how_is 1.0.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a6fdbded1ff0bf48eba79e033d60b63fe5b3227
4
- data.tar.gz: 3cce6191b1f525431233d27fc856f593d2e59b3f
3
+ metadata.gz: 0d03e9957e3cfefe6c95927bf11693ee2556d318
4
+ data.tar.gz: 9159d25f1cd1f7d221a21fb7d0d38a844a271fda
5
5
  SHA512:
6
- metadata.gz: 9c6e101d9dbf277c6df9f21b0c68457316bd346a2d97d93472a9f4661d44f06ae9987901368e5bb09b24f63d6e66e2ee71f5f91c5c8ff03b46d9d4696e993afd
7
- data.tar.gz: 7f66062db788773e525b566acc9b8f38cbcb9c381176f8150059368601e04a10d096867e70e80457e571d9a4b4de678c9954dd55bad81e9406e30981677e342f
6
+ metadata.gz: bad3e1bd77fa4958c81c497b3002309121efc4575c8f5b45e31d302abb7ce23a0332999bcf631e08b735a612acb32ae0eb57e4b35df4d7b332b3adf2618506a2
7
+ data.tar.gz: f6989dc7995c9aaf8215f1dd813d9173a14aa54fc9003bec21d91885e6335ac26c2a33c76ceaad4791a6243e0b3e9291cd89a5f65b3c7ecd190e72057e95926f
data/.gitignore CHANGED
@@ -9,5 +9,6 @@
9
9
  /tmp/
10
10
  report.pdf
11
11
  report.json
12
+ report.html
12
13
  *.dat
13
14
  *.png
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
2
- --color
1
+ --format documentation
2
+ --color
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
- language: ruby
2
- rvm:
3
- - 2.2
4
- - jruby
5
- - rbx-2
6
- before_install: gem install bundler -v 1.11.2
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
4
+ - jruby
5
+ - rbx-2
6
+ before_install: gem install bundler -v 1.11.2
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,49 +1,49 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at me@duckie.co. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at me@duckie.co. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
49
  [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in how_is.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in how_is.gemspec
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Ellen Marie Dash
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ellen Marie Dash
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -16,6 +16,8 @@ The summary includes:
16
16
 
17
17
  ## Installation
18
18
 
19
+ Make sure you have [gnuplot](http://gnuplot.info/) installed, then:
20
+
19
21
  $ gem install how_is
20
22
 
21
23
  ## Usage
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "how_is"
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
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "how_is"
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 CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ {"repository":"rubygems/rubygems","number_of_issues":30,"number_of_pulls":30,"issues_with_label":{"triage":7,"bug report":9,"feedback":4,"osx":1,"bug fix":4,"category - install":5,"feature implementation":2,"major bump":2,"windows":1,"feature request":1,"cleanup":1,"accepted":2,"category - #gem or #require":1,"ready for work":1,"question":3,"administrative":1},"issues_with_no_label":0,"average_issue_age":"approximately 3 months and 1 week","average_pull_age":"approximately 11 months and 3 days","oldest_issue_date":"2016-01-31T21:28:02+00:00","oldest_pull_date":"2013-09-16T15:04:07+00:00"}
data/exe/how_is CHANGED
@@ -39,10 +39,14 @@ opts = OptionParser.new do |opts|
39
39
  end
40
40
  opts.parse!
41
41
 
42
- if ARGV.length >= 1
42
+ if options[:from_file]
43
+ # Opening this file here seems a bit messy, but it works.
44
+ options[:repository] = JSON.parse(open(options[:from_file]).read)['repository']
45
+ abort "Error: Invalid JSON report file." unless options[:repository]
46
+ elsif ARGV.length >= 1
43
47
  options[:repository] = ARGV.delete_at(0)
44
48
  else
45
49
  abort "Error: No repository specified."
46
50
  end
47
51
 
48
- HowIs.generate_report(options)
52
+ HowIs.generate_report_file(options)
@@ -80,11 +80,10 @@ module HowIs
80
80
  end
81
81
 
82
82
  def average_date_for(issues_or_pulls)
83
- timestamps = issues_or_pulls.map { |iop| Time.parse(iop['created_at']).to_i }
83
+ timestamps = issues_or_pulls.map { |iop| Date.parse(iop['created_at']).strftime('%s').to_i }
84
84
  average_timestamp = timestamps.reduce(:+) / issues_or_pulls.length
85
85
 
86
- average_time = Time.at(average_timestamp)
87
- Date.parse(average_time.to_s)
86
+ Date.strptime(average_timestamp.to_s, '%s')
88
87
  end
89
88
 
90
89
  # Given an Array of issues or pulls, return the average age of them.
@@ -24,9 +24,10 @@ class HowIs::Fetcher
24
24
  end
25
25
 
26
26
 
27
- Contract String, C::RespondTo[:issues, :pulls] => Results
27
+ Contract String, C::Or[C::RespondTo[:issues, :pulls], nil] => Results
28
28
  def call(repository,
29
- github = Github.new(auto_pagination: true))
29
+ github = nil)
30
+ github ||= Github.new(auto_pagination: true)
30
31
  user, repo = repository.split('/', 2)
31
32
  issues = github.issues.list user: user, repo: repo
32
33
  pulls = github.pulls.list user: user, repo: repo
@@ -1,7 +1,78 @@
1
1
  module HowIs
2
2
  class HtmlReport < BaseReport
3
- def export!(&block)
4
- raise NotImplementedError
3
+ def title(_text)
4
+ @title = _text
5
+ @r += "<h1>#{_text}</h1>"
6
+ end
7
+
8
+ def header(_text)
9
+ @r += "<h2>#{_text}</h2>"
10
+ end
11
+
12
+ def horizontal_bar_graph(data)
13
+ biggest = data.map(&:last).max
14
+ get_percentage = ->(number_of_issues) { number_of_issues * 100 / biggest }
15
+
16
+ longest_label_length = data.map(&:first).map(&:length).max
17
+ label_width = "#{longest_label_length}ch"
18
+
19
+ @r += '<table class="horizontal-bar-graph">'
20
+ data.each do |row|
21
+ percentage = get_percentage.(row[1])
22
+ @r += <<-EOF
23
+ <tr>
24
+ <td style="width: #{label_width}">#{row[0]}</td>
25
+ <td><span class="fill" style="width: #{percentage}%">#{row[1]}</span></td>
26
+ </tr>
27
+ EOF
28
+ end
29
+ @r += "</table>"
30
+ end
31
+
32
+ def text(_text)
33
+ @r += "<p>#{_text}</p>"
34
+ end
35
+
36
+ def export(&block)
37
+ @r = ''
38
+ instance_exec(&block)
39
+ end
40
+
41
+ def export!(file, &block)
42
+ report = export(&block)
43
+
44
+ File.open(file, 'w') do |f|
45
+ f.puts <<-EOF
46
+ <!DOCTYPE html>
47
+ <html>
48
+ <head>
49
+ <title>#{@title}</title>
50
+ <style>
51
+ body { font: sans-serif; }
52
+ main {
53
+ max-width: 600px;
54
+ max-width: 72ch;
55
+ margin: auto;
56
+ }
57
+
58
+ .horizontal-bar-graph {
59
+ position: relative;
60
+ width: 100%;
61
+ }
62
+ .horizontal-bar-graph .fill {
63
+ display: inline-block;
64
+ background: #CCC;
65
+ }
66
+ </style>
67
+ </head>
68
+ <body>
69
+ <main>
70
+ #{report}
71
+ </main>
72
+ </body>
73
+ </html>
74
+ EOF
75
+ end
5
76
  end
6
77
  end
7
78
  end
@@ -1,3 +1,6 @@
1
+ require 'prawn'
2
+ require 'how_is/chart'
3
+
1
4
  module HowIs
2
5
  class PdfReport < BaseReport
3
6
  attr_accessor :pdf
data/lib/how_is/report.rb CHANGED
@@ -33,6 +33,7 @@ module HowIs
33
33
  class Report
34
34
  require 'how_is/report/pdf'
35
35
  require 'how_is/report/json'
36
+ require 'how_is/report/html'
36
37
 
37
38
  REPORT_BLOCK = proc do
38
39
  title "How is #{analysis.repository}?"
@@ -49,10 +50,6 @@ module HowIs
49
50
  horizontal_bar_graph issues_per_label
50
51
  end
51
52
 
52
- def self.export(analysis, format = :pdf)
53
-
54
- end
55
-
56
53
  def self.export!(analysis, file)
57
54
  format = file.split('.').last
58
55
  report = get_report_class(format).new(analysis)
@@ -64,8 +61,6 @@ module HowIs
64
61
  report = get_report_class(format).new(analysis)
65
62
 
66
63
  report.export(&REPORT_BLOCK)
67
-
68
- report
69
64
  end
70
65
 
71
66
  private
@@ -1,3 +1,3 @@
1
1
  module HowIs
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
data/lib/how_is.rb CHANGED
@@ -8,25 +8,39 @@ module HowIs
8
8
 
9
9
  require 'how_is/fetcher'
10
10
  require 'how_is/analyzer'
11
- require 'how_is/reporter'
12
-
13
- Contract C::KeywordArgs[repository: String, report_file: String,
14
- from_file: C::Optional[C::Or[String, nil]],
15
- fetcher: C::Optional[Class],
16
- analyzer: C::Optional[Class],
17
- reporter: C::Optional[Class]] => C::Any
18
- def self.generate_report(repository:, report_file:,
11
+ require 'how_is/report'
12
+
13
+ def self.generate_report_file(report_file:, **kw_args)
14
+ analysis = self.generate_analysis(**kw_args)
15
+
16
+ Report.export!(analysis, report_file)
17
+ end
18
+
19
+ def self.generate_report(format:, **kw_args)
20
+ analysis = self.generate_analysis(**kw_args)
21
+
22
+ Report.export(analysis, format)
23
+ end
24
+ private
25
+
26
+
27
+ Contract C::KeywordArgs[repository: String,
28
+ from_file: C::Optional[C::Or[String, nil]],
29
+ fetcher: C::Optional[Class],
30
+ analyzer: C::Optional[Class],
31
+ github: C::Optional[C::Any]] => C::Any
32
+ def self.generate_analysis(repository:,
19
33
  from_file: nil,
20
- fetcher: Fetcher.new,
34
+ fetcher: Fetcher.new,
21
35
  analyzer: Analyzer.new,
22
- reporter: Reporter.new)
36
+ github: nil)
23
37
  if from_file
24
38
  analysis = analyzer.from_file(from_file)
25
39
  else
26
- raw_data = fetcher.call(repository)
40
+ raw_data = fetcher.call(repository, github)
27
41
  analysis = analyzer.call(raw_data)
28
42
  end
29
43
 
30
- reporter.call(analysis, report_file)
44
+ analysis
31
45
  end
32
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: how_is
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ellen Marie Dash
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github_api
@@ -140,6 +140,7 @@ files:
140
140
  - Rakefile
141
141
  - bin/console
142
142
  - bin/setup
143
+ - data/how_is_spec/generate_report--generates-a-correct-JSON-report.json
143
144
  - data/issues.plg
144
145
  - exe/how_is
145
146
  - how_is.gemspec
@@ -151,7 +152,6 @@ files:
151
152
  - lib/how_is/report/html.rb
152
153
  - lib/how_is/report/json.rb
153
154
  - lib/how_is/report/pdf.rb
154
- - lib/how_is/reporter.rb
155
155
  - lib/how_is/version.rb
156
156
  - roadmap.markdown
157
157
  homepage: https://github.com/duckinator/how_is
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
- rubygems_version: 2.6.3
177
+ rubygems_version: 2.5.1
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: Quantify the health of a GitHub repository is.
@@ -1,19 +0,0 @@
1
- require 'contracts'
2
- require 'prawn'
3
- require 'how_is/chart'
4
-
5
- module HowIs
6
- class Reporter
7
- require 'how_is/report'
8
- include Contracts::Core
9
-
10
- ##
11
- # Given an Analysis, generate a Report
12
- #
13
- # Returns a class that inherits from Report.
14
- Contract Analysis, String => C::Any
15
- def call(analysis, report_file)
16
- Report.export!(analysis, report_file)
17
- end
18
- end
19
- end