codelines 0.1 → 0.2

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: 787e27202ae5a1e7083ad43a7e776376181778d5
4
- data.tar.gz: ef4fcc6d782e63ed203ec97d5958b94339cb8bf0
3
+ metadata.gz: 915d6fbe038221b16349c90e17a3c3d636425bdd
4
+ data.tar.gz: d30f76ec3d6d64c31adc07fd40cbc0c3e71f0cbc
5
5
  SHA512:
6
- metadata.gz: 57b6ec1dd7f3b1b0f61f1f5eb92faa5d1962ea2998893995756dfa2ff1e9ae2d053e8f3f4395506501407d28eefcc2c797b77b5ac2b258c68d89ae6f98f399a0
7
- data.tar.gz: bf928cc509c99bebbe83356e9787ffe3d5c8fcbbdbc653df8b9756c71c214b86e61a8db7a375506bb201908dc1cf16a026426623b137c98c97362ced8a37e337
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', 'Ignore comments' do |branch|
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]
@@ -12,11 +12,11 @@ module CodeLines
12
12
 
13
13
  class Adapter
14
14
  def authenticate(*args, &block)
15
- raise NotImplementedError, 'authenticate has been not implemented'
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 not implemented'
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
@@ -10,6 +10,6 @@
10
10
 
11
11
  module CodeLines
12
12
 
13
- VERSION = '0.1'
13
+ VERSION = '0.2'
14
14
 
15
15
  end
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(repository: [ { name: :codelines } ], ignore_comments: true ).should be > 100
10
- github.count(repository: [ { name: :codelines } ], ignore_comments: false).should be > 100
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
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.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano