hoc 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ service_name: travis-pro
2
+ repo_token: E8h8J4kUBHZNPsh2leUD2UzW02VCGftrU
@@ -0,0 +1,7 @@
1
+ coverage/
2
+ Gemfile.lock
3
+ .idea/
4
+ *.gem
5
+ .bundle/
6
+ .DS_Store
7
+ rdoc/
@@ -0,0 +1,2 @@
1
+ MethodLength:
2
+ Max: 30
@@ -0,0 +1,18 @@
1
+ assets:
2
+ rubygems.yml: "yegor256/home#assets/rubygems.yml"
3
+ s3cfg: "yegor256/home#assets/s3cfg"
4
+
5
+ install: |
6
+ sudo gem install pdd
7
+
8
+ release:
9
+ script: |
10
+ sudo bundle install
11
+ rake
12
+ rm -rf *.gem
13
+ sed -i "s/1\.0\.snapshot/${tag}/g" lib/hoc/version.rb
14
+ gem build hoc.gemspec
15
+ chmod 0600 ../rubygems.yml
16
+ gem push *.gem --config-file ../rubygems.yml
17
+ pdd --source=$(pwd) --verbose --file=hoc.xml
18
+ s3cmd --no-progress put hoc.xml --config=../s3cfg s3://pdd.teamed.io/hoc.xml
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'coveralls'
25
+
26
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
27
+ SimpleCov::Formatter::HTMLFormatter,
28
+ Coveralls::SimpleCov::Formatter
29
+ ]
30
+ SimpleCov.start do
31
+ add_filter "/test/"
32
+ add_filter "/features/"
33
+ minimum_coverage 100
34
+ end
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache: bundler
3
+ branches:
4
+ only:
5
+ - master
6
+ install:
7
+ - sudo apt-get update
8
+ - travis_retry sudo apt-get install -y --fix-missing libmagic1 libmagic-dev
9
+ - travis_retry bundle install
10
+ script:
11
+ - rake
12
+
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ source 'https://rubygems.org'
25
+ gemspec
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2014 Teamed.io
4
+ Copyright (c) 2014 Yegor Bugayenko
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the 'Software'), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,20 @@
1
+ [![Made By Teamed.io](http://img.teamed.io/btn.svg)](http://www.teamed.io)
2
+ [![DevOps By Rultor.com](http://www.rultor.com/b/teamed/hoc)](http://www.rultor.com/p/teamed/hoc)
3
+
4
+ [![Build Status](https://travis-ci.org/teamed/hoc.svg)](https://travis-ci.org/teamed/hoc)
5
+ [![Gem Version](https://badge.fury.io/rb/hoc.svg)](http://badge.fury.io/rb/hoc)
6
+ [![Dependency Status](https://gemnasium.com/teamed/hoc.svg)](https://gemnasium.com/teamed/hoc)
7
+ [![Code Climate](http://img.shields.io/codeclimate/github/teamed/hoc.svg)](https://codeclimate.com/github/teamed/hoc)
8
+ [![Coverage Status](https://img.shields.io/coveralls/teamed/hoc.svg)](https://coveralls.io/r/teamed/hoc)
9
+
10
+ Install it first:
11
+
12
+ ```bash
13
+ gem install hoc
14
+ ```
15
+
16
+ Run it locally and read its output:
17
+
18
+ ```bash
19
+ hoc --help
20
+ ```
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'rubygems'
25
+ require 'rake'
26
+ require 'rdoc'
27
+
28
+ def name
29
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
30
+ end
31
+
32
+ def version
33
+ Gem::Specification.load(Dir['*.gemspec'].first).version
34
+ end
35
+
36
+ task default: [:clean, :test, :features, :rubocop]
37
+
38
+ task :clean do
39
+ rm_rf 'coverage'
40
+ end
41
+
42
+ require 'rake/testtask'
43
+ desc 'Run all unit tests'
44
+ Rake::TestTask.new(:test) do |test|
45
+ test.libs << 'lib' << 'test'
46
+ test.pattern = 'test/**/test_*.rb'
47
+ test.verbose = true
48
+ end
49
+
50
+ require 'rdoc/task'
51
+ desc 'Build RDoc documentation'
52
+ Rake::RDocTask.new do |rdoc|
53
+ rdoc.rdoc_dir = 'rdoc'
54
+ rdoc.title = "#{name} #{version}"
55
+ rdoc.rdoc_files.include('README*')
56
+ rdoc.rdoc_files.include('lib/**/*.rb')
57
+ end
58
+
59
+ require 'rubocop/rake_task'
60
+ desc 'Run RuboCop on all directories'
61
+ RuboCop::RakeTask.new(:rubocop) do |task|
62
+ task.fail_on_error = true
63
+ task.requires << 'rubocop-rspec'
64
+ end
65
+
66
+ require 'cucumber/rake/task'
67
+ Cucumber::Rake::Task.new(:features) do |t|
68
+ t.profile = 'travis'
69
+ end
70
+ Cucumber::Rake::Task.new(:'features:html') do |t|
71
+ t.profile = 'html_report'
72
+ end
data/bin/hoc ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # Copyright (c) 2014 Teamed.io
5
+ # Copyright (c) 2014 Yegor Bugayenko
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the 'Software'), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ STDOUT.sync = true
26
+
27
+ require 'hoc'
28
+ require 'slop'
29
+ require 'hoc/version'
30
+
31
+ opts = Slop.parse(ARGV, strict: true, help: true) do
32
+ banner "Usage (#{HOC::VERSION}): hoc [options]"
33
+ on 'f', 'format', 'Output format (text|xml|json|int)', default: 'int'
34
+ end
35
+
36
+ if opts.help?
37
+ puts opts
38
+ exit
39
+ end
40
+
41
+ Encoding.default_external = Encoding::UTF_8
42
+ Encoding.default_internal = Encoding::UTF_8
43
+
44
+ puts HOC::Base.new(Dir.pwd, opts[:format]).report
@@ -0,0 +1,3 @@
1
+ default: --format pretty
2
+ travis: --format progress
3
+ html_report: --format progress --format html --out=features_report.html
@@ -0,0 +1,22 @@
1
+ Feature: Command Line Processing
2
+ As a source code writer I want to be able to
3
+ calculate my hits-of-code metric
4
+
5
+ Scenario: Help can be printed
6
+ When I run bin/hoc with "-h"
7
+ Then Exit code is zero
8
+ And Stdout contains "--format"
9
+
10
+ Scenario: Simple git repo
11
+ Given I run bash:
12
+ """
13
+ set -e
14
+ set -x
15
+ git init .
16
+ echo 'hello, world!' > test.txt
17
+ git add test.txt
18
+ git commit -m test
19
+ """
20
+ When I run bin/hoc with "-f int"
21
+ Then Exit code is zero
22
+ And Stdout contains "1"
@@ -0,0 +1,22 @@
1
+ Feature: Gem Package
2
+ As a source code writer I want to be able to
3
+ package the Gem into .gem file
4
+
5
+ Scenario: Gem can be packaged
6
+ Given I have a "execs.rb" file with content:
7
+ """
8
+ #!/usr/bin/env ruby
9
+ require 'rubygems'
10
+ spec = Gem::Specification::load('./spec.rb')
11
+ fail 'no executables' if spec.executables.empty?
12
+ """
13
+ When I run bash:
14
+ """
15
+ set -e
16
+ cd hoc
17
+ gem build hoc.gemspec
18
+ gem specification --ruby hoc-*.gem > ../spec.rb
19
+ cd ..
20
+ ruby execs.rb
21
+ """
22
+ Then Exit code is zero
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'hoc'
25
+ require 'tmpdir'
26
+ require 'slop'
27
+ require 'English'
28
+
29
+ Before do
30
+ @cwd = Dir.pwd
31
+ @dir = Dir.mktmpdir('test')
32
+ FileUtils.mkdir_p(@dir) unless File.exist?(@dir)
33
+ Dir.chdir(@dir)
34
+ end
35
+
36
+ After do
37
+ Dir.chdir(@cwd)
38
+ FileUtils.rm_rf(@dir) if File.exist?(@dir)
39
+ end
40
+
41
+ Given(/^I run bash:$/) do |bash|
42
+ FileUtils.copy_entry(@cwd, File.join(@dir, 'hoc'))
43
+ @stdout = `#{bash}`
44
+ @exitstatus = $CHILD_STATUS.exitstatus
45
+ end
46
+
47
+ When(/^I run bin\/hoc with "([^"]*)"$/) do |arg|
48
+ home = File.join(File.dirname(__FILE__), '../..')
49
+ @stdout = `ruby -I#{home}/lib #{home}/bin/hoc #{arg}`
50
+ @exitstatus = $CHILD_STATUS.exitstatus
51
+ end
52
+
53
+ Then(/^Stdout contains "([^"]*)"$/) do |txt|
54
+ unless @stdout.include?(txt)
55
+ fail "STDOUT doesn't contain '#{txt}':\n#{@stdout}"
56
+ end
57
+ end
58
+
59
+ Then(/^Exit code is zero$/) do
60
+ fail "Non-zero exit code #{@exitstatus}" unless @exitstatus == 0
61
+ end
62
+
63
+ Given(/^I have a "([^"]*)" file with content:$/) do |file, text|
64
+ FileUtils.mkdir_p(File.dirname(file)) unless File.exist?(file)
65
+ File.open(file, 'w') do |f|
66
+ f.write(text)
67
+ end
68
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ # it doesn't work, I don't know why :(
25
+ # require 'simplecov'
26
+ require 'hoc'
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ lib = File.expand_path('../lib', __FILE__)
25
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
26
+ require 'hoc/version'
27
+
28
+ Gem::Specification.new do |s|
29
+ s.specification_version = 2 if s.respond_to? :specification_version=
30
+ if s.respond_to? :required_rubygems_version=
31
+ s.required_rubygems_version = Gem::Requirement.new('>= 0')
32
+ end
33
+ s.rubygems_version = '2.2.2'
34
+ s.required_ruby_version = '>= 1.9.3'
35
+ s.name = 'hoc'
36
+ s.version = HOC::VERSION
37
+ s.license = 'MIT'
38
+ s.summary = 'Hits Of Code'
39
+ s.description = 'Collects information about hits-of-code'
40
+ s.authors = ['Yegor Bugayenko']
41
+ s.email = 'yegor@teamed.io'
42
+ s.homepage = 'http://github.com/teamed/hoc'
43
+ s.files = `git ls-files`.split($RS)
44
+ s.executables = s.files.grep(/^bin\//) { |f| File.basename(f) }
45
+ s.test_files = s.files.grep(/^(test|spec|features)\//)
46
+ s.rdoc_options = ['--charset=UTF-8']
47
+ s.extra_rdoc_files = %w(README.md LICENSE.txt)
48
+ s.add_runtime_dependency 'slop', '3.6'
49
+ s.add_runtime_dependency 'rake', '10.1'
50
+ s.add_development_dependency 'coveralls', '0.7'
51
+ s.add_development_dependency 'rdoc', '3.11'
52
+ s.add_development_dependency 'cucumber', '1.3.11'
53
+ s.add_development_dependency 'minitest', '5.4'
54
+ s.add_development_dependency 'rubocop', '0.24.1'
55
+ s.add_development_dependency 'rubocop-rspec', '1.1'
56
+ s.add_development_dependency 'rspec-rails', '2.13'
57
+ end
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'hoc/git'
25
+
26
+ # HOC main module.
27
+ # Author:: Yegor Bugayenko (yegor@teamed.io)
28
+ # Copyright:: Copyright (c) 2014 Yegor Bugayenko
29
+ # License:: MIT
30
+ module HOC
31
+ # Code base abstraction
32
+ class Base
33
+ # Ctor.
34
+ # +dir+:: Directory to read from
35
+ # +format+:: Format (xml, json, text)
36
+ def initialize(dir, format)
37
+ @dir = dir
38
+ @format = format
39
+ end
40
+
41
+ # Generate report.
42
+ def report
43
+ Git.new(@dir).hits.map { |h| h.total }.inject(:+)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'hoc/hits'
25
+
26
+ module HOC
27
+ # Git source code base.
28
+ class Git
29
+ def initialize(dir)
30
+ @dir = dir
31
+ end
32
+
33
+ def hits
34
+ [
35
+ Hits.new(Time.new(0), Time.new(0), 1)
36
+ ]
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ module HOC
25
+ # Set of hits.
26
+ class Hits
27
+ def initialize(first, last, total)
28
+ @first = first
29
+ @last = last
30
+ @total = total
31
+ end
32
+ attr_reader :first, :last, :total
33
+ end
34
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ # HOC main module.
25
+ # Author:: Yegor Bugayenko (yegor@teamed.io)
26
+ # Copyright:: Copyright (c) 2014 Yegor Bugayenko
27
+ # License:: MIT
28
+ module HOC
29
+ VERSION = '0.1'
30
+ end
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'minitest/autorun'
25
+ require 'hoc/git'
26
+ require 'tmpdir'
27
+
28
+ # Git test.
29
+ # Author:: Yegor Bugayenko (yegor@teamed.io)
30
+ # Copyright:: Copyright (c) 2014 Yegor Bugayenko
31
+ # License:: MIT
32
+ class TestGit < Minitest::Test
33
+ def test_parsing
34
+ Dir.mktmpdir 'test' do |dir|
35
+ system("
36
+ set -e
37
+ set -x
38
+ cd '#{dir}'
39
+ git init .
40
+ echo 'hello, world!' > test.txt
41
+ git add test.txt
42
+ git commit -m test
43
+ ")
44
+ hits = HOC::Git.new(dir).hits
45
+ assert_equal 1, hits.size
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ # it doesn't work, I don't know why :(
25
+ # require 'simplecov'
26
+ require 'hoc'
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 Teamed.io
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ require 'minitest/autorun'
25
+ require 'hoc'
26
+ require 'tmpdir'
27
+ require 'slop'
28
+
29
+ # HOC main module test.
30
+ # Author:: Yegor Bugayenko (yegor@teamed.io)
31
+ # Copyright:: Copyright (c) 2014 Yegor Bugayenko
32
+ # License:: MIT
33
+ class TestHOC < Minitest::Test
34
+ def test_basic
35
+ Dir.mktmpdir 'test' do |dir|
36
+ system("
37
+ set -e
38
+ set -x
39
+ cd '#{dir}'
40
+ git init .
41
+ echo 'hello, world!' > test.txt
42
+ git add test.txt
43
+ git commit -m test
44
+ ")
45
+ assert HOC::Base.new(dir, 'total').report > 0
46
+ end
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,224 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hoc
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yegor Bugayenko
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-11-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: slop
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.6'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: '10.1'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: '10.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: coveralls
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: '0.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: '3.11'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: '3.11'
78
+ - !ruby/object:Gem::Dependency
79
+ name: cucumber
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.3.11
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - '='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.11
94
+ - !ruby/object:Gem::Dependency
95
+ name: minitest
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - '='
100
+ - !ruby/object:Gem::Version
101
+ version: '5.4'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: '5.4'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.24.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - '='
124
+ - !ruby/object:Gem::Version
125
+ version: 0.24.1
126
+ - !ruby/object:Gem::Dependency
127
+ name: rubocop-rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - '='
132
+ - !ruby/object:Gem::Version
133
+ version: '1.1'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - '='
140
+ - !ruby/object:Gem::Version
141
+ version: '1.1'
142
+ - !ruby/object:Gem::Dependency
143
+ name: rspec-rails
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - '='
148
+ - !ruby/object:Gem::Version
149
+ version: '2.13'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - '='
156
+ - !ruby/object:Gem::Version
157
+ version: '2.13'
158
+ description: Collects information about hits-of-code
159
+ email: yegor@teamed.io
160
+ executables:
161
+ - hoc
162
+ extensions: []
163
+ extra_rdoc_files:
164
+ - README.md
165
+ - LICENSE.txt
166
+ files:
167
+ - .coveralls.yml
168
+ - .gitignore
169
+ - .rubocop.yml
170
+ - .rultor.yml
171
+ - .simplecov
172
+ - .travis.yml
173
+ - Gemfile
174
+ - LICENSE.txt
175
+ - README.md
176
+ - Rakefile
177
+ - bin/hoc
178
+ - cucumber.yml
179
+ - features/cli.feature
180
+ - features/gem_package.feature
181
+ - features/step_definitions/steps.rb
182
+ - features/support/env.rb
183
+ - hoc.gemspec
184
+ - lib/hoc.rb
185
+ - lib/hoc/git.rb
186
+ - lib/hoc/hits.rb
187
+ - lib/hoc/version.rb
188
+ - test/test_git.rb
189
+ - test/test_helper.rb
190
+ - test/test_hoc.rb
191
+ homepage: http://github.com/teamed/hoc
192
+ licenses:
193
+ - MIT
194
+ post_install_message:
195
+ rdoc_options:
196
+ - --charset=UTF-8
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ none: false
201
+ requirements:
202
+ - - ! '>='
203
+ - !ruby/object:Gem::Version
204
+ version: 1.9.3
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ none: false
207
+ requirements:
208
+ - - ! '>='
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
211
+ requirements: []
212
+ rubyforge_project:
213
+ rubygems_version: 1.8.23
214
+ signing_key:
215
+ specification_version: 2
216
+ summary: Hits Of Code
217
+ test_files:
218
+ - features/cli.feature
219
+ - features/gem_package.feature
220
+ - features/step_definitions/steps.rb
221
+ - features/support/env.rb
222
+ - test/test_git.rb
223
+ - test/test_helper.rb
224
+ - test/test_hoc.rb