worth 0.0.1

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: c4437152314700fb411684c31e5ddb0070b754f3
4
+ data.tar.gz: c4e6a8011d00ffcb34a91458eab55b69a2e6c946
5
+ SHA512:
6
+ metadata.gz: da39bba57bd0128ae941450152dbce69b47ac837dc666bd722a8acd7d510b60b0c7e9fb2beba1abc8ba3f79009a3254df85d5ee08baf89039edf15f7d2d8d00d
7
+ data.tar.gz: a2bdde264421b306982ba8afcb424800658a2a58314abcf3e0c796d38f1930a5282fea1d76a5c5ba381d91f17d666e4330c4399fd42bb4ff44879c44734a2f27
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in worth.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Worth
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'worth'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install worth
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/cap-hours ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "worth"
4
+
5
+ output = Git::Logs.authors.reduce([]) do |reports, author|
6
+
7
+ current_month = Git::Logs.current_month.(author)
8
+
9
+ if current_month.any?
10
+
11
+ reports << Commit.heading
12
+
13
+ rows = current_month.map do |commit|
14
+ Builder.(commit, author).to_csv
15
+ end
16
+
17
+ reports << rows.join("\n")
18
+
19
+ end
20
+
21
+ reports
22
+
23
+ end
24
+
25
+ puts output.join("\n\n")
26
+
27
+ puts "\nDing, fries are done."
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "worth"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/worth.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "pry"
2
+ require "time"
3
+ require "ostruct"
4
+ require "yaml"
5
+ require "worth/version"
6
+ require "worth/builder"
7
+ require "worth/commit"
8
+ require "worth/git"
9
+
10
+ module Worth
11
+ end
@@ -0,0 +1,15 @@
1
+ Builder = proc {|commit, author|
2
+
3
+ lines = commit.split(/\n/)
4
+ message = lines.first
5
+ changes = lines.last.split(/\n/)
6
+
7
+ Commit.new(
8
+ author,
9
+ message,
10
+ changes.reduce(0){|count, change|
11
+ count += change.to_f
12
+ })
13
+
14
+ }
15
+
@@ -0,0 +1,32 @@
1
+ class Commit
2
+
3
+ def self.heading
4
+ "author,message,weight"
5
+ end
6
+
7
+ attr_reader :author, :message, :changes
8
+
9
+ def initialize(author, message, changes)
10
+ @author = author
11
+ @message = message
12
+ @changes = changes
13
+ end
14
+
15
+ def to_csv
16
+ "#{author},#{message},#{weight}" if relevant?
17
+ end
18
+
19
+ private
20
+
21
+ def relevant?
22
+ changes > 0.0
23
+ end
24
+
25
+ def weight
26
+ (20 * 8 * contribution).ceil / 100.0
27
+ end
28
+
29
+ def contribution
30
+ changes / Git::TOTAL * 100.0
31
+ end
32
+ end
data/lib/worth/git.rb ADDED
@@ -0,0 +1,26 @@
1
+ class Git
2
+
3
+ require "pry"
4
+
5
+ Commands = YAML.load(%Q{
6
+
7
+ authors: git log --since="#{ARGV[0]}-01" --before="#{ARGV[1]}-01" --pretty=format:"%an"
8
+ stats:
9
+ complete: git log --since="#{ARGV[0]}-01" --before="#{ARGV[1]}-01" --stat --pretty=format:"%an"
10
+ current_month: git log --no-merges --oneline --author="%{author}" --after=30.days.ago --stat --pretty=format:"%s"
11
+
12
+ })
13
+
14
+ Logs = OpenStruct.new(
15
+ authors: `#{Commands["authors"]}`.split(/\n/).uniq,
16
+ complete: `#{Commands["stats"]["complete"]}`.split(/\n\n/),
17
+ current_month: ->(author){
18
+ `#{Commands["stats"]["current_month"].sub(/%{author}/, author)}`.split(/\n\n/)
19
+ }
20
+ )
21
+
22
+ TOTAL = Logs.complete.reduce(0) do |count, commit|
23
+ count += Builder.(commit).changes
24
+ end
25
+
26
+ end
@@ -0,0 +1,3 @@
1
+ module Worth
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe Commit do
4
+
5
+ it "thing" do
6
+ expect(true).to be(false)
7
+ end
8
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'worth'
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe Worth do
4
+
5
+
6
+ end
data/worth.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'worth/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "worth"
8
+ spec.version = Worth::VERSION
9
+ spec.authors = ["Richard Massey"]
10
+ spec.email = ["rwassey@gmail.com"]
11
+ spec.description = %q{Cap Hours, automated}
12
+ spec.summary = %q{Infer cap hours from git stats}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables << "cap-hours"
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: worth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Richard Massey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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'
41
+ description: Cap Hours, automated
42
+ email:
43
+ - rwassey@gmail.com
44
+ executables:
45
+ - cap-hours
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".travis.yml"
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/cap-hours
57
+ - bin/console
58
+ - bin/setup
59
+ - lib/worth.rb
60
+ - lib/worth/builder.rb
61
+ - lib/worth/commit.rb
62
+ - lib/worth/git.rb
63
+ - lib/worth/version.rb
64
+ - spec/commit_spec.rb
65
+ - spec/spec_helper.rb
66
+ - spec/worth_spec.rb
67
+ - worth.gemspec
68
+ homepage: ''
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.2.2
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Infer cap hours from git stats
92
+ test_files:
93
+ - spec/commit_spec.rb
94
+ - spec/spec_helper.rb
95
+ - spec/worth_spec.rb
96
+ has_rdoc: