gitloc-megannnnnnn 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 937dab1a78fb33487b62f71865eea4052114a2b4
4
- data.tar.gz: 51d9bf1b534814c7c9965c23fcf29ba1019137ac
3
+ metadata.gz: dc72cbfcd0f08f65d8d78c49b9af2a8563bd3690
4
+ data.tar.gz: 8a7ded361e8be914c8a4c6e3fde2b883f7856660
5
5
  SHA512:
6
- metadata.gz: 7fbd09c298de4f984cbac359fadc8ae9dd6ec6bbfea8000c12363886eecd6ac9d5a05aa302f0b152737689046a765305dca11b7d15b3f5254a942f95e213d18c
7
- data.tar.gz: d7b4a11bb2b741f75642d7fa7e414f9004a8c91d39d06c590d04f3d419533ad904172f89f80cb639bc630a77589aeaf610ddb6fee20ba51aaf619bee6fce512e
6
+ metadata.gz: 8d75fe724b4100bf48b0e56bb8a2aedcd454f67cab9358ba1b3203e851918e7ab8d843295d5bbd162269aac75618ab0eec1f943518a50b7e45d8a85643071cb6
7
+ data.tar.gz: aab9d676b8cb3cacc559ce3d194ac92723c02f6f9236a2ddc7116b828f8e8546f62ced4f442f5a0f75eac94822f941dc5592ccb848638d4a7324c8b134a8e29e
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gitloc-megannnnnnn (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ binding_of_caller (0.7.2)
10
+ debug_inspector (>= 0.0.1)
11
+ coderay (1.1.1)
12
+ debug_inspector (0.0.2)
13
+ interception (0.5)
14
+ method_source (0.8.2)
15
+ minitest (5.8.4)
16
+ mrspec (0.3.1)
17
+ minitest (~> 5.0)
18
+ rspec-core (~> 3.2)
19
+ what_weve_got_here_is_an_error_to_communicate (~> 0.0.8)
20
+ pry (0.10.3)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.8.1)
23
+ slop (~> 3.4)
24
+ rouge (1.10.1)
25
+ rspec-core (3.4.3)
26
+ rspec-support (~> 3.4.0)
27
+ rspec-support (3.4.1)
28
+ slop (3.6.0)
29
+ what_weve_got_here_is_an_error_to_communicate (0.0.8)
30
+ binding_of_caller (~> 0.7.2)
31
+ interception (~> 0.5)
32
+ rouge (~> 1.8, != 1.9.1)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ gitloc-megannnnnnn!
39
+ mrspec (~> 0.3)
40
+ pry
41
+
42
+ BUNDLED WITH
43
+ 1.11.2
data/bin/gitloc CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require 'gitloc'
4
- Gitloc.call(ARGV, $stdout, $stderr)
3
+ require 'gitloc/binary'
4
+ Gitloc::Binary.call(ARGV, $stdout, $stderr)
data/gitloc.gemspec CHANGED
@@ -9,7 +9,9 @@ Gem::Specification.new do |s|
9
9
  s.description = "Example project for Code Platoon, see https://github.com/darkstarre/gitloc-- gives lines-of-code information for a git repo."
10
10
  s.authors = ["Megan Nilles"]
11
11
  s.email = 'darkstarre@hotmail.com.com'
12
- s.files = Dir["**/*"].select { |f| File.file? f }
12
+ s.files = Dir["**/*"].select { |f| File.file? f } - Dir['*.gem']
13
13
  s.homepage = 'https://github.com/darkstarre/gitloc'
14
14
  s.executables << 'gitloc'
15
+ s.add_development_dependency 'mrspec', '~> 0.3'
16
+ s.add_development_dependency 'pry'
15
17
  end
data/lib/gitloc.rb CHANGED
@@ -1,24 +1,20 @@
1
1
  require 'tmpdir'
2
2
  require 'open3'
3
-
3
+ require 'gitloc/errors'
4
4
  require 'gitloc/version'
5
+ require 'gitloc/line_counts'
5
6
 
6
7
  class Gitloc
7
- def self.call(argv, outstream, errstream)
8
- repo = argv.first
9
- Dir.mktmpdir { |dir|
8
+ def self.call(repo)
9
+ names_to_bodies = Dir.mktmpdir { |dir|
10
10
  Dir.chdir dir
11
11
  out, err, status = Open3.capture3 'git', 'clone', repo, 'cloned'
12
- unless status.success?
13
- errstream.puts out, err
14
- exit "Failed somehow >.<"
15
- end
12
+ raise RepoDoesNotExistError, repo unless status.success?
16
13
  Dir.chdir 'cloned'
17
- files = Dir['**/*'].reject { |name| File.directory? name }
18
- files.each do |filename|
19
- loc = File.readlines(filename).count { |line| line !~ /^\s*$/ }
20
- outstream.puts "#{loc}\t#{filename}"
21
- end
14
+ Dir['**/*'].reject { |name| File.directory? name }
15
+ .map { |name| [name, File.read(name)]}
22
16
  }
17
+
18
+ LineCounts.call(names_to_bodies)
23
19
  end
24
20
  end
@@ -0,0 +1,13 @@
1
+ require 'gitloc'
2
+
3
+ class Gitloc
4
+ class Binary
5
+ def self.call(argv, outstream, errstream)
6
+ repo = argv.first
7
+ files_to_lines = Gitloc.call(repo)
8
+ files_to_lines.each do |filename, loc|
9
+ outstream.puts "#{loc}\t#{filename}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ class Gitloc
2
+ Error = Class.new StandardError
3
+ end
@@ -0,0 +1,10 @@
1
+ class Gitloc
2
+ module LineCounts
3
+ def self.call(names_to_bodies)
4
+ names_to_bodies.map do |name, body|
5
+ loc = body.lines.count { |line| line !~ /^\s*$/ }
6
+ [name, loc]
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  class Gitloc
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'gitloc'
2
+
3
+ class Gitloc
4
+ Error = Class.new StandardError
5
+
6
+ class RepoDoesNotExistError < Error
7
+ def initialize(repo_name)
8
+ super "#{repo_name} does not exist"
9
+ end
10
+ end
11
+ end
12
+
13
+ RSpec.describe Gitloc do
14
+ it 'raises RepoDoesNotExistError when the repo does not exist' do
15
+ expect { Gitloc.call("not-a-repo") }
16
+ .to raise_error Gitloc::RepoDoesNotExistError, /not-a-repo/
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ class Gitloc
2
+ module LineCounts
3
+ def self.call(names_to_bodies)
4
+ names_to_bodies
5
+ .map { |name, body| [name, count_lines(body)]}
6
+ .select { |name, body| body}
7
+ end
8
+
9
+ def self.count_lines(body)
10
+ body.lines.count { |line| line !~ /^\s*$/ }
11
+ [name, loc]
12
+ rescue ArgumentError
13
+ nil
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitloc-megannnnnnn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Megan Nilles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mrspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: Example project for Code Platoon, see https://github.com/darkstarre/gitloc--
14
42
  gives lines-of-code information for a git repo.
15
43
  email: darkstarre@hotmail.com.com
@@ -18,13 +46,20 @@ executables:
18
46
  extensions: []
19
47
  extra_rdoc_files: []
20
48
  files:
49
+ - Gemfile
50
+ - Gemfile.lock
21
51
  - Readme.md
22
52
  - bin/gitloc
23
53
  - gitloc.gemspec
24
54
  - lib/gitloc.rb
55
+ - lib/gitloc/binary.rb
56
+ - lib/gitloc/errors.rb
57
+ - lib/gitloc/line_counts.rb
25
58
  - lib/gitloc/version.rb
26
59
  - test/acceptance_test.rb
27
60
  - test/fixtures/2loc
61
+ - test/gitloc_test.rb
62
+ - test/line_counts_test.rb
28
63
  homepage: https://github.com/darkstarre/gitloc
29
64
  licenses:
30
65
  - MIT