codelines 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/codelines +6 -2
- data/lib/codelines/adapter.rb +2 -2
- data/lib/codelines/adapters/github.rb +2 -0
- data/lib/codelines/version.rb +1 -1
- data/test/github_spec.rb +7 -2
- 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: 915d6fbe038221b16349c90e17a3c3d636425bdd
|
4
|
+
data.tar.gz: d30f76ec3d6d64c31adc07fd40cbc0c3e71f0cbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb2248bbbbc77d45b9ffe8868b059d401e912c53a850b8bef25345a5979b2dc3d199679a80c14a7c1c143acc9440c20099edc9f2f6672ac6580fd6c4784817ff
|
7
|
+
data.tar.gz: 52b055fd4a37483a79fd6924abddf66bcdda0625176c5160d61e9bdeeea7473e29891ec1afee4fbda5df3a7be1f4b3a47a530d0b649127c46c008028ef78f0d3
|
data/bin/codelines
CHANGED
@@ -36,10 +36,14 @@ OptionParser.new do |o|
|
|
36
36
|
options[:branch ] = branch
|
37
37
|
end
|
38
38
|
|
39
|
-
o.on '-c', '--no-comments',
|
39
|
+
o.on '-c', '--no-comments', 'Ignore comments' do |branch|
|
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 ?,
|
45
|
+
end
|
46
|
+
|
43
47
|
o.on '-s', '--authenticate USERNAME:PASSWORD', 'Perform the sign in' do |data|
|
44
48
|
data = data.split ?:
|
45
49
|
options[:username] = data.shift
|
@@ -58,4 +62,4 @@ adapter = CodeLines.constants.map { |p|
|
|
58
62
|
github = CodeLines::GitHub.new options[:profile]
|
59
63
|
github.authenticate options[:username], options[:password] if options[:username] && options[:password]
|
60
64
|
|
61
|
-
puts github.count repository: [ { name: options[:repository], branch: options[:branch] } ], ignore_comments: options[:ignore_comments]
|
65
|
+
puts github.count repository: [ { name: options[:repository], branch: options[:branch], ignore: options[:ignore] } ], ignore_comments: options[:ignore_comments]
|
data/lib/codelines/adapter.rb
CHANGED
@@ -12,11 +12,11 @@ module CodeLines
|
|
12
12
|
|
13
13
|
class Adapter
|
14
14
|
def authenticate(*args, &block)
|
15
|
-
raise NotImplementedError, 'authenticate has been
|
15
|
+
raise NotImplementedError, 'authenticate has not been implemented'
|
16
16
|
end
|
17
17
|
|
18
18
|
def count(*args, &block)
|
19
|
-
raise NotImplementedError, 'count has been
|
19
|
+
raise NotImplementedError, 'count has not been implemented'
|
20
20
|
end
|
21
21
|
|
22
22
|
protected
|
@@ -34,6 +34,8 @@ class GitHub < Adapter
|
|
34
34
|
@repositories[name] = fetch(name) if reload || !@repositories.include?(name)
|
35
35
|
|
36
36
|
@repositories[name].each { |github|
|
37
|
+
next if name[:ignore].is_a?(Array) && name[:ignore].include?(github.name)
|
38
|
+
|
37
39
|
source = Base64.decode64 github.content
|
38
40
|
source.gsub!(/\r\n?/m, "\n")
|
39
41
|
source.gsub!(/\/\*![^*]*\*+(?:[^*\/][^*]*\*+)*\//m, '') if ignore_comments
|
data/lib/codelines/version.rb
CHANGED
data/test/github_spec.rb
CHANGED
@@ -6,7 +6,12 @@ describe CodeLines::GitHub do
|
|
6
6
|
it 'counts the lines of code contained in a GitHub repository' do
|
7
7
|
github = CodeLines::GitHub.new 'RoxasShadow'
|
8
8
|
|
9
|
-
github.count
|
10
|
-
github.count
|
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
|
11
|
+
|
12
|
+
result.should be > 100
|
13
|
+
filtered_result.should be > 100
|
14
|
+
|
15
|
+
filtered_result.should_not be result
|
11
16
|
end
|
12
17
|
end
|