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 +4 -4
- data/bin/codelines +7 -7
- data/lib/codelines/codelines.rb +6 -1
- data/lib/codelines/version.rb +1 -1
- data/test/github_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec8dc371afa9a60d9883bcd466ea9d1df1a0e4bf
|
4
|
+
data.tar.gz: 9d6360a85febc79a8892acd01b118081fc62bafe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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'
|
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'
|
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'
|
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
|
-
|
63
|
-
|
62
|
+
CodeLines.setup CodeLines::GitHub, options[:profile]
|
63
|
+
CodeLines.authenticate options[:username], options[:password] if options[:username] && options[:password]
|
64
64
|
|
65
|
-
puts
|
65
|
+
puts CodeLines.count repository: [ { name: options[:repository], branch: options[:branch], ignore: options[:ignore] } ], ignore_comments: options[:ignore_comments]
|
data/lib/codelines/codelines.rb
CHANGED
@@ -14,7 +14,12 @@ class << self
|
|
14
14
|
attr_reader :adapter
|
15
15
|
|
16
16
|
def setup(adapter, profile)
|
17
|
-
@adapter = adapter.new
|
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)
|
data/lib/codelines/version.rb
CHANGED
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
|
-
|
7
|
+
CodeLines.setup CodeLines::GitHub, 'RoxasShadow'
|
8
8
|
|
9
|
-
result =
|
10
|
-
filtered_result =
|
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
|
|