-
Measure interest rates. Ruby code that changed most frequently in the last year.
git log --format=format: --name-only --after="2017-05-18" -- "*.rb" | egrep -v '^$' | sort | uniq -c | sort -r | head -10
-
Measure size of each file. Lines of code is a simple proxy for complexity. Just Ruby files
cloc . --by-file --csv --include-lang=Ruby --quiet
-
Combine the two into a single output of filename, change_frequency, size.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ArrayHelper | |
# Returns a new Array which is the result | |
# flattening any nested arrays. | |
# | |
# @param [Array] the array to flatten | |
# @param [Array] the array to append results to. | |
# | |
# @return [Array] the flattened array. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe MailingList do | |
let(:notifications) { double('notifications') } | |
let(:user) { User.new } | |
it 'registers a new user' do | |
expect(notifications).to receive(:call).with(user, 'list_name') | |
mailing_list = MailingList.new('list_name', notifications) | |
mailing_list.add(user) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Analytics | |
ConnectionFailure = Class.new(StandardError) | |
def self.sync(account) | |
new(Analytics::Client.new(CC.config[:analytics_api_key])).sync(account) | |
end | |
def initialize(analytics_client) | |
@analytics_client = analytics_client | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JMSMockObjectFactory objectFactory = new JMSMockObjectFactory(); | |
JMSTestModule testModule = new JMSTestModule(objectFactory); | |
TopicConnectionFactory beTopicConnectionFactory = objectFactory.createMockTopicConnectionFactory(); | |
Topic beTopic = objectFactory.getDestinationManager().createTopic("sampleTopic"); | |
//Perform you test - Publish the message | |
//Create the expected Message by the subscriber | |
MockMessage mockmessage = new MockMessage(); | |
//set properties to mockmessage | |
//condition - similar to assertequals | |
testModule.verifyReceivedTopicMessageEquals("sampleTopic", 1, mockmessage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppServerConfiguration | |
attr_accessor :port, :admin_password | |
end | |
class Configuration | |
attr_accessor :tail_logs, :max_connections, :admin_password | |
def initialize(block) | |
block.call(self) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def counter(start=0, increment=1) | |
lambda do | |
initial = start | |
start += increment | |
initial | |
end | |
end | |
result = counter(10, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def counter(start=0, increment=1) | |
lambda do | |
puts start | |
start += increment | |
end | |
end | |
result = counter(10, 2) | |
result.call # 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When /^(\d+) x \$(\d+)/ do |qty, price| | |
@basket ||= [] | |
@basket << (qty.to_i * price.to_i) | |
end | |
Then /^Total bill = \$(.+)$/ do |expected_total| | |
@basket.inject(0) {|memo, item| memo += item}.should eql(expected_total.to_i) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: A simple shopping basket | |
Scenario: adding items | |
* 1 x $15 screw-driver | |
* 2 x $12 lamp | |
* Total bill = $39 |
NewerOlder