gemstory 0.1.0 → 0.1.1
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 +4 -4
- data/.ruby-version +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -5
- data/gemstory.gemspec +0 -1
- data/lib/gemstory.rb +3 -1
- data/lib/gemstory/cli.rb +12 -9
- data/lib/gemstory/printer/helpers.rb +9 -5
- data/lib/gemstory/printer/horizontal.rb +17 -14
- data/lib/gemstory/printer/vertical.rb +13 -11
- data/lib/gemstory/reader.rb +17 -17
- data/lib/gemstory/version.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 003afca4f263042d29645b9deadcbc4088afad853bae518baf1caae0a65fdd3b
|
|
4
|
+
data.tar.gz: b93fe764dac7bbc3c3916736cdff1cdf5fee874183aebc845268c59b8bba3918
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3d9ec0457ee85800b737eb0adafaa7e5af0124df866d9d2c7d700b2dcc32eeceb67c814ca2b31e0a9388ec7fa8d2f5f68e9615b9064be818efacc58d86a073e
|
|
7
|
+
data.tar.gz: bba45f2a5f5c34a2cf31dc52af561c6fb9beae6240410aa5dbc362fdefd0252ce82037a56ad5a9ca23daafe5713096507c10a2c3631ccdd43ff918e1dafd95c0
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.5.0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
# Gemstory
|
|
2
|
-
Gemstory tells the
|
|
2
|
+
Gemstory tells the history of gems in your project. Its a command line tool that will read the history of the Gemfile.lock and project the output in terminal.
|
|
3
3
|
|
|
4
4
|
## Installation
|
|
5
5
|
|
|
6
|
-
$ gem install gemstory
|
|
6
|
+
$ gem install gemstory
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Run `gemstory` in your project root folder. This will return the history of Gem upgrades of the project.
|
|
11
|
+
|
|
12
|
+
#### Options
|
|
13
|
+
|
|
14
|
+
A single Gem name can be passed as an option. This will return details information about the Gem history, commits and authors.
|
|
15
|
+
|
|
16
|
+
`gemstory rails`
|
|
17
|
+
|
|
18
|
+
Or multiple Gems can be passed as options so that history can be compared.
|
|
19
|
+
|
|
20
|
+
`gemstory rails thin`
|
|
11
21
|
|
|
12
22
|
## Development
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
More CLI options are under construction. Output can be a json file or an HTML file in the future.
|
|
15
25
|
|
|
16
26
|
|
|
17
27
|
## Contributing
|
|
18
28
|
|
|
19
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/EdwinRozario/gemstory. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
20
30
|
|
|
21
31
|
## License
|
|
22
32
|
|
data/gemstory.gemspec
CHANGED
data/lib/gemstory.rb
CHANGED
data/lib/gemstory/cli.rb
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'thor'
|
|
2
4
|
|
|
3
5
|
module Gemstory
|
|
6
|
+
# Handles the CLI commands
|
|
4
7
|
class Cli < Thor
|
|
5
8
|
attr_reader :history, :printer
|
|
6
9
|
|
|
7
10
|
def initialize(argv)
|
|
8
11
|
@history = Reader.new(argv)
|
|
9
12
|
|
|
10
|
-
if argv.empty?
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
@printer = if argv.empty?
|
|
14
|
+
Printer::Horizontal
|
|
15
|
+
elsif argv.length == 1
|
|
16
|
+
Printer::Vertical
|
|
17
|
+
else
|
|
18
|
+
Printer::Horizontal
|
|
19
|
+
end
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
desc
|
|
22
|
+
desc 'execute', 'Will print the history of your gems'
|
|
20
23
|
def execute
|
|
21
24
|
@history.call
|
|
22
25
|
|
|
23
26
|
@printer.new(@history).call
|
|
24
27
|
end
|
|
25
28
|
end
|
|
26
|
-
end
|
|
29
|
+
end
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Gemstory
|
|
2
4
|
module Printer
|
|
5
|
+
# Helper methods for printers
|
|
3
6
|
module Helpers
|
|
4
7
|
def compare_version(current_version, last_version)
|
|
5
8
|
last_version = Gem::Version.new(last_version)
|
|
6
9
|
current_version = Gem::Version.new(current_version)
|
|
7
10
|
|
|
8
|
-
if last_version < current_version
|
|
11
|
+
if last_version < current_version
|
|
9
12
|
:up
|
|
10
13
|
elsif last_version > current_version
|
|
11
14
|
:down
|
|
12
15
|
else
|
|
13
16
|
:same
|
|
14
17
|
end
|
|
15
|
-
|
|
16
|
-
rescue
|
|
18
|
+
rescue ArgumentError
|
|
17
19
|
:up
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def status_code
|
|
21
|
-
{ up: " \u2191
|
|
23
|
+
{ up: " \033[0;32m\u2191\033[0;m ",
|
|
24
|
+
down: " \033[0;31m\u2193\033[0;m ",
|
|
25
|
+
next: " \033[0;34m \u2192 \033[0;m " }
|
|
22
26
|
end
|
|
23
27
|
end
|
|
24
28
|
end
|
|
25
|
-
end
|
|
29
|
+
end
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Gemstory
|
|
2
4
|
module Printer
|
|
5
|
+
# Prints history vertically
|
|
3
6
|
class Horizontal
|
|
4
7
|
include Helpers
|
|
5
8
|
|
|
@@ -10,27 +13,27 @@ module Gemstory
|
|
|
10
13
|
end
|
|
11
14
|
|
|
12
15
|
def call
|
|
13
|
-
@history.history.sort.each do |
|
|
14
|
-
print "#{
|
|
15
|
-
|
|
16
|
-
(@history.max_gem_name_size -
|
|
17
|
-
|
|
18
|
-
print
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
@history.history.sort.each do |gem_name, commits|
|
|
17
|
+
print "\033[0;33m#{gem_name}\033[0;m"
|
|
18
|
+
|
|
19
|
+
(@history.max_gem_name_size - gem_name.length).times { print ' ' }
|
|
20
|
+
|
|
21
|
+
print ': '
|
|
22
|
+
|
|
23
|
+
commits.each_with_index do |commit, index|
|
|
21
24
|
version_status = :up
|
|
25
|
+
current_version = commit[:version]
|
|
22
26
|
|
|
23
|
-
unless
|
|
27
|
+
unless index.zero?
|
|
24
28
|
print status_code[:next]
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
last_version = changes[changes.index(change) - 1][:version]
|
|
30
|
+
last_version = commits[index - 1][:version]
|
|
28
31
|
version_status = compare_version(current_version, last_version)
|
|
29
32
|
end
|
|
30
33
|
|
|
31
|
-
date_string =
|
|
34
|
+
date_string = commit[:date].strftime('%d.%m.%Y')
|
|
32
35
|
|
|
33
|
-
print "#{
|
|
36
|
+
print "#{current_version}#{status_code[version_status]}(#{date_string})"
|
|
34
37
|
end
|
|
35
38
|
|
|
36
39
|
puts ' '
|
|
@@ -38,4 +41,4 @@ module Gemstory
|
|
|
38
41
|
end
|
|
39
42
|
end
|
|
40
43
|
end
|
|
41
|
-
end
|
|
44
|
+
end
|
|
@@ -1,39 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Gemstory
|
|
2
4
|
module Printer
|
|
5
|
+
# Prints hostory of a single gem verticalling through commits
|
|
3
6
|
class Vertical
|
|
4
7
|
include Helpers
|
|
5
8
|
|
|
6
9
|
attr_reader :history
|
|
7
10
|
|
|
8
11
|
def initialize(history)
|
|
9
|
-
@history = history
|
|
12
|
+
@history = history.history
|
|
10
13
|
end
|
|
11
14
|
|
|
12
15
|
def call
|
|
13
|
-
if @history.
|
|
16
|
+
if @history.empty?
|
|
14
17
|
puts 'Requested gem dosent exist in the Gemfile.lock'
|
|
15
18
|
else
|
|
16
|
-
gem_name = @history.
|
|
17
|
-
commits = @history.history.first.last
|
|
19
|
+
gem_name, commits = @history.first
|
|
18
20
|
|
|
19
|
-
puts gem_name
|
|
21
|
+
puts "\033[0;33m#{gem_name}\033[0;m"
|
|
20
22
|
puts ' '
|
|
21
23
|
|
|
22
|
-
commits.
|
|
24
|
+
commits.each_with_index do |commit, index|
|
|
23
25
|
version_status = :up
|
|
26
|
+
current_version = commit[:version]
|
|
24
27
|
|
|
25
|
-
unless
|
|
26
|
-
|
|
27
|
-
last_version = commits[commits.index(commit) - 1][:version]
|
|
28
|
+
unless index.zero?
|
|
29
|
+
last_version = commits[index - 1][:version]
|
|
28
30
|
version_status = compare_version(current_version, last_version)
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
date_string = commit[:date].strftime('%d.%m.%Y')
|
|
32
34
|
|
|
33
|
-
puts "#{status_code[version_status]} #{
|
|
35
|
+
puts "#{status_code[version_status]} #{current_version} #{date_string} #{commit[:commit]} #{commit[:author]}"
|
|
34
36
|
end
|
|
35
37
|
end
|
|
36
38
|
end
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
|
-
end
|
|
41
|
+
end
|
data/lib/gemstory/reader.rb
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'date'
|
|
2
4
|
|
|
3
5
|
module Gemstory
|
|
6
|
+
# Reads the git logs and produce and Hash
|
|
4
7
|
class Reader
|
|
5
8
|
attr_reader :logs, :line, :date, :max_gem_name_size,
|
|
6
9
|
:commit, :history, :author, :requested_gems
|
|
@@ -23,37 +26,35 @@ module Gemstory
|
|
|
23
26
|
|
|
24
27
|
ruby_gem.strip!
|
|
25
28
|
gem_name_part = ruby_gem.match(/(.*)(?= \()/)
|
|
26
|
-
|
|
29
|
+
|
|
27
30
|
if gem_name_part
|
|
28
|
-
gem_name = gem_name_part[0]
|
|
31
|
+
gem_name = gem_name_part[0].to_sym
|
|
29
32
|
version = ruby_gem.match(/(?<=\()(.*?)(?=\))/)[0]
|
|
30
33
|
else
|
|
31
|
-
gem_name = ruby_gem
|
|
34
|
+
gem_name = ruby_gem.to_sym
|
|
32
35
|
version = nil
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
unless @requested_gems.empty?
|
|
36
|
-
return unless @requested_gems.include? gem_name
|
|
39
|
+
return unless @requested_gems.include? gem_name.to_s
|
|
37
40
|
end
|
|
38
41
|
|
|
39
42
|
@max_gem_name_size = gem_name.length if gem_name.length > @max_gem_name_size
|
|
40
|
-
|
|
41
|
-
@history[gem_name
|
|
42
|
-
|
|
43
|
-
@history[gem_name.to_sym] << { date: @date, commit: @commit,
|
|
44
|
-
version: version, author: @author }
|
|
43
|
+
@history[gem_name] ||= []
|
|
44
|
+
@history[gem_name] << { date: date, commit: commit,
|
|
45
|
+
version: version, author: author }
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
def gem?
|
|
48
|
-
|
|
49
|
+
line.match(/(.*)(\()(.*?)(\))/)
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
def new_line?
|
|
52
|
-
|
|
53
|
+
line.match(/^\+ /)
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def author?
|
|
56
|
-
matches =
|
|
57
|
+
matches = line.match(/(?<=^Author: )(.*)/)
|
|
57
58
|
|
|
58
59
|
if matches
|
|
59
60
|
@author = matches[0]
|
|
@@ -64,7 +65,7 @@ module Gemstory
|
|
|
64
65
|
end
|
|
65
66
|
|
|
66
67
|
def date?
|
|
67
|
-
matches =
|
|
68
|
+
matches = line.match(/(?<=^Date: )(.*)/)
|
|
68
69
|
|
|
69
70
|
if matches
|
|
70
71
|
@date = Date.parse(matches[0])
|
|
@@ -75,7 +76,7 @@ module Gemstory
|
|
|
75
76
|
end
|
|
76
77
|
|
|
77
78
|
def commit?
|
|
78
|
-
matches =
|
|
79
|
+
matches = line.match(/(?<=^commit )(.*)/)
|
|
79
80
|
|
|
80
81
|
if matches
|
|
81
82
|
@commit = matches[0]
|
|
@@ -91,7 +92,7 @@ module Gemstory
|
|
|
91
92
|
|
|
92
93
|
@logs.each_line do |line|
|
|
93
94
|
@line = line.strip
|
|
94
|
-
|
|
95
|
+
|
|
95
96
|
next if commit?
|
|
96
97
|
next if date?
|
|
97
98
|
next if author?
|
|
@@ -110,7 +111,6 @@ module Gemstory
|
|
|
110
111
|
end
|
|
111
112
|
end.compact
|
|
112
113
|
end
|
|
113
|
-
|
|
114
|
-
end
|
|
114
|
+
end
|
|
115
115
|
end
|
|
116
116
|
end
|
data/lib/gemstory/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gemstory
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Edwin Rozario
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-02-
|
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -91,6 +91,7 @@ extra_rdoc_files: []
|
|
|
91
91
|
files:
|
|
92
92
|
- ".gitignore"
|
|
93
93
|
- ".rspec"
|
|
94
|
+
- ".ruby-version"
|
|
94
95
|
- ".travis.yml"
|
|
95
96
|
- CODE_OF_CONDUCT.md
|
|
96
97
|
- Gemfile
|