how_is 17.0.0 → 18.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/README.md +20 -1
- data/design/01-functionality.md +4 -62
- data/exe/how_is +32 -7
- data/how_is.gemspec +2 -4
- data/lib/how_is/analyzer.rb +10 -5
- data/lib/how_is/cli.rb +32 -10
- data/lib/how_is/pulse.rb +8 -2
- data/lib/how_is/report/base_report.rb +23 -1
- data/lib/how_is/report/json.rb +13 -0
- data/lib/how_is/version.rb +1 -1
- data/lib/how_is.rb +54 -19
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c44d90a04abb7343c89a5ff858d63d23c98c0ce
|
4
|
+
data.tar.gz: e2c1842533e09ec46d26d5cc6d5e24c72c2c65f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77dea4e880e70869bc7b9ad6a3ce2cd2d33cd20a07cfd5ebbf45e01937275fe828b7e448bfcbf0c93486720202c44244065da82b5251b0423358efcdd174905d
|
7
|
+
data.tar.gz: 41c3d52d430ec1de181d01461db6b084e14ccbf3d50e147e72306f85214b367bb718d059199edb2ee9cc09f412c93e5b1c30b5e66b45a2bf53b6aa5481abc0e7
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,41 @@ this project adheres to [Semantic Versioning](http://semver.org).
|
|
9
9
|
|
10
10
|
(Nothing so far.)
|
11
11
|
|
12
|
+
## [v18.0.0]
|
13
|
+
|
14
|
+
This release ([snapshot](https://github.com/how-is/how_is/tree/v18.0.0))
|
15
|
+
vastly improves documentation, fixes the `--from` flag, and adds the
|
16
|
+
`HowIs.from_hash` method (used by the
|
17
|
+
[dashboard](https://github.com/how-is/dashboard)).
|
18
|
+
|
19
|
+
Pull Requests for this release can be [viewed on
|
20
|
+
GitHub](https://github.com/how-is/how_is/pulls?utf8=&q=is%3Apr%20created%3A2017-02-10..2017-03-03).
|
21
|
+
|
22
|
+
### Additions
|
23
|
+
|
24
|
+
* Add/improve inline code documentation.
|
25
|
+
([#132](https://github.com/how-is/how_is/pull/132))
|
26
|
+
* Move documentation from design/ to README.
|
27
|
+
([#143](https://github.com/how-is/how_is/pull/143))
|
28
|
+
* Add `HowIs.from_hash` method.
|
29
|
+
([#144](https://github.com/how-is/how_is/pull/144))
|
30
|
+
|
31
|
+
### Changes
|
32
|
+
|
33
|
+
* Unpin Rack version. ([#139](https://github.com/how-is/how_is/pull/139))
|
34
|
+
* Fix --from. ([#141](https://github.com/how-is/how_is/pull/141))
|
35
|
+
|
36
|
+
### Miscellaneous
|
37
|
+
|
38
|
+
Things that don't affect users of how\_is.
|
39
|
+
|
40
|
+
* Fix grammar in gemspec.
|
41
|
+
([#129](https://github.com/how-is/how_is/pull/129))
|
42
|
+
* Fix URL in gemspec. ([#130](https://github.com/how-is/how_is/pull/130))
|
43
|
+
* Remove shebang line from lib/ file.
|
44
|
+
([#131](https://github.com/how-is/how_is/pull/131))
|
45
|
+
|
46
|
+
|
12
47
|
## [v17.0.0]
|
13
48
|
|
14
49
|
This release ([snapshot](https://github.com/how-is/how_is/tree/v17.0.0))
|
data/README.md
CHANGED
@@ -34,9 +34,28 @@ E.g.,
|
|
34
34
|
|
35
35
|
The above command creates a HTML file containing the summary at `./report.html`.
|
36
36
|
|
37
|
+
If you don't pass the `--report` flag, it defaults to
|
38
|
+
`./report.html`.
|
39
|
+
|
40
|
+
#### Generating reports, using a JSON report as a cache
|
41
|
+
|
42
|
+
You can use a JSON report as a cache when generating another rpeort.
|
43
|
+
|
44
|
+
E.g.,
|
45
|
+
|
46
|
+
$ how_is rubygems/rubygems --report report.json
|
47
|
+
$ how_is --from report.json --report report.html
|
48
|
+
|
49
|
+
The first command generates a JSON report at `./report.json`. The second
|
50
|
+
command generates an HTML report at `./report.html`, using information
|
51
|
+
from `./report.json`.
|
52
|
+
|
53
|
+
When using `--from`, no network requests are made, because all of the
|
54
|
+
required information is in the JSON report.
|
55
|
+
|
37
56
|
#### Generating reports from a config file
|
38
57
|
|
39
|
-
|
58
|
+
You can also create a config file — typically called
|
40
59
|
how_is.yml — and run `how_is --config YAML_CONFIG_FILE`. (E.g., if
|
41
60
|
the config file is how_is.yml, you would run `how_is --config how_is.yml`.)
|
42
61
|
|
data/design/01-functionality.md
CHANGED
@@ -91,65 +91,7 @@ Items with two asterisks (\*\*) have been partially implemented.
|
|
91
91
|
|
92
92
|
## UI Specification
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
`how_is --version` prints the version and exits.
|
99
|
-
|
100
|
-
### Generating a report
|
101
|
-
|
102
|
-
How\_is can generate HTML reports for https://github.com/rubygems/rubygems.
|
103
|
-
By default, it generates reports at `./report.html`.
|
104
|
-
To view an HTML report, open it in aweb browser.
|
105
|
-
|
106
|
-
There is no output when it succeeds.
|
107
|
-
|
108
|
-
```
|
109
|
-
$ how_is rubygems/rubygems
|
110
|
-
$
|
111
|
-
```
|
112
|
-
|
113
|
-
### Generate a report, specifying the filename
|
114
|
-
|
115
|
-
You can generate reports with other filenames, as well as different
|
116
|
-
report formats, using the `--report FILENAME` parameter.
|
117
|
-
|
118
|
-
The FILENAME can be any filename that ends with a lowercase
|
119
|
-
extension specifying a supported format (currently `.html` and `.json`).
|
120
|
-
|
121
|
-
If the filename ends with `.html` it'll generate an HTML report,
|
122
|
-
if it ends with `.json` it'll generate a JSON report.
|
123
|
-
|
124
|
-
There is no output when it succeeds.
|
125
|
-
|
126
|
-
```
|
127
|
-
$ how_is --report report.json rubygems/rubygems
|
128
|
-
$
|
129
|
-
```
|
130
|
-
|
131
|
-
### Generate a report, using data from a JSON report
|
132
|
-
|
133
|
-
If you have a JSON report (see above), you can use that to generate
|
134
|
-
another report (probably HTML) using that data.
|
135
|
-
|
136
|
-
E.g.,
|
137
|
-
|
138
|
-
```
|
139
|
-
$ how_is --from report.json --report report.html
|
140
|
-
$
|
141
|
-
```
|
142
|
-
|
143
|
-
This generates an HTML report just like `how_is --report report.html
|
144
|
-
REPOSITORY`, except it uses the data from `report.json` instead of
|
145
|
-
fetching it again.
|
146
|
-
|
147
|
-
tl;dr: you're using the JSON file as a cache.
|
148
|
-
|
149
|
-
### Generating a report using a config file
|
150
|
-
|
151
|
-
See [the README](https://github.com/how-is/how_is/blob/master/README.md#generating-reports-from-a-config-file).
|
152
|
-
|
153
|
-
### Ruby API
|
154
|
-
|
155
|
-
See [the README](https://github.com/how-is/how_is/blob/master/README.md#ruby-api).
|
94
|
+
how_is follows [Readme Driven
|
95
|
+
Development](http://tom.preston-werner.com/2010/08/23/readme-driven-development.html) and, as such,
|
96
|
+
[README.md](https://github.com/how-is/how_is/blob/master/README.md) is
|
97
|
+
both the documentation and the specification.
|
data/exe/how_is
CHANGED
@@ -18,16 +18,41 @@ opts = result[:opts]
|
|
18
18
|
options = result[:options]
|
19
19
|
arguments = result[:arguments]
|
20
20
|
|
21
|
+
if options[:help]
|
22
|
+
puts result[:opts]
|
23
|
+
exit
|
24
|
+
elsif options[:version]
|
25
|
+
puts HowIs::VERSION
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
def save_files(reports)
|
30
|
+
reports.each do |file, report|
|
31
|
+
format = file.split('.').last
|
32
|
+
|
33
|
+
File.open(file, 'w') do |f|
|
34
|
+
f.write report.send("to_#{format}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
21
39
|
begin
|
22
|
-
if options[:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
elsif options[:config]
|
27
|
-
HowIs.from_config_file(YAML.load_file(options[:config]))
|
40
|
+
if options[:config]
|
41
|
+
reports = HowIs.from_config_file(YAML.load_file(options[:config]))
|
42
|
+
|
43
|
+
save_files(reports)
|
28
44
|
else
|
29
|
-
|
45
|
+
report =
|
46
|
+
if options[:from]
|
47
|
+
json_report = File.open(options[:from]).read
|
48
|
+
HowIs.from_json(json_report)
|
49
|
+
else
|
50
|
+
HowIs.new(options[:repository])
|
51
|
+
end
|
52
|
+
|
53
|
+
save_files({ options[:report] => report })
|
30
54
|
end
|
55
|
+
|
31
56
|
rescue => e
|
32
57
|
if ENV['SHOW_TRACE']
|
33
58
|
raise
|
data/how_is.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Ellen Marie Dash"]
|
10
10
|
spec.email = ["me@duckie.co"]
|
11
11
|
|
12
|
-
spec.summary = %q{Quantify the health of a GitHub repository
|
13
|
-
spec.homepage = "https://github.com/
|
12
|
+
spec.summary = %q{Quantify the health of a GitHub repository.}
|
13
|
+
spec.homepage = "https://github.com/how-is/how_is"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -22,8 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency "contracts", "~> 0.14.0"
|
23
23
|
spec.add_runtime_dependency "slop", "~> 4.4.1"
|
24
24
|
|
25
|
-
spec.add_runtime_dependency "rack", "~> 2.0"
|
26
|
-
|
27
25
|
spec.add_runtime_dependency "tessellator-fetcher", "~> 5.0.0"
|
28
26
|
|
29
27
|
spec.add_development_dependency "bundler", "~> 1.11"
|
data/lib/how_is/analyzer.rb
CHANGED
@@ -21,7 +21,11 @@ class HowIs
|
|
21
21
|
end
|
22
22
|
|
23
23
|
##
|
24
|
-
# Generates and returns an analysis.
|
24
|
+
# Generates and returns an analysis.i
|
25
|
+
#
|
26
|
+
# @param data [Fetcher::Results] The results gathered by Fetcher.
|
27
|
+
# @param analysis_class (You don't need this.) A class to use instead of
|
28
|
+
# HowIs::Analysis.
|
25
29
|
Contract Fetcher::Results, C::KeywordArgs[analysis_class: C::Optional[Class]] => Analysis
|
26
30
|
def call(data, analysis_class: Analysis)
|
27
31
|
issues = data.issues
|
@@ -53,10 +57,11 @@ class HowIs
|
|
53
57
|
end
|
54
58
|
|
55
59
|
##
|
56
|
-
# Generates an analysis from a
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
+
# Generates an analysis from a hash of report data.
|
61
|
+
#
|
62
|
+
# @param data [Hash] The hash to generate an Analysis from.
|
63
|
+
def self.from_hash(data)
|
64
|
+
hash = data.map do |k, v|
|
60
65
|
v = DateTime.parse(v) if k.end_with?('_date')
|
61
66
|
|
62
67
|
[k, v]
|
data/lib/how_is/cli.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
1
|
require "how_is"
|
4
2
|
require "slop"
|
5
3
|
|
6
4
|
class HowIs::CLI
|
7
5
|
DEFAULT_REPORT_FILE = "report.#{HowIs::DEFAULT_FORMAT}"
|
8
6
|
|
7
|
+
# Parent class of all exceptions raised in HowIs::CLI.
|
9
8
|
class OptionsError < StandardError
|
10
9
|
end
|
11
10
|
|
11
|
+
# Raised when the specified output file can't be used.
|
12
12
|
class InvalidOutputFileError < OptionsError
|
13
13
|
end
|
14
14
|
|
15
|
+
# Raised when the specified input file doesn't contain
|
16
|
+
# a valid JSON report.
|
15
17
|
class InvalidInputFileError < OptionsError
|
16
18
|
end
|
17
19
|
|
20
|
+
# Raised when no repository is specified, but one is required.
|
21
|
+
# (It's _not_ required, e.g., when +--config+ is passed.)
|
18
22
|
class NoRepositoryError < OptionsError
|
19
23
|
end
|
20
24
|
|
@@ -25,6 +29,8 @@ class HowIs::CLI
|
|
25
29
|
# the library.
|
26
30
|
def call(argv)
|
27
31
|
opts = Slop::Options.new
|
32
|
+
|
33
|
+
# General usage information.
|
28
34
|
opts.banner =
|
29
35
|
<<-EOF.gsub(/ *\| ?/, '')
|
30
36
|
| Usage: how_is REPOSITORY [--report REPORT_FILE] [--from JSON_FILE]
|
@@ -41,48 +47,64 @@ class HowIs::CLI
|
|
41
47
|
opts.separator ""
|
42
48
|
opts.separator "Options:"
|
43
49
|
|
50
|
+
# Allowed arguments:
|
44
51
|
opts.bool "-h", "--help", "Print help text"
|
45
52
|
opts.string "--config", "YAML config file, used to generate a group of reports"
|
46
53
|
opts.string "--from", "JSON report file, used instead of fetching the data again"
|
47
54
|
opts.string "--report", "output file for the report (valid extensions: #{HowIs.supported_formats.join(', ')}; default: #{DEFAULT_REPORT_FILE})"
|
48
55
|
opts.bool "-v", "--version", "prints the version"
|
49
56
|
|
57
|
+
# Parse the arguments.
|
50
58
|
parser = Slop::Parser.new(opts)
|
51
59
|
result = parser.parse(argv)
|
60
|
+
|
61
|
+
# +options+ is a Hash of flags/values.
|
52
62
|
options = result.to_hash
|
63
|
+
# +arguments+ is an Array of values that don't correspond to a flag.
|
53
64
|
arguments = result.arguments
|
54
65
|
|
66
|
+
# If --report isn't specified, default to DEFAULT_REPORT_FILE.
|
55
67
|
options[:report] ||= DEFAULT_REPORT_FILE
|
56
68
|
|
57
69
|
# The following are only useful if they're not nil or false.
|
58
|
-
# Removing them here simplifies contracts and keyword args for
|
70
|
+
# Removing them here simplifies contracts and keyword args for
|
71
|
+
# other APIs.
|
59
72
|
options.delete(:config) unless options[:config]
|
60
73
|
options.delete(:help) unless options[:help]
|
61
74
|
options.delete(:version) unless options[:version]
|
62
75
|
|
63
|
-
#
|
76
|
+
# If we can't export to the specified file, raise an exception.
|
64
77
|
unless HowIs.can_export_to?(options[:report])
|
65
78
|
raise InvalidOutputFileError, "Invalid file: #{options[:report_file]}. Supported formats: #{HowIs.supported_formats.join(', ')}"
|
66
79
|
end
|
67
80
|
|
81
|
+
# If we pass --config, other options (excluding --help and
|
82
|
+
# --version) are ignored. As such, when --config is passed,
|
83
|
+
# everything in this `unless` block is irrelevant.
|
68
84
|
unless options[:config]
|
69
|
-
# If we pass --config, other options (excluding --help and --version)
|
70
|
-
# are ignored. As such, everything in this `unless` block is irrelevant.
|
71
|
-
|
72
85
|
if options[:from]
|
73
86
|
raise InvalidInputFileError, "No such file: #{options[:from]}" unless File.file?(options[:from])
|
74
87
|
|
75
|
-
# Opening the file here is a bit gross, but I couldn't find a
|
76
|
-
# way to do it. -@duckinator
|
77
|
-
options[:repository] = JSON.parse(open(options[:
|
88
|
+
# Opening the file here is a bit gross, but I couldn't find a
|
89
|
+
# better way to do it. -@duckinator
|
90
|
+
options[:repository] = JSON.parse(open(options[:from]).read)['repository']
|
91
|
+
|
78
92
|
raise InvalidInputFileError, "Invalid JSON report file." unless options[:repository]
|
93
|
+
|
79
94
|
elsif argv.length >= 1
|
80
95
|
options[:repository] = argv.delete_at(0)
|
96
|
+
|
81
97
|
else
|
82
98
|
raise NoRepositoryError, "No repository specified."
|
83
99
|
end
|
84
100
|
end
|
85
101
|
|
102
|
+
# Return a Hash with:
|
103
|
+
# +opts+: the original Slop::Options object.
|
104
|
+
# +options+: the Hash of flags/values (e.g. +--foo bar+ becomes
|
105
|
+
# +options[:foo]+ with the value of +"bar"+).
|
106
|
+
# +arguments+: an Array of arguments that don't have a
|
107
|
+
# corresponding flags.
|
86
108
|
{
|
87
109
|
opts: opts,
|
88
110
|
options: options,
|
data/lib/how_is/pulse.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
1
|
require 'tessellator/fetcher'
|
2
2
|
|
3
3
|
class HowIs
|
4
|
-
# This entire class is a monstrous hack, because GitHub doesn't provide
|
5
|
-
# API for Pulse.
|
4
|
+
# This entire class is a monstrous hack, because GitHub doesn't provide
|
5
|
+
# a good API for Pulse.
|
6
|
+
#
|
7
|
+
# TODO: Use GitHub's Statistics API to replace this garbage.
|
8
|
+
# See https://github.com/how-is/how_is/issues/122
|
6
9
|
class Pulse
|
7
10
|
def initialize(repository)
|
8
11
|
@repository = repository
|
9
12
|
@pulse_page_response = fetch_pulse!(repository)
|
10
13
|
end
|
11
14
|
|
15
|
+
# This is probably dead code.
|
12
16
|
def text_summary
|
13
17
|
raise NotImplementedError
|
14
18
|
end
|
15
19
|
|
20
|
+
# Gets the HTML Pulse summary.
|
16
21
|
def html_summary
|
17
22
|
parts =
|
18
23
|
@pulse_page_response.body
|
@@ -30,6 +35,7 @@ class HowIs
|
|
30
35
|
end
|
31
36
|
|
32
37
|
private
|
38
|
+
# Fetch Pulse page from GitHub for scraping.
|
33
39
|
def fetch_pulse!(repository, period='monthly')
|
34
40
|
Tessellator::Fetcher.new.call('get', "https://github.com/#{repository}/pulse/#{period}")
|
35
41
|
end
|
@@ -38,40 +38,62 @@ class HowIs
|
|
38
38
|
@r
|
39
39
|
end
|
40
40
|
|
41
|
+
# === Methods implemented by subclasses of BaseReport ===
|
41
42
|
|
42
|
-
|
43
|
+
##
|
44
|
+
# Returns the format of report this class generates.
|
45
|
+
#
|
46
|
+
# @returns [Symbol] A lowercase symbol denoting the report format.
|
43
47
|
def format
|
44
48
|
raise NotImplementedError
|
45
49
|
end
|
46
50
|
|
51
|
+
##
|
52
|
+
# Appends a title to the report.
|
47
53
|
def title(_text)
|
48
54
|
raise NotImplementedError
|
49
55
|
end
|
50
56
|
|
57
|
+
##
|
58
|
+
# Appends a header to the report.
|
51
59
|
def header(_text)
|
52
60
|
raise NotImplementedError
|
53
61
|
end
|
54
62
|
|
63
|
+
##
|
64
|
+
# Appends a line of text to the report.
|
55
65
|
def text(_text)
|
56
66
|
raise NotImplementedError
|
57
67
|
end
|
58
68
|
|
69
|
+
##
|
70
|
+
# Appends a link to the report.
|
59
71
|
def link(_text, url)
|
60
72
|
raise NotImplementedError
|
61
73
|
end
|
62
74
|
|
75
|
+
##
|
76
|
+
# Appends an unordered list to the report.
|
63
77
|
def unordered_list(arr)
|
64
78
|
raise NotImplementedError
|
65
79
|
end
|
66
80
|
|
81
|
+
##
|
82
|
+
# Appends a horizontal bar graph to the report.
|
67
83
|
def horizontal_bar_graph(data)
|
68
84
|
raise NotImplementedError
|
69
85
|
end
|
70
86
|
|
87
|
+
##
|
88
|
+
# Exports the report as a String.
|
71
89
|
def export
|
72
90
|
raise NotImplementedError
|
73
91
|
end
|
74
92
|
|
93
|
+
##
|
94
|
+
# Exports a report to a file.
|
95
|
+
#
|
96
|
+
# NOTE: May be removed in the future.
|
75
97
|
def export_file(file)
|
76
98
|
raise NotImplementedError
|
77
99
|
end
|
data/lib/how_is/report/json.rb
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
require 'how_is/report/base_report'
|
2
2
|
|
3
3
|
class HowIs
|
4
|
+
##
|
5
|
+
# A JSON report.
|
4
6
|
class JsonReport < BaseReport
|
7
|
+
# A JSON report is simply a JSON dump of the corresponding
|
8
|
+
# HowIs::Analysis instance.
|
9
|
+
|
10
|
+
##
|
11
|
+
# The format of the report.
|
12
|
+
#
|
13
|
+
# @return [Symbol] The name of the format.
|
5
14
|
def format
|
6
15
|
:json
|
7
16
|
end
|
8
17
|
|
18
|
+
##
|
19
|
+
# Generates a report.
|
9
20
|
def export
|
10
21
|
to_json
|
11
22
|
end
|
12
23
|
|
24
|
+
##
|
25
|
+
# Generates a report and writes it to a file.
|
13
26
|
def export_file(file)
|
14
27
|
File.open(file, 'w') do |f|
|
15
28
|
f.write export
|
data/lib/how_is/version.rb
CHANGED
data/lib/how_is.rb
CHANGED
@@ -16,36 +16,65 @@ class HowIs
|
|
16
16
|
DEFAULT_FORMAT = :html
|
17
17
|
|
18
18
|
##
|
19
|
-
# Generate a
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
##
|
27
|
-
# Generates and returns a report as a String.
|
19
|
+
# Generate a HowIs instance, so you can generate reports.
|
20
|
+
#
|
21
|
+
# @param repository [String] The name of a GitHub repository (of the
|
22
|
+
# format <user or organization>/<repository>).
|
23
|
+
# @param analysis [HowIs::Analysis] Optional; if passed, this Analysis
|
24
|
+
# object is used instead of generating one.
|
28
25
|
def initialize(repository, analysis = nil, **kw_args)
|
26
|
+
# If no Analysis is passed, generate one.
|
29
27
|
analysis ||= HowIs.generate_analysis(repository: repository, **kw_args)
|
28
|
+
|
29
|
+
# Used by to_html, to_json, etc.
|
30
30
|
@analysis = analysis
|
31
31
|
end
|
32
32
|
|
33
|
+
##
|
34
|
+
# Generate an HTML report.
|
35
|
+
#
|
36
|
+
# @returns [String] An HTML report.
|
33
37
|
def to_html
|
34
38
|
Report.export(@analysis, :html)
|
35
39
|
end
|
36
40
|
|
41
|
+
##
|
42
|
+
# Generate a JSON report.
|
43
|
+
#
|
44
|
+
# @returns [String] A JSON report.
|
37
45
|
def to_json
|
38
46
|
Report.export(@analysis, :json)
|
39
47
|
end
|
40
48
|
|
49
|
+
##
|
50
|
+
# Given a JSON report, create a new HowIs object (for generating other
|
51
|
+
# reports).
|
52
|
+
#
|
53
|
+
# @param json [String] A JSON report object.
|
54
|
+
# @returns [HowIs] A HowIs object that can be used for generating other
|
55
|
+
# reports, treating the JSON report as a cache.
|
41
56
|
def self.from_json(json)
|
42
|
-
|
57
|
+
self.from_hash(JSON.parse(json))
|
58
|
+
end
|
59
|
+
|
60
|
+
##
|
61
|
+
# Given report data as a hash, create a new HowIs object (for generating
|
62
|
+
# other reports).
|
63
|
+
#
|
64
|
+
# @param data [Hash] A hash containing report data.
|
65
|
+
# @returns [HowIs] A HowIs object that can be used for generating other
|
66
|
+
# reports, treating the provided report data as a cache.
|
67
|
+
def self.from_hash(data)
|
68
|
+
analysis = HowIs::Analyzer.from_hash(data)
|
43
69
|
|
44
70
|
self.new(analysis.repository, analysis)
|
45
71
|
end
|
46
72
|
|
47
73
|
##
|
48
74
|
# Returns a list of possible export formats.
|
75
|
+
#
|
76
|
+
# @returns [Array<String>] An array of the types of reports you can
|
77
|
+
# generate.
|
49
78
|
def self.supported_formats
|
50
79
|
report_constants = HowIs.constants.grep(/.Report/) - [:BaseReport]
|
51
80
|
report_constants.map {|x| x.to_s.split('Report').first.downcase }
|
@@ -53,28 +82,27 @@ class HowIs
|
|
53
82
|
|
54
83
|
##
|
55
84
|
# Returns whether or not the specified +file+ can be exported to.
|
85
|
+
#
|
86
|
+
# @param file [String] A filename.
|
87
|
+
# @returns [Boolean] +true+ if HowIs can export to the file, +false+
|
88
|
+
# if it can't.
|
56
89
|
def self.can_export_to?(file)
|
57
90
|
# TODO: Check if the file is writable?
|
58
91
|
supported_formats.include?(file.split('.').last)
|
59
92
|
end
|
60
93
|
|
61
|
-
# Generate an analysis.
|
94
|
+
# Generate an analysis.
|
95
|
+
# TODO: This may make more sense as Analysis.new().
|
62
96
|
Contract C::KeywordArgs[repository: String,
|
63
|
-
from: C::Optional[C::Or[String, nil]],
|
64
97
|
fetcher: C::Optional[Class],
|
65
98
|
analyzer: C::Optional[Class],
|
66
99
|
github: C::Optional[C::Any]] => C::Any
|
67
100
|
def self.generate_analysis(repository:,
|
68
|
-
from: nil,
|
69
101
|
fetcher: Fetcher.new,
|
70
102
|
analyzer: Analyzer.new,
|
71
103
|
github: nil)
|
72
|
-
|
73
|
-
|
74
|
-
else
|
75
|
-
raw_data = fetcher.call(repository, github)
|
76
|
-
analysis = analyzer.call(raw_data)
|
77
|
-
end
|
104
|
+
raw_data = fetcher.call(repository, github)
|
105
|
+
analysis = analyzer.call(raw_data)
|
78
106
|
|
79
107
|
analysis
|
80
108
|
end
|
@@ -101,6 +129,13 @@ class HowIs
|
|
101
129
|
|
102
130
|
##
|
103
131
|
# Generates a series of report files based on a config Hash.
|
132
|
+
#
|
133
|
+
# @param config [Hash] A Hash specifying the formats, locations, etc
|
134
|
+
# of the reports to generate.
|
135
|
+
# @param github (You don't need this.) An object to replace the GitHub
|
136
|
+
# class when fetching data.
|
137
|
+
# @param report_class (You don't need this.) An object to replace the
|
138
|
+
# HowIs::Report class when generating reports.
|
104
139
|
def self.from_config(config,
|
105
140
|
github: nil,
|
106
141
|
report_class: nil)
|
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:
|
4
|
+
version: 18.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: 2017-
|
11
|
+
date: 2017-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: github_api
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 4.4.1
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rack
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: tessellator-fetcher
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,7 +189,7 @@ files:
|
|
203
189
|
- lib/how_is/report/json.rb
|
204
190
|
- lib/how_is/version.rb
|
205
191
|
- roadmap.markdown
|
206
|
-
homepage: https://github.com/
|
192
|
+
homepage: https://github.com/how-is/how_is
|
207
193
|
licenses:
|
208
194
|
- MIT
|
209
195
|
metadata: {}
|
@@ -223,8 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
209
|
version: '0'
|
224
210
|
requirements: []
|
225
211
|
rubyforge_project:
|
226
|
-
rubygems_version: 2.5.2
|
212
|
+
rubygems_version: 2.4.5.2
|
227
213
|
signing_key:
|
228
214
|
specification_version: 4
|
229
|
-
summary: Quantify the health of a GitHub repository
|
215
|
+
summary: Quantify the health of a GitHub repository.
|
230
216
|
test_files: []
|