Class: DioTests::Client
- Inherits:
-
Object
- Object
- DioTests::Client
- Defined in:
- lib/dio_tests/client.rb
Instance Attribute Summary collapse
-
#minus_count ⇒ Object
readonly
Returns the value of attribute minus_count.
-
#plus_count ⇒ Object
readonly
Returns the value of attribute plus_count.
Class Method Summary collapse
Instance Method Summary collapse
- #git_config(name) ⇒ Object
- #git_log ⇒ Object
-
#initialize(args = {}) ⇒ Client
constructor
A new instance of Client.
- #print_test_count ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/dio_tests/client.rb', line 7 def initialize(args={}) @format = args[:format] @since_commit = args[:since_commit] || "master" @author = args[:author] || git_config("user.name") end |
Instance Attribute Details
#minus_count ⇒ Object (readonly)
Returns the value of attribute minus_count.
5 6 7 |
# File 'lib/dio_tests/client.rb', line 5 def minus_count @minus_count end |
#plus_count ⇒ Object (readonly)
Returns the value of attribute plus_count.
5 6 7 |
# File 'lib/dio_tests/client.rb', line 5 def plus_count @plus_count end |
Class Method Details
.format_pattern(format) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/dio_tests/client.rb', line 44 def self.format_pattern(format) raise "format is require" unless format raise "Not found: #{format} in formats.yml" unless formats[format] formats[format] end |
.formats ⇒ Object
51 52 53 |
# File 'lib/dio_tests/client.rb', line 51 def self.formats formats = YAML.load_file("#{File.dirname(__FILE__)}/formats.yml") end |
Instance Method Details
#git_config(name) ⇒ Object
40 41 42 |
# File 'lib/dio_tests/client.rb', line 40 def git_config(name) `git config --get #{name}`.strip end |
#git_log ⇒ Object
34 35 36 37 38 |
# File 'lib/dio_tests/client.rb', line 34 def git_log git_log_command = "git log --author=#{@author} --remove-empty --oneline --unified=0 --ignore-all-space #{@since_commit}..HEAD" puts git_log_command `#{git_log_command}` end |
#print_test_count ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dio_tests/client.rb', line 13 def print_test_count format_pattern = DioTests::Client.format_pattern(@format) log = git_log @plus_count = log.each_line.select{|line| line[0] == "+"}. inject(0){|count, line| line[0] = "" count += 1 if line =~ /#{format_pattern}/ count } || 0 @minus_count = log.each_line.select{|line| line[0] == "-"}. inject(0){|count, line| line[0] = "" count += 1 if line =~ /#{format_pattern}/ count } || 0 puts "plus=#{@plus_count}, minus=#{@minus_count}, increment=#{@plus_count - @minus_count}" end |