pain 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c4206b23bae5c9b227f43d0418a8bbfabe7d8d3
4
+ data.tar.gz: 8c6753d6ba640cacbd626c6833624f1d8f4774b7
5
+ SHA512:
6
+ metadata.gz: 248b2f22e0ec30f3c514a322fd83e9a6ec22bee38f11577db7e8ff603e4cab3b03a3ceb6e6551f3c19cd47b48bddbec2eb605eb70cac3abddb1e8887b9abf6b9
7
+ data.tar.gz: d4f5f6f7696d4a16dade07df3769684a4972eaf2189bbffeeb7b3400b0f7bce8a305044e045c2ae615107743cd6a7cdd32627bdb9731c53a1785c4fed500f705
@@ -0,0 +1,22 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,7 @@
1
+ AllCops:
2
+ Exclude:
3
+ - spec/**
4
+ - pain.gemspec
5
+
6
+ Documentation:
7
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in user_pain.gemspec
4
+ gemspec
5
+
6
+ gem 'rubocop'
7
+ gem 'coveralls', require: false
8
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Andy Nicholson
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.
@@ -0,0 +1,25 @@
1
+ # Pain
2
+
3
+ Quickly gauge the User Pain a bug will cause.
4
+ Basically stolen from http://www.lostgarden.com/2008/05/improving-bug-triage-with-user-pain.html
5
+
6
+ ## Installation
7
+
8
+ Install it yourself as:
9
+
10
+ $ gem install pain
11
+
12
+ ## Usage
13
+
14
+ Usage: pain [options]
15
+ -l, --likelihood [LIKELIHOOD] How likely is this bug to occur?
16
+ -i, --impact [IMPACT] How much impact will this bug have?
17
+ -t, --type [TYPE] What kind of bug is this?
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it ( https://github.com/anicholson/pain/fork )
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'term/ansicolor'
5
+ require 'pain'
6
+
7
+ include Pain
8
+
9
+ class String
10
+ include Term::ANSIColor
11
+ end
12
+
13
+ def get_color(value)
14
+ offset = case value
15
+ when :trivial
16
+ 40
17
+ when :minor
18
+ 69
19
+ when :standard
20
+ 184
21
+ when :major
22
+ 202
23
+ when :critical
24
+ 9
25
+ else
26
+ 252
27
+ end
28
+ Term::ANSIColor::Attribute[offset]
29
+ end
30
+
31
+ def case_danger(danger)
32
+ if danger < 0.21
33
+ :trivial
34
+ elsif danger < 0.41
35
+ :minor
36
+ elsif danger < 0.65
37
+ :standard
38
+ elsif danger < 0.81
39
+ :major
40
+ else
41
+ :critical
42
+ end
43
+ end
44
+
45
+ def total_danger(danger)
46
+ if danger < 21
47
+ :trivial
48
+ elsif danger < 31
49
+ :minor
50
+ elsif danger < 51
51
+ :standard
52
+ elsif danger < 75
53
+ :major
54
+ else
55
+ :critical
56
+ end
57
+ end
58
+
59
+ def color_output(msg, danger = :normal)
60
+ level = if danger == :normal
61
+ :default
62
+ elsif danger.is_a? Symbol
63
+ danger
64
+ else
65
+ case_danger(danger)
66
+ end
67
+ puts msg.color(get_color(level))
68
+ end
69
+
70
+ def display_options_for(input)
71
+ ceiling = Pain::OPTIONS[input].count
72
+ Pain::OPTIONS[input].each do |v, msg|
73
+ color_output("#{v}: #{msg}", (v/ceiling.to_f))
74
+ end
75
+ puts
76
+ end
77
+
78
+ def ask_question_for(input)
79
+ color_output Pain::INPUT_MESSAGE[input]
80
+ end
81
+
82
+ def print_report_for(o)
83
+ pain = Pain.user_pain(o[:bug_type], o[:likelihood], o[:impact])
84
+
85
+ levels = o.reduce({}) do |hash, (input, level)|
86
+ hash[input] = case_danger(level.to_f / Pain::MAX[input])
87
+ hash
88
+ end
89
+
90
+ color_output "Type: #{o[:bug_type]} - #{Pain::OPTIONS[:bug_type][o[:bug_type]]}", levels[:bug_type]
91
+ color_output "Likelihood: #{o[:likelihood]} - #{Pain::OPTIONS[:likelihood][o[:likelihood]]}", levels[:likelihood]
92
+ color_output "Impact: #{o[:impact]} - #{Pain::OPTIONS[:impact][o[:impact]]}", levels[:impact]
93
+ puts
94
+ color_output "User Pain: #{pain}", total_danger(pain)
95
+ end
96
+
97
+
98
+ options = {}
99
+
100
+ OptionParser.new do |opts|
101
+ opts.on('-l', '--likelihood [LIKELIHOOD]', OptionParser::DecimalInteger,
102
+ 'How likely is this bug to occur?') do |like|
103
+ options[:likelihood] = Pain::normalize(like, :likelihood)
104
+ end
105
+
106
+ opts.on('-i', '--impact [IMPACT]', OptionParser::DecimalInteger,
107
+ 'How much impact will this bug have?') do |impact|
108
+ options[:impact] = Pain.normalize(impact, :impact)
109
+ end
110
+
111
+ opts.on('-t', '--type [TYPE]', OptionParser::DecimalInteger,
112
+ 'What kind of bug is this?') do |bug_type|
113
+ options[:bug_type] = Pain.normalize(bug_type, :bug_type)
114
+ end
115
+ end.parse!
116
+
117
+ [:bug_type, :likelihood, :impact].each do |input|
118
+ first = true
119
+ until options[input]
120
+ ask_question_for input
121
+ display_options_for(input) if first
122
+
123
+ response = gets.chomp
124
+ options[input] = Pain::normalize(response, input)
125
+ first = false
126
+ end
127
+ end
128
+
129
+ print_report_for options
@@ -0,0 +1,62 @@
1
+ require 'pain/version'
2
+ require 'optparse'
3
+ require 'ostruct'
4
+
5
+ module Pain
6
+ MAX = {
7
+ bug_type: 7,
8
+ likelihood: 5,
9
+ impact: 5
10
+ }
11
+
12
+ INPUT_MESSAGE = {
13
+ bug_type: 'What kind of bug is this?',
14
+ likelihood: 'How likely is this bug to occur?',
15
+ impact: 'How much impact will this bug have?'
16
+ }
17
+
18
+ OPTIONS = {
19
+ bug_type: {
20
+ 1 => 'Documentation: a documentation issue',
21
+ 2 => 'Localization: missing translations',
22
+ 3 => 'Visual Polish: Aesthetic issues',
23
+ 4 => 'Balancing: allows poor usage strategy',
24
+ 5 => 'Minor UX: Impairs UX in secondary scenarios',
25
+ 6 => 'Major UX: Impairs UX in key scenarios',
26
+ 7 => 'Crash: Causes crash or data loss'
27
+ },
28
+ likelihood: {
29
+ 1 => 'Will affect almost no one',
30
+ 2 => 'Will only affect a few users',
31
+ 3 => 'Will affect average number of users',
32
+ 4 => 'Will affect most users',
33
+ 5 => 'Will affect all users'
34
+ },
35
+
36
+ impact: {
37
+ 1 => 'Nuisance: not a big deal bug noticeable.',
38
+ 2 => 'A Pain: Users won\'t like this once they notice it.',
39
+ 3 => 'Affects Buy-in. Will show up in review. Clearly noticeable.',
40
+ 4 => 'A user would return the product. Should not deploy until fixed',
41
+ 5 => 'Affects system build'
42
+ }
43
+ }
44
+
45
+ def max_pain
46
+ MAX.values.reduce(&:*)
47
+ end
48
+
49
+ def user_pain(type, likelihood, impact)
50
+ 100 * (type * likelihood * impact) / max_pain
51
+ end
52
+
53
+ def normalize(value, variable)
54
+ value = value.to_i
55
+ max = MAX[variable]
56
+
57
+ return nil if max.nil? || value.nil?
58
+ return nil if value < 1
59
+ return max if value > max
60
+ value
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ module Pain
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pain/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'pain'
8
+ spec.version = Pain::VERSION
9
+ spec.authors = ['Andy Nicholson']
10
+ spec.email = ['andrew@anicholson.net']
11
+ spec.summary = %q{Quickly calculate User Pain for a bug}
12
+ spec.description = %q{Based on http://www.lostgarden.com/2008/05/improving-bug-triage-with-user-pain.html }
13
+ spec.homepage = 'http://github.com/anicholson/pain.git'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'term-ansicolor'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'simplecov'
27
+ spec.add_development_dependency 'simplecov-rcov'
28
+ spec.add_development_dependency 'pry'
29
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'normalize' do
4
+ subject { Class.new { include Pain }.new }
5
+
6
+ it 'doesn\'t allow numbers too small' do
7
+ expect(subject.normalize(0, :impact)).to be_nil
8
+ expect(subject.normalize(-1, :impact)).to be_nil
9
+ end
10
+
11
+ it 'doesn\'t allow numbers too big' do
12
+ expect(subject.normalize(10, :bug_type)).to eq(7)
13
+ expect(subject.normalize(7, :impact)).to eq(5)
14
+ expect(subject.normalize(7, :bug_type)).to eq(7)
15
+ end
16
+ end
@@ -0,0 +1,38 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ require 'bundler/setup'
9
+
10
+ require 'simplecov'
11
+ require 'simplecov-rcov'
12
+ require 'pry'
13
+ require 'coveralls'
14
+
15
+ Coveralls.wear!
16
+
17
+ class SimpleCov::Formatter::MergedFormatter
18
+ def format(result)
19
+ SimpleCov::Formatter::HTMLFormatter.new.format(result)
20
+ SimpleCov::Formatter::RcovFormatter.new.format(result)
21
+ end
22
+ end
23
+
24
+ SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
25
+
26
+ require 'pain'
27
+
28
+ RSpec.configure do |config|
29
+ config.treat_symbols_as_metadata_keys_with_true_values = true
30
+ config.run_all_when_everything_filtered = true
31
+ config.filter_run :focus
32
+
33
+ # Run specs in random order to surface order dependencies. If you find an
34
+ # order dependency and want to debug it, you can fix the order by providing
35
+ # the seed, which is printed after each run.
36
+ # --seed 1234
37
+ config.order = 'random'
38
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe 'pain' do
5
+ subject { Class.new { include Pain }.new }
6
+
7
+ it 'calculates_correctly' do
8
+ expect(subject.user_pain(7, 5, 5)).to eq(100)
9
+ expect(subject.user_pain(1, 1, 1)).to eq(0)
10
+ expect(subject.user_pain(4, 3, 3)).to eq(20)
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pain
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andy Nicholson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: term-ansicolor
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov-rcov
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: pry
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: 'Based on http://www.lostgarden.com/2008/05/improving-bug-triage-with-user-pain.html '
112
+ email:
113
+ - andrew@anicholson.net
114
+ executables:
115
+ - pain
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - .gitignore
120
+ - .rspec
121
+ - .rubocop.yml
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/pain
127
+ - lib/pain.rb
128
+ - lib/pain/version.rb
129
+ - pain.gemspec
130
+ - spec/normalize_spec.rb
131
+ - spec/spec_helper.rb
132
+ - spec/user_pain_spec.rb
133
+ homepage: http://github.com/anicholson/pain.git
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.1.11
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Quickly calculate User Pain for a bug
157
+ test_files:
158
+ - spec/normalize_spec.rb
159
+ - spec/spec_helper.rb
160
+ - spec/user_pain_spec.rb
161
+ has_rdoc: