codelines 0.2.1 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cff687b0191c01367052200b71269447012219db
4
- data.tar.gz: 7111a2585cea7f630ddd5e7eca7951e65c683c46
3
+ metadata.gz: ec8dc371afa9a60d9883bcd466ea9d1df1a0e4bf
4
+ data.tar.gz: 9d6360a85febc79a8892acd01b118081fc62bafe
5
5
  SHA512:
6
- metadata.gz: b799c0642f02f9e3c3e3c995320176996f89d0267c2c9e0b09689ac5c7b278569cd687a722bce6609cc7fb7be3eec1fbc432f5445b1c88ab27bf9558061b0a2c
7
- data.tar.gz: 04093085564ec678a2458120ae6b69fd3064fdd1fe8ce68231020565abdc0acf4cb229ab60c8f21eb4835afbf74fb7a3eceb2cbecb10312d7b0b343a71ee4697
6
+ metadata.gz: 940c5a6fe214dec266e49dedb258d3217cc0b9de01ee68f87ce5f498848c336ed9c35a3c5400ab2591f50078755039171ea63db7c85d566a17f386122c1de296
7
+ data.tar.gz: da79974e92a1e4aa55413cad33c01a5998bb54b68e5e1db850a47d449b4da8af000270664f814295502255b2437ad0803104d30575dbcc80b2290622a44ddaa7
data/bin/codelines CHANGED
@@ -36,15 +36,15 @@ OptionParser.new do |o|
36
36
  options[:branch ] = branch
37
37
  end
38
38
 
39
- o.on '-c', '--no-comments', 'Ignore comments' do |branch|
39
+ o.on '-c', '--no-comments', 'Ignore comments' do
40
40
  options[:ignore_comments] = true
41
41
  end
42
42
 
43
- o.on '-i', '-ignore FILE1,FILE2...', 'Ignore given files' do |files|
44
- options[:ignore] = files.split ?,
43
+ o.on '-i', '-ignore FILE1,FILE2...', 'Ignore given files' do |files|
44
+ options[:ignore ] = files.split ?,
45
45
  end
46
46
 
47
- o.on '-s', '--authenticate USERNAME:PASSWORD', 'Perform the sign in' do |data|
47
+ o.on '-s', '--authenticate USERNAME:PASSWORD', 'Perform the sign in' do |data|
48
48
  data = data.split ?:
49
49
  options[:username] = data.shift
50
50
  options[:password] = data.pop
@@ -59,7 +59,7 @@ adapter = CodeLines.constants.map { |p|
59
59
  "CodeLines::#{p}".split('::').inject(Object) { |o, c| o.const_get c }
60
60
  }.select { |c| c.to_s.split('::').last.downcase == options[:adapter] }.first
61
61
 
62
- github = CodeLines::GitHub.new options[:profile]
63
- github.authenticate options[:username], options[:password] if options[:username] && options[:password]
62
+ CodeLines.setup CodeLines::GitHub, options[:profile]
63
+ CodeLines.authenticate options[:username], options[:password] if options[:username] && options[:password]
64
64
 
65
- puts github.count repository: [ { name: options[:repository], branch: options[:branch], ignore: options[:ignore] } ], ignore_comments: options[:ignore_comments]
65
+ puts CodeLines.count repository: [ { name: options[:repository], branch: options[:branch], ignore: options[:ignore] } ], ignore_comments: options[:ignore_comments]
@@ -14,7 +14,12 @@ class << self
14
14
  attr_reader :adapter
15
15
 
16
16
  def setup(adapter, profile)
17
- @adapter = adapter.new self, profile
17
+ @adapter = adapter.new profile
18
+ end
19
+
20
+ def authentication(*args, &block)
21
+ raise LoadError, 'adapter not found' unless @adapter
22
+ @adapter.authentication *args, &block
18
23
  end
19
24
 
20
25
  def count(*args, &block)
@@ -10,6 +10,6 @@
10
10
 
11
11
  module CodeLines
12
12
 
13
- VERSION = '0.2.1'
13
+ VERSION = '0.3'
14
14
 
15
15
  end
data/test/github_spec.rb CHANGED
@@ -4,10 +4,10 @@ require 'codelines/adapters/github'
4
4
 
5
5
  describe CodeLines::GitHub do
6
6
  it 'counts the lines of code contained in a GitHub repository' do
7
- github = CodeLines::GitHub.new 'RoxasShadow'
7
+ CodeLines.setup CodeLines::GitHub, 'RoxasShadow'
8
8
 
9
- result = github.count repository: [ { name: :codelines } ], ignore_comments: false
10
- filtered_result = github.count repository: [ { name: :codelines, ignore: %w(Readme.md) } ], ignore_comments: true
9
+ result = CodeLines.count repository: [ { name: :codelines } ], ignore_comments: false
10
+ filtered_result = CodeLines.count repository: [ { name: :codelines, ignore: %w(Readme.md) } ], ignore_comments: true
11
11
  result.should be > 100
12
12
  filtered_result.should be > 100
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codelines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano