werd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/werd +15 -0
- data/lib/werd.rb +8 -0
- data/lib/werd/commands/report.rb +13 -0
- data/lib/werd/project_word_counter.rb +41 -0
- data/lib/werd/reports/basic.rb +20 -0
- data/lib/werd/version.rb +3 -0
- data/spec/lib/werd/project_word_counter_spec.rb +46 -0
- data/spec/lib/werd/reports/basic_spec.rb +15 -0
- data/spec/spec_helper.rb +18 -0
- data/werd.gemspec +30 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: da297d8fac5d594a00a7d4b16e3975348af0f3f1
|
4
|
+
data.tar.gz: c6b329af37350e5dff78581ea69f0da5b59871de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e67e9642081d6963ec1c8e2bad96eae748e25a7416ec4d2dcf954188eee7e8200983fb56381a2a92ceb38d3baedda92aba48404afba1a40f1e0dba27a79331f
|
7
|
+
data.tar.gz: cf8bcbbc23157ade954b70684650dd0716271df972ba56bf4c8918514900fcc93afeabc64f7610b8df11fc258bc7ac6f3df7832d8e1d11ff839b20b944c10b73
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p598
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Can Berk Guder
|
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,31 @@
|
|
1
|
+
# Werd
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'werd'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install werd
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/werd/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/werd
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'escort'
|
4
|
+
require 'werd'
|
5
|
+
|
6
|
+
Escort::App.create do |app|
|
7
|
+
app.options do |opts|
|
8
|
+
opts.opt :token, 'Your Pivotal Tracker API token', short: '-t', long: '--token', type: :string
|
9
|
+
opts.opt :project, 'The ID of the project you want a report on', short: '-p', long: '--project', type: :string
|
10
|
+
end
|
11
|
+
|
12
|
+
app.action do |options, arguments|
|
13
|
+
Werd::Commands::Report.new(options, arguments).execute
|
14
|
+
end
|
15
|
+
end
|
data/lib/werd.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Werd
|
2
|
+
module Commands
|
3
|
+
class Report < ::Escort::ActionCommand::Base
|
4
|
+
def execute
|
5
|
+
token = command_options[:token]
|
6
|
+
project_id = command_options[:project]
|
7
|
+
|
8
|
+
words = Werd::ProjectWordCounter.new(token, project_id).words
|
9
|
+
puts Werd::Reports::Basic.new(words).to_s
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Werd
|
2
|
+
class ProjectWordCounter
|
3
|
+
include Contracts
|
4
|
+
attr_reader :project_id, :token
|
5
|
+
|
6
|
+
Contract String, String => Any
|
7
|
+
def initialize token, project_id
|
8
|
+
@token, @project_id = token, project_id
|
9
|
+
end
|
10
|
+
|
11
|
+
Contract String => ArrayOf[[String, Num]]
|
12
|
+
def words
|
13
|
+
counts = Hash.new 0
|
14
|
+
document.split(/\W/).select do |str|
|
15
|
+
str.size > 0
|
16
|
+
end.map do |chunk|
|
17
|
+
chunk.downcase
|
18
|
+
end.each do |word|
|
19
|
+
counts[word] += 1
|
20
|
+
end
|
21
|
+
counts.to_a.sort_by(&:last).reverse
|
22
|
+
end
|
23
|
+
|
24
|
+
Contract None => RespondTo[:project]
|
25
|
+
def client
|
26
|
+
@client ||= TrackerApi::Client.new(token: token)
|
27
|
+
end
|
28
|
+
|
29
|
+
Contract None => Any
|
30
|
+
def project
|
31
|
+
client.project project_id
|
32
|
+
end
|
33
|
+
|
34
|
+
Contract None => String
|
35
|
+
def document
|
36
|
+
project.stories.map do |s|
|
37
|
+
[s.name, s.description]
|
38
|
+
end.flatten.join("\n")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Werd
|
2
|
+
module Reports
|
3
|
+
class Basic
|
4
|
+
include Contracts
|
5
|
+
attr_reader :words
|
6
|
+
|
7
|
+
Contract ArrayOf[[String, Num]] => Any
|
8
|
+
def initialize words
|
9
|
+
@words = words.first(30)
|
10
|
+
end
|
11
|
+
|
12
|
+
Contract None => String
|
13
|
+
def to_s
|
14
|
+
words.map do |row|
|
15
|
+
"%4i %s" % [row.last, row.first]
|
16
|
+
end.join("\n")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/werd/version.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Werd::ProjectWordCounter do
|
4
|
+
let(:name) { 'Story, story!' }
|
5
|
+
let(:description) { 'Some words! Some: word' }
|
6
|
+
let(:stories) { [instance_double(TrackerApi::Resources::Story,
|
7
|
+
name: name,
|
8
|
+
description: description,
|
9
|
+
)] }
|
10
|
+
let(:project) { instance_double(TrackerApi::Resources::Project, stories: stories) }
|
11
|
+
let(:client) { instance_double(TrackerApi::Client, project: project) }
|
12
|
+
let(:word_counter) { Werd::ProjectWordCounter.new('token', 'project-id') }
|
13
|
+
|
14
|
+
before do
|
15
|
+
allow(word_counter).
|
16
|
+
to receive(:client).
|
17
|
+
and_return(verify_contracted_instance_method(Werd::ProjectWordCounter, :client, client))
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:document_expectation) { [name, description].join("\n") }
|
21
|
+
describe '#document' do
|
22
|
+
subject { word_counter.document }
|
23
|
+
it { is_expected.to eq document_expectation }
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:words_expectation) { [
|
27
|
+
['story' , 2],
|
28
|
+
['some' , 2],
|
29
|
+
['words' , 1],
|
30
|
+
['word' , 1],
|
31
|
+
] }
|
32
|
+
describe '#words' do
|
33
|
+
before do
|
34
|
+
allow(word_counter).
|
35
|
+
to receive(:document).
|
36
|
+
and_return(verify_contracted_instance_method(Werd::ProjectWordCounter, :document, document_expectation))
|
37
|
+
end
|
38
|
+
subject { word_counter.words }
|
39
|
+
it { is_expected.to eq words_expectation }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#project' do
|
43
|
+
subject { word_counter.project }
|
44
|
+
it { is_expected.to eq project }
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Werd::Reports::Basic do
|
4
|
+
let(:words) { verify_contracted_instance_method(Werd::ProjectWordCounter, :words, [
|
5
|
+
['words', 1236],
|
6
|
+
['some', 5],
|
7
|
+
]) }
|
8
|
+
|
9
|
+
let(:report) { Werd::Reports::Basic.new(words) }
|
10
|
+
|
11
|
+
describe "#to_s" do
|
12
|
+
subject { report.to_s }
|
13
|
+
it { is_expected.to eq "1236 words\n 5 some" }
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'werd'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
|
5
|
+
def verify_contracted_instance_method(klass, method, ret)
|
6
|
+
klass.decorated_methods[:instance_methods][method.to_sym].each do |contract|
|
7
|
+
validator = Contract.make_validator(contract.ret_contract)
|
8
|
+
if validator.call(ret)
|
9
|
+
return ret
|
10
|
+
else
|
11
|
+
raise <<-END
|
12
|
+
#{klass}##{method} contract violated.
|
13
|
+
#{contract}
|
14
|
+
Cannot return #{ret}
|
15
|
+
END
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/werd.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'werd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "werd"
|
8
|
+
spec.version = Werd::VERSION
|
9
|
+
spec.authors = ["Ehren Murdick"]
|
10
|
+
spec.email = ["emurdick@pivotal.io"]
|
11
|
+
spec.summary = %q{Find the most common words on your tracker project}
|
12
|
+
spec.description = %q{Pulls story descriptions and names from tracker}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.add_runtime_dependency 'escort'
|
17
|
+
spec.add_runtime_dependency 'tracker_api'
|
18
|
+
spec.add_runtime_dependency 'contracts'
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency 'pry'
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0")
|
26
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
27
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: werd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ehren Murdick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: escort
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tracker_api
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: contracts
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Pulls story descriptions and names from tracker
|
112
|
+
email:
|
113
|
+
- emurdick@pivotal.io
|
114
|
+
executables:
|
115
|
+
- werd
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .gitignore
|
120
|
+
- .ruby-version
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/werd
|
127
|
+
- lib/werd.rb
|
128
|
+
- lib/werd/commands/report.rb
|
129
|
+
- lib/werd/project_word_counter.rb
|
130
|
+
- lib/werd/reports/basic.rb
|
131
|
+
- lib/werd/version.rb
|
132
|
+
- spec/lib/werd/project_word_counter_spec.rb
|
133
|
+
- spec/lib/werd/reports/basic_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
- werd.gemspec
|
136
|
+
homepage: ''
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.0.14
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: Find the most common words on your tracker project
|
160
|
+
test_files:
|
161
|
+
- spec/lib/werd/project_word_counter_spec.rb
|
162
|
+
- spec/lib/werd/reports/basic_spec.rb
|
163
|
+
- spec/spec_helper.rb
|