gitloc-matthewswan 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 731cdae18dd18d1159d23ac3ab9d4528d72f1186
4
+ data.tar.gz: e6dac46ac6b7295c17cfb3a9901c7c68c789690b
5
+ SHA512:
6
+ metadata.gz: 6972d3961332576c5d80e7ebfff7e19cb3c0268c78a97312c0e19b6f8487c1b6b743e0f3b65d617af76702665292c18d536f9ab4a01e1c515254ff90fc9bb9c3
7
+ data.tar.gz: 8430fdc7fc1931f10b3af39711bd32775ac8c57eee9b717a73d57eba3ceb357ba71f20ee35e717dea32b354e103053f0164f69b3be901fbf1f39e001ab668311
data/Readme.md ADDED
@@ -0,0 +1,34 @@
1
+ Gitloc
2
+ ======
3
+
4
+ Takes a git url, prints out information about how many lines of code it is.
5
+
6
+ [MIT License](http://opensource.org/licenses/MIT)Gitloc
7
+ ======
8
+
9
+ Takes a git url, prints out information about how many lines of code it has.
10
+
11
+ [MIT License](http://opensource.org/licenses/MIT)
12
+ -------------------------------------------------
13
+
14
+ The MIT License (MIT)
15
+
16
+ Copyright (c) 2016 Matthew Swan
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining a copy
19
+ of this software and associated documentation files (the "Software"), to deal
20
+ in the Software without restriction, including without limitation the rights
21
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
+ copies of the Software, and to permit persons to whom the Software is
23
+ furnished to do so, subject to the following conditions:
24
+
25
+ The above copyright notice and this permission notice shall be included in
26
+ all copies or substantial portions of the Software.
27
+
28
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34
+ THE SOFTWARE.
data/bin/gitloc ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'tmpdir'
4
+ require 'open3'
5
+
6
+ repo = ARGV.first
7
+
8
+ Dir.mktmpdir { |dir|
9
+ Dir.chdir dir
10
+ out, err, status = Open3.capture3 'git', 'clone', repo, 'cloned'
11
+ unless status.success?
12
+ $stderr.puts out, err
13
+ exit "Failed somehow >.<"
14
+ end
15
+ Dir.chdir 'cloned'
16
+ files = Dir['**/*'].reject { |name| File.directory? name }
17
+ files.each do |filename|
18
+ loc = File.readlines(filename).count { |line| line !~ /^\s*$/ }
19
+ puts "#{loc}\t#{filename}"
20
+ end
21
+ }
data/gitloc.gemspec ADDED
@@ -0,0 +1,13 @@
1
+ # update to match your information, not mine :)
2
+ Gem::Specification.new do |s|
3
+ s.name = 'gitloc-matthewswan'
4
+ s.version = '0.1.0'
5
+ s.licenses = ['MIT']
6
+ s.summary = "Example project -- gives lines-of-code information for a git repo"
7
+ s.description = "Example project for the Turing School of Software and Design, see https://github.com/JoshCheek/elective-building-a-gem -- gives lines-of-code information for a git repo."
8
+ s.authors = ["Matthew Swan"]
9
+ s.email = 'swanm86@gmail.com'
10
+ s.files = Dir["**/*"].select { |f| File.file? f }
11
+ s.homepage = 'https://github.com/MatthewSwan/gitloc'
12
+ s.executables << 'gitloc'
13
+ end
Binary file
@@ -0,0 +1,31 @@
1
+ require 'open3' # we'll use this to invoke the binary
2
+
3
+ RSpec.describe 'gitloc binary' do
4
+ let(:binpath) { File.expand_path '../../bin/gitloc', __FILE__ }
5
+ let(:repopath) { File.expand_path '../..', __FILE__ }
6
+
7
+ it 'takes a git repository and tells me how many lines of code are in each file' do
8
+ stdout, stderr, exitstatus = Open3.capture3(binpath, repopath)
9
+ expect(stdout).to match /2.*?spec\/fixtures\/2loc/
10
+ expect(exitstatus).to be_success
11
+ end
12
+ end
13
+
14
+ # we can run the program and get its stdout and stderr
15
+ stdout, stderr, exitstatus = Open3.capture3 'ruby', '-e', '
16
+ $stdout.puts "hello"
17
+ $stderr.puts "goodbye"
18
+ '
19
+ stdout # => "hello\n"
20
+ stderr # => "goodbye\n"
21
+ exitstatus # => #<Process::Status: pid 11855 exit 0>
22
+
23
+ # an exit status of 0 means it succeeded
24
+ stdout, stderr, exitstatus = Open3.capture3 'ruby', '-e', 'exit 0'
25
+ exitstatus.exitstatus # => 0
26
+ exitstatus.success? # => true
27
+
28
+ # an exit status of nonzero means it failed
29
+ stdout, stderr, exitstatus = Open3.capture3 'ruby', '-e', 'exit 12'
30
+ exitstatus.exitstatus # => 12
31
+ exitstatus.success? # => false
@@ -0,0 +1,2 @@
1
+ 1
2
+ 2
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitloc-matthewswan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Swan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Example project for the Turing School of Software and Design, see https://github.com/JoshCheek/elective-building-a-gem
14
+ -- gives lines-of-code information for a git repo.
15
+ email: swanm86@gmail.com
16
+ executables:
17
+ - gitloc
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - Readme.md
22
+ - bin/gitloc
23
+ - gitloc.gemspec
24
+ - seeing_is_believing-2.2.0.gem
25
+ - spec/acceptance_spec.rb
26
+ - spec/fixtures/2loc
27
+ homepage: https://github.com/MatthewSwan/gitloc
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.5.1
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Example project -- gives lines-of-code information for a git repo
51
+ test_files: []
52
+ has_rdoc: