what_is_it_about 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/what_is_it_about +5 -0
- data/lib/what_is_it_about/cli.rb +50 -0
- data/lib/what_is_it_about/config.rb +39 -0
- data/lib/what_is_it_about/gem_summary.rb +225 -0
- data/lib/what_is_it_about/github.rb +18 -0
- data/lib/what_is_it_about/report.rb +92 -0
- data/lib/what_is_it_about/summary.rb +30 -0
- data/lib/what_is_it_about/version.rb +3 -0
- data/lib/what_is_it_about.rb +19 -0
- data/what_is_it_about.gemspec +29 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3f337587685e9fdf137dd9d3bd60e1b428ae0e6
|
4
|
+
data.tar.gz: e11c88f95315284d47815930f260ae3927f60d06
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b0fff8b32f91ed3bad568b448817a6d59100eb447bf4b91ca98e621f5b5d6176c1f704b3d71770d8a4e0283d79a4fb5196bb600d1d8be062788464069811faa
|
7
|
+
data.tar.gz: b9e9934ee945758ed39f76f94ffb13b3a28d8ce5f954e55cd3810b6de2e4ce7aeacdf0c00698a0d8001cc67d4a41f1bb35280ebeee1200a8edebadf262deada6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Dmitry Bochkarev
|
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
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# What Is It About?
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/what_is_it_about`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'what_is_it_about'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install what_is_it_about
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
$ what_is_it_about lock Gemfile_old.lock Gemfile.lock
|
26
|
+
$ what_is_it_about diff upstream/develop upstream/master
|
27
|
+
$ what_is_it_about pull https://github.com/discourse/discourse/pull/4332
|
28
|
+
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/DmitryBochkarev/whats_is_it_about.
|
39
|
+
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
44
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "what_is_it_about"
|
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,50 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'what_is_it_about'
|
4
|
+
require 'base64'
|
5
|
+
require 'thor'
|
6
|
+
|
7
|
+
module WhatIsItAbout
|
8
|
+
class CLI < Thor
|
9
|
+
GEMFILE_LOCK = 'Gemfile.lock'.freeze
|
10
|
+
|
11
|
+
desc 'lock OLD_GEMFILE_LOCK NEW_GEMFILE_LOCK', ''
|
12
|
+
def lock(old_gemfile_lock, new_gemfile_lock)
|
13
|
+
old_content = File.open(old_gemfile_lock, 'rb', &:read)
|
14
|
+
new_content = File.open(new_gemfile_lock, 'rb', &:read)
|
15
|
+
report(old_content, new_content)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'pull LINK', ''
|
19
|
+
def pull(link)
|
20
|
+
rx = %r{/(?<repo>[\w-]+/[\w-]+)/pull/(?<pull_id>[\d]+)}
|
21
|
+
match = rx.match(link)
|
22
|
+
raise "invalid pull request link #{link}" unless match
|
23
|
+
pull = WhatIsItAbout.github.client.pull match[:repo], match[:pull_id]
|
24
|
+
base_lock = WhatIsItAbout.github.client.content pull[:base][:repo][:full_name], ref: pull[:base][:sha], path: GEMFILE_LOCK
|
25
|
+
base_content = Base64.decode64(base_lock[:content])
|
26
|
+
head_lock = WhatIsItAbout.github.client.content pull[:head][:repo][:full_name], ref: pull[:head][:sha], path: GEMFILE_LOCK
|
27
|
+
head_content = Base64.decode64(head_lock[:content])
|
28
|
+
report(base_content, head_content)
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'diff OLD_REF NEW_REF', ''
|
32
|
+
def diff(old_ref, new_ref)
|
33
|
+
old_content = `git show #{old_ref}:#{GEMFILE_LOCK}`
|
34
|
+
new_content = `git show #{new_ref}:#{GEMFILE_LOCK}`
|
35
|
+
report(old_content, new_content)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'set_github_token TOKEN', ''
|
39
|
+
def set_github_token(token)
|
40
|
+
WhatIsItAbout.config.set('github', 'token', token)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def report(old_content, new_content)
|
46
|
+
summary = Summary.new(old_content, new_content)
|
47
|
+
puts Report::PlainText.new(summary)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module WhatIsItAbout
|
6
|
+
def self.config
|
7
|
+
@@config = Config.new
|
8
|
+
end
|
9
|
+
|
10
|
+
class Config
|
11
|
+
def initialize(file = "#{Dir.home}/.what_is_it_about")
|
12
|
+
@file = file
|
13
|
+
@data = File.exist?(file) ? YAML.load_file(file) : {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(*path)
|
17
|
+
data = @data
|
18
|
+
path.each do |branch|
|
19
|
+
data = data[branch]
|
20
|
+
return unless data
|
21
|
+
end
|
22
|
+
data
|
23
|
+
end
|
24
|
+
|
25
|
+
def set(*args)
|
26
|
+
val = args.pop
|
27
|
+
leaf = args.pop
|
28
|
+
data = @data
|
29
|
+
args.each do |branch|
|
30
|
+
data[branch] ||= {}
|
31
|
+
data = data[branch]
|
32
|
+
end
|
33
|
+
data[leaf] = val
|
34
|
+
File.open(@file, 'w') do |f|
|
35
|
+
f.puts YAML.dump(@data)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module WhatIsItAbout
|
4
|
+
class GemSummary
|
5
|
+
GITHUB_RX = %r{github\.com}
|
6
|
+
REPO_RX = %r{[/:](?<user>[\w-]+)/(?<repo>[\w-]+)(?<suffix>\.git)?}
|
7
|
+
|
8
|
+
def initialize(old_spec, new_spec)
|
9
|
+
@spec = {
|
10
|
+
old: old_spec,
|
11
|
+
new: new_spec
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def name
|
16
|
+
@spec.values.compact[0].name
|
17
|
+
end
|
18
|
+
|
19
|
+
def added?
|
20
|
+
@spec[:old].nil?
|
21
|
+
end
|
22
|
+
|
23
|
+
def removed?
|
24
|
+
@spec[:new].nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
def changed?
|
28
|
+
version_changed? || source_changed?
|
29
|
+
end
|
30
|
+
|
31
|
+
def version_changed?
|
32
|
+
versions.values.uniq.size != 1
|
33
|
+
end
|
34
|
+
|
35
|
+
def versions
|
36
|
+
spec_map do |spec|
|
37
|
+
spec.version.to_s
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def source_changed?
|
42
|
+
source_type_changed? || path_changed? || source_repository_changed? || source_branch_changed? || source_revision_changed?
|
43
|
+
end
|
44
|
+
|
45
|
+
def source_type_changed?
|
46
|
+
source_types.values.uniq.size != 1
|
47
|
+
end
|
48
|
+
|
49
|
+
def source_types
|
50
|
+
spec_map do |spec|
|
51
|
+
case spec.source
|
52
|
+
when Bundler::Source::Git
|
53
|
+
:git
|
54
|
+
when Bundler::Source::Path
|
55
|
+
:path
|
56
|
+
when Bundler::Source::Rubygems
|
57
|
+
:rubygems
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def path_changed?
|
63
|
+
paths.values.uniq.size != 1
|
64
|
+
end
|
65
|
+
|
66
|
+
def paths
|
67
|
+
spec_map do |spec|
|
68
|
+
spec.source.path.to_s if spec.source.class == Bundler::Source::Path
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def source_repository_changed?
|
73
|
+
source_repositories.values.uniq.size != 1
|
74
|
+
end
|
75
|
+
|
76
|
+
def source_repositories
|
77
|
+
spec_map do |spec|
|
78
|
+
spec.source.uri if spec.source.class == Bundler::Source::Git
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def source_branch_changed?
|
83
|
+
source_branches.values.uniq.size != 1
|
84
|
+
end
|
85
|
+
|
86
|
+
def source_branches
|
87
|
+
spec_map do |spec|
|
88
|
+
next unless spec.source.class == Bundler::Source::Git
|
89
|
+
if spec.source.branch.to_s.empty?
|
90
|
+
'master'
|
91
|
+
else
|
92
|
+
spec.source.branch
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def source_revision_changed?
|
98
|
+
source_revisions.values.uniq.size != 1
|
99
|
+
end
|
100
|
+
|
101
|
+
def source_revisions
|
102
|
+
spec_map do |spec|
|
103
|
+
spec.source.revision if spec.source.class == Bundler::Source::Git
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def commits_log
|
108
|
+
@commits_log ||= {
|
109
|
+
added: added_compare,
|
110
|
+
removed: removed_compare
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def spec_map(&block)
|
117
|
+
results = @spec.values.map do |spec|
|
118
|
+
next unless spec
|
119
|
+
block.call(spec)
|
120
|
+
end
|
121
|
+
|
122
|
+
{
|
123
|
+
old: results[0],
|
124
|
+
new: results[1]
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
128
|
+
def added_compare
|
129
|
+
p = github_compare_params
|
130
|
+
return if p.values.compact.size < 2
|
131
|
+
repo = "#{p[:old][:user]}/#{p[:old][:repo]}"
|
132
|
+
start = p[:old][:revision]
|
133
|
+
end_ = "#{p[:new][:user]}:#{p[:new][:revision]}"
|
134
|
+
puts "downloading commits #{repo} #{start} => #{end_}"
|
135
|
+
WhatIsItAbout.github.client.compare repo, start, end_
|
136
|
+
rescue Octokit::NotFound => e
|
137
|
+
$stderr.puts e.inspect if ENV['VERBOSE']
|
138
|
+
end
|
139
|
+
|
140
|
+
def removed_compare
|
141
|
+
p = github_compare_params
|
142
|
+
return if p.values.compact.size < 2
|
143
|
+
repo = "#{p[:new][:user]}/#{p[:new][:repo]}"
|
144
|
+
start = p[:new][:revision]
|
145
|
+
end_ = "#{p[:old][:user]}:#{p[:old][:revision]}"
|
146
|
+
puts "downloading commits #{repo} #{start} => #{end_}"
|
147
|
+
WhatIsItAbout.github.client.compare repo, start, end_
|
148
|
+
rescue Octokit::NotFound => e
|
149
|
+
$stderr.puts e.inspect if ENV['VERBOSE']
|
150
|
+
end
|
151
|
+
|
152
|
+
def github_compare_params
|
153
|
+
@github_compare_params ||=
|
154
|
+
begin
|
155
|
+
spec_map do |spec|
|
156
|
+
v = @spec.key(spec)
|
157
|
+
source_uri, revision =
|
158
|
+
case spec.source
|
159
|
+
when Bundler::Source::Git
|
160
|
+
[source_repositories[v], source_revisions[v]]
|
161
|
+
when Bundler::Source::Rubygems
|
162
|
+
uri = homepage(spec)
|
163
|
+
uri = rubygems_source_uri(spec) unless GITHUB_RX.match(uri)
|
164
|
+
[uri, "v#{versions[v]}"]
|
165
|
+
end
|
166
|
+
|
167
|
+
next unless source_uri
|
168
|
+
next unless GITHUB_RX.match(source_uri)
|
169
|
+
|
170
|
+
match = REPO_RX.match(source_uri)
|
171
|
+
|
172
|
+
next unless match
|
173
|
+
|
174
|
+
{
|
175
|
+
user: match[:user],
|
176
|
+
repo: match[:repo],
|
177
|
+
revision: revision
|
178
|
+
}
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def homepage(spec)
|
184
|
+
specification = fetch_spec(spec)
|
185
|
+
return unless specification
|
186
|
+
specification.homepage
|
187
|
+
end
|
188
|
+
|
189
|
+
def fetch_spec(spec)
|
190
|
+
spec.source.fetchers.each do |fetcher|
|
191
|
+
begin
|
192
|
+
if ENV['VERBOSE']
|
193
|
+
puts "fetching specification from #{fetcher.uri} for #{spec.name}-#{spec.version}"
|
194
|
+
end
|
195
|
+
return fetcher.fetch_spec([spec.name, spec.version, spec.platform])
|
196
|
+
rescue Bundler::Fetcher::FallbackError => _e
|
197
|
+
next
|
198
|
+
end
|
199
|
+
end
|
200
|
+
nil
|
201
|
+
end
|
202
|
+
|
203
|
+
def rubygems_source_uri(spec)
|
204
|
+
@rubygems_source_uri ||= {}
|
205
|
+
|
206
|
+
return @rubygems_source_uri[spec.name] if @rubygems_source_uri.key?(spec.name)
|
207
|
+
|
208
|
+
puts "fetching specification from rubygems api #{spec.name}" if ENV['VERBOSE']
|
209
|
+
data = open("https://rubygems.org/api/v1/gems/#{spec.name}.json").read
|
210
|
+
specification = JSON.load(data)
|
211
|
+
%w(source_code_uri project_uri homepage_uri).each do |field|
|
212
|
+
val = specification[field]
|
213
|
+
next unless val
|
214
|
+
next unless GITHUB_RX.match(val)
|
215
|
+
next unless REPO_RX.match(val)
|
216
|
+
@rubygems_source_uri[spec.name] = val
|
217
|
+
return val
|
218
|
+
end
|
219
|
+
@rubygems_source_uri[spec.name] = nil
|
220
|
+
rescue OpenURI::HTTPError => e
|
221
|
+
@rubygems_source_uri[spec.name] = nil
|
222
|
+
$stderr.puts e.inspect if ENV['VERBOSE']
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'octokit'
|
3
|
+
|
4
|
+
module WhatIsItAbout
|
5
|
+
def self.github
|
6
|
+
@@github = Github.new
|
7
|
+
end
|
8
|
+
|
9
|
+
class Github
|
10
|
+
attr_reader :client
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
token = WhatIsItAbout.config.get('github', 'token')
|
14
|
+
raise 'please do $ what_is_it_abouts set_github_token TOKEN' unless token
|
15
|
+
@client = Octokit::Client.new(access_token: token)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module WhatIsItAbout
|
4
|
+
module Report
|
5
|
+
class PlainText
|
6
|
+
def initialize(summary)
|
7
|
+
@summary = summary
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
lines = @summary.gems.each_with_object([]) do |gem, lines|
|
12
|
+
case
|
13
|
+
when gem.added?
|
14
|
+
lines << [
|
15
|
+
'+',
|
16
|
+
gem.name,
|
17
|
+
gem.versions[:new],
|
18
|
+
gem_source(gem, :new)
|
19
|
+
].join(' ')
|
20
|
+
when gem.removed?
|
21
|
+
lines << [
|
22
|
+
'-',
|
23
|
+
gem.name,
|
24
|
+
gem.versions[:old],
|
25
|
+
gem_source(gem, :old)
|
26
|
+
].join(' ')
|
27
|
+
when gem.changed?
|
28
|
+
version =
|
29
|
+
if gem.version_changed?
|
30
|
+
"#{gem.versions[:old]} => #{gem.versions[:new]}"
|
31
|
+
else
|
32
|
+
gem.versions[:old]
|
33
|
+
end
|
34
|
+
source =
|
35
|
+
if gem.source_changed?
|
36
|
+
"#{gem_source(gem, :old)} => #{gem_source(gem, :new)}"
|
37
|
+
else
|
38
|
+
gem_source(gem, :old)
|
39
|
+
end
|
40
|
+
lines << [
|
41
|
+
'C',
|
42
|
+
gem.name,
|
43
|
+
version,
|
44
|
+
source
|
45
|
+
].join(' ')
|
46
|
+
gem.commits_log.each do |type, log|
|
47
|
+
next unless log
|
48
|
+
next if log[:commits].empty?
|
49
|
+
padding = ' '*4
|
50
|
+
lines << padding + "commits #{type} #{log[:html_url]}"
|
51
|
+
padding *= 2
|
52
|
+
message_padding = padding * 2
|
53
|
+
log[:commits].each do |commit|
|
54
|
+
lines << [
|
55
|
+
padding + commit[:commit][:author][:name],
|
56
|
+
commit[:html_url]
|
57
|
+
].join(' ')
|
58
|
+
padded_message = commit[:commit][:message].lines.map do |line|
|
59
|
+
message_padding + line
|
60
|
+
end.join('')
|
61
|
+
lines << padded_message
|
62
|
+
end
|
63
|
+
end
|
64
|
+
else
|
65
|
+
lines << [
|
66
|
+
'=',
|
67
|
+
gem.name,
|
68
|
+
gem.versions[:old],
|
69
|
+
gem_source(gem, :old)
|
70
|
+
].join(' ')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
lines.join("\n")
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def gem_source(gem, version)
|
79
|
+
case gem.source_types[version]
|
80
|
+
when :rubygems
|
81
|
+
'rubygems'
|
82
|
+
when :path
|
83
|
+
gem.paths[version]
|
84
|
+
when :git
|
85
|
+
"#{gem.source_repositories[version]}##{gem.source_branches[version]}(#{gem.source_revisions[version]})"
|
86
|
+
else
|
87
|
+
raise "Unknown source type for #{gem.inspect}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module WhatIsItAbout
|
4
|
+
class Summary
|
5
|
+
def initialize(old_gemfile_lock_content, new_gemfile_lock_content)
|
6
|
+
@old_definition = definition(old_gemfile_lock_content)
|
7
|
+
@new_definition = definition(new_gemfile_lock_content)
|
8
|
+
end
|
9
|
+
|
10
|
+
def gems
|
11
|
+
@gems ||=
|
12
|
+
begin
|
13
|
+
gem_names = (@old_definition.specs + @new_definition.specs).map(&:name).uniq.sort
|
14
|
+
gem_names.map { |name| gem_summary(name)}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def definition(gemfile_lock_content)
|
21
|
+
Bundler::LockfileParser.new(gemfile_lock_content)
|
22
|
+
end
|
23
|
+
|
24
|
+
def gem_summary(name)
|
25
|
+
old_spec = @old_definition.specs.find { |spec| spec.name == name }
|
26
|
+
new_spec = @new_definition.specs.find { |spec| spec.name == name }
|
27
|
+
GemSummary.new(old_spec, new_spec)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'yaml'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'json'
|
6
|
+
require 'pry'
|
7
|
+
|
8
|
+
# for parsing gemfile lock
|
9
|
+
ENV['BUNDLE_GEMFILE'] = Pathname.new(Dir.pwd).join(__FILE__).to_s
|
10
|
+
|
11
|
+
module WhatIsItAbout
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'what_is_it_about/version'
|
15
|
+
require 'what_is_it_about/config'
|
16
|
+
require 'what_is_it_about/github'
|
17
|
+
require 'what_is_it_about/gem_summary'
|
18
|
+
require 'what_is_it_about/summary'
|
19
|
+
require 'what_is_it_about/report'
|
@@ -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 'what_is_it_about/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "what_is_it_about"
|
8
|
+
spec.version = WhatIsItAbout::VERSION
|
9
|
+
spec.authors = ["Dmitry Bochkarev"]
|
10
|
+
spec.email = ["dimabochkarev@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Write a short summary, because Rubygems requires one.}
|
13
|
+
spec.description = %q{Write a longer description or delete this line.}
|
14
|
+
spec.homepage = "https://github.com/DmitryBochkarev/whats_is_it_about"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency 'bundler'
|
23
|
+
spec.add_dependency 'octokit'
|
24
|
+
spec.add_dependency 'thor'
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: what_is_it_about
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitry Bochkarev
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-26 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: '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: octokit
|
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: thor
|
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.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.12'
|
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: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description: Write a longer description or delete this line.
|
98
|
+
email:
|
99
|
+
- dimabochkarev@gmail.com
|
100
|
+
executables:
|
101
|
+
- what_is_it_about
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- exe/what_is_it_about
|
115
|
+
- lib/what_is_it_about.rb
|
116
|
+
- lib/what_is_it_about/cli.rb
|
117
|
+
- lib/what_is_it_about/config.rb
|
118
|
+
- lib/what_is_it_about/gem_summary.rb
|
119
|
+
- lib/what_is_it_about/github.rb
|
120
|
+
- lib/what_is_it_about/report.rb
|
121
|
+
- lib/what_is_it_about/summary.rb
|
122
|
+
- lib/what_is_it_about/version.rb
|
123
|
+
- what_is_it_about.gemspec
|
124
|
+
homepage: https://github.com/DmitryBochkarev/whats_is_it_about
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.5.1
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Write a short summary, because Rubygems requires one.
|
148
|
+
test_files: []
|
149
|
+
has_rdoc:
|