gemstory 0.1.0.beta2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/gemstory.gemspec +1 -1
- data/lib/gemstory.rb +3 -1
- data/lib/gemstory/cli.rb +12 -3
- data/lib/gemstory/printer/helpers.rb +25 -0
- data/lib/gemstory/printer/horizontal.rb +41 -0
- data/lib/gemstory/printer/vertical.rb +39 -0
- data/lib/gemstory/reader.rb +41 -53
- data/lib/gemstory/version.rb +1 -1
- metadata +7 -5
- data/lib/gemstory/printer.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66652c50f8e1074651114aad547f9d51cc32cb14b1b578ace9d33bb4a235920d
|
4
|
+
data.tar.gz: 2699c4d3c9bf92f8ce695e0ca42aef0ec5aa7b8f960a61954f3c04518935586d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d51b6e2eefc119be82487cabcc4767a09b7dffd78306b73c8b57d58fb0a188ac8e9fda24124e9de15777f7e46645dea42f38fa54822eb0efe191f6d097e8695
|
7
|
+
data.tar.gz: 05cd3ce1949cd798cdee608c2a84b41ae1778404c0dd490fe4a2d400730814a5cfcd9893a2cbc1be6d3a86382af10d1125697519c046efff94dae702686d7fbf
|
data/Gemfile.lock
CHANGED
data/gemstory.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
# spec.bindir = "exe"
|
32
32
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
33
33
|
#spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
-
spec.require_paths = [
|
34
|
+
spec.require_paths = ['lib']
|
35
35
|
|
36
36
|
spec.add_runtime_dependency 'thor', '~> 0.20.0'
|
37
37
|
|
data/lib/gemstory.rb
CHANGED
data/lib/gemstory/cli.rb
CHANGED
@@ -2,16 +2,25 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module Gemstory
|
4
4
|
class Cli < Thor
|
5
|
-
attr_reader :history
|
5
|
+
attr_reader :history, :printer
|
6
6
|
|
7
7
|
def initialize(argv)
|
8
|
-
@history =
|
8
|
+
@history = Reader.new(argv)
|
9
|
+
|
10
|
+
if argv.empty?
|
11
|
+
@printer = Printer::Horizontal
|
12
|
+
elsif argv.length == 1
|
13
|
+
@printer = Printer::Vertical
|
14
|
+
else
|
15
|
+
@printer = Printer::Horizontal
|
16
|
+
end
|
9
17
|
end
|
10
18
|
|
11
19
|
desc "execute", "Will print the history of your gems"
|
12
20
|
def execute
|
13
21
|
@history.call
|
14
|
-
|
22
|
+
|
23
|
+
@printer.new(@history).call
|
15
24
|
end
|
16
25
|
end
|
17
26
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Gemstory
|
2
|
+
module Printer
|
3
|
+
module Helpers
|
4
|
+
def compare_version(current_version, last_version)
|
5
|
+
last_version = Gem::Version.new(last_version)
|
6
|
+
current_version = Gem::Version.new(current_version)
|
7
|
+
|
8
|
+
if last_version < current_version
|
9
|
+
:up
|
10
|
+
elsif last_version > current_version
|
11
|
+
:down
|
12
|
+
else
|
13
|
+
:same
|
14
|
+
end
|
15
|
+
|
16
|
+
rescue
|
17
|
+
:up
|
18
|
+
end
|
19
|
+
|
20
|
+
def status_code
|
21
|
+
{ up: " \u2191 ", down: " \u2193 ", next: " \u2192 " }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Gemstory
|
2
|
+
module Printer
|
3
|
+
class Horizontal
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
attr_reader :history
|
7
|
+
|
8
|
+
def initialize(history)
|
9
|
+
@history = history
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
@history.history.sort.each do |name, changes|
|
14
|
+
print "#{name}"
|
15
|
+
|
16
|
+
(@history.max_gem_name_size - name.to_s.length).times { print ' ' }
|
17
|
+
|
18
|
+
print ": "
|
19
|
+
|
20
|
+
changes.each do |change|
|
21
|
+
version_status = :up
|
22
|
+
|
23
|
+
unless changes.index(change).zero?
|
24
|
+
print status_code[:next]
|
25
|
+
|
26
|
+
current_version = change[:version]
|
27
|
+
last_version = changes[changes.index(change) - 1][:version]
|
28
|
+
version_status = compare_version(current_version, last_version)
|
29
|
+
end
|
30
|
+
|
31
|
+
date_string = change[:date].strftime('%d.%m.%Y')
|
32
|
+
|
33
|
+
print "#{change[:version]}#{status_code[version_status]}(#{date_string})"
|
34
|
+
end
|
35
|
+
|
36
|
+
puts ' '
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Gemstory
|
2
|
+
module Printer
|
3
|
+
class Vertical
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
attr_reader :history
|
7
|
+
|
8
|
+
def initialize(history)
|
9
|
+
@history = history
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
if @history.history.empty?
|
14
|
+
puts 'Requested gem dosent exist in the Gemfile.lock'
|
15
|
+
else
|
16
|
+
gem_name = @history.history.first.first
|
17
|
+
commits = @history.history.first.last
|
18
|
+
|
19
|
+
puts gem_name
|
20
|
+
puts ' '
|
21
|
+
|
22
|
+
commits.each do |commit|
|
23
|
+
version_status = :up
|
24
|
+
|
25
|
+
unless commits.index(commit).zero?
|
26
|
+
current_version = commit[:version]
|
27
|
+
last_version = commits[commits.index(commit) - 1][:version]
|
28
|
+
version_status = compare_version(current_version, last_version)
|
29
|
+
end
|
30
|
+
|
31
|
+
date_string = commit[:date].strftime('%d.%m.%Y')
|
32
|
+
|
33
|
+
puts "#{status_code[version_status]} #{commit[:version]} #{date_string} #{commit[:commit]} #{commit[:author]}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/gemstory/reader.rb
CHANGED
@@ -3,39 +3,19 @@ require 'date'
|
|
3
3
|
module Gemstory
|
4
4
|
class Reader
|
5
5
|
attr_reader :logs, :line, :date, :max_gem_name_size,
|
6
|
-
:commit, :
|
6
|
+
:commit, :history, :author, :requested_gems
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@dates = []
|
8
|
+
def initialize(gems = [])
|
9
|
+
@requested_gems = gems
|
12
10
|
@max_gem_name_size = 0
|
13
|
-
@logs = `git log --reverse --follow -p -- Gemfile.lock`
|
14
|
-
@log_count = `git rev-list --all --count Gemfile.lock`
|
15
|
-
@history = {}
|
16
|
-
end
|
17
|
-
|
18
|
-
def compare_version(gem_name, version)
|
19
|
-
return :up if @history[gem_name].empty?
|
20
|
-
|
21
|
-
last_version = Gem::Version.new(@history[gem_name].last[:version])
|
22
|
-
current_version = Gem::Version.new(version)
|
23
11
|
|
12
|
+
puts 'Reading Gemfile.lock history'
|
13
|
+
@logs = `git log --reverse --follow -p -- Gemfile.lock`
|
24
14
|
|
25
|
-
|
26
|
-
:up
|
27
|
-
elsif last_version > current_version
|
28
|
-
:down
|
29
|
-
else
|
30
|
-
false
|
31
|
-
end
|
32
|
-
|
33
|
-
rescue
|
34
|
-
:up
|
15
|
+
@history = {}
|
35
16
|
end
|
36
17
|
|
37
18
|
def add_line
|
38
|
-
return unless gem?
|
39
19
|
ruby_gem = line.slice(1, 1000)
|
40
20
|
tab_length = ruby_gem[/\A */].size
|
41
21
|
|
@@ -45,26 +25,23 @@ module Gemstory
|
|
45
25
|
gem_name_part = ruby_gem.match(/(.*)(?= \()/)
|
46
26
|
|
47
27
|
if gem_name_part
|
48
|
-
gem_name = gem_name_part[0]
|
28
|
+
gem_name = gem_name_part[0]
|
49
29
|
version = ruby_gem.match(/(?<=\()(.*?)(?=\))/)[0]
|
50
30
|
else
|
51
31
|
gem_name = ruby_gem
|
52
32
|
version = nil
|
53
33
|
end
|
54
34
|
|
55
|
-
@
|
35
|
+
unless @requested_gems.empty?
|
36
|
+
return unless @requested_gems.include? gem_name
|
37
|
+
end
|
56
38
|
|
57
|
-
|
58
|
-
|
59
|
-
return unless version_status
|
39
|
+
@max_gem_name_size = gem_name.length if gem_name.length > @max_gem_name_size
|
60
40
|
|
61
41
|
@history[gem_name.to_sym] ||= []
|
62
42
|
|
63
43
|
@history[gem_name.to_sym] << { date: @date, commit: @commit,
|
64
|
-
version: version,
|
65
|
-
hierarchy: tab_length }
|
66
|
-
|
67
|
-
@history[gem_name.to_sym] = @history[gem_name.to_sym].sort_by { |changes| changes[:date] }
|
44
|
+
version: version, author: @author }
|
68
45
|
end
|
69
46
|
|
70
47
|
def gem?
|
@@ -75,54 +52,65 @@ module Gemstory
|
|
75
52
|
@line.match(/^\+ /)
|
76
53
|
end
|
77
54
|
|
78
|
-
def
|
79
|
-
matches = @line.match(/(?<=^
|
55
|
+
def author?
|
56
|
+
matches = @line.match(/(?<=^Author: )(.*)/)
|
80
57
|
|
81
58
|
if matches
|
82
|
-
@
|
83
|
-
@dates << @date
|
59
|
+
@author = matches[0]
|
84
60
|
true
|
85
61
|
else
|
86
62
|
false
|
87
63
|
end
|
88
64
|
end
|
89
65
|
|
90
|
-
def
|
91
|
-
matches = @line.match(/(?<=^
|
66
|
+
def date?
|
67
|
+
matches = @line.match(/(?<=^Date: )(.*)/)
|
92
68
|
|
93
69
|
if matches
|
94
|
-
@
|
70
|
+
@date = Date.parse(matches[0])
|
95
71
|
true
|
96
72
|
else
|
97
73
|
false
|
98
74
|
end
|
99
75
|
end
|
100
76
|
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
@
|
77
|
+
def commit?
|
78
|
+
matches = @line.match(/(?<=^commit )(.*)/)
|
79
|
+
|
80
|
+
if matches
|
81
|
+
@commit = matches[0]
|
106
82
|
true
|
107
83
|
else
|
108
84
|
false
|
109
85
|
end
|
110
86
|
end
|
111
87
|
|
112
|
-
def categorize
|
113
|
-
section
|
114
|
-
end
|
115
|
-
|
116
88
|
def call
|
117
|
-
puts '
|
89
|
+
puts 'Processing history'
|
90
|
+
puts ''
|
91
|
+
|
118
92
|
@logs.each_line do |line|
|
119
93
|
@line = line.strip
|
120
94
|
|
121
95
|
next if commit?
|
122
96
|
next if date?
|
97
|
+
next if author?
|
123
98
|
|
124
|
-
add_line if new_line?
|
99
|
+
add_line if new_line? && gem?
|
125
100
|
end
|
101
|
+
|
102
|
+
@history.each do |gem_name, commits|
|
103
|
+
sorted_commits = commits.sort_by { |commit| commit[:date] }
|
104
|
+
|
105
|
+
@history[gem_name] = sorted_commits.each_with_index.map do |commit, index|
|
106
|
+
if index.zero?
|
107
|
+
commit
|
108
|
+
else
|
109
|
+
commit unless commit[:version] == sorted_commits[index - 1][:version]
|
110
|
+
end
|
111
|
+
end.compact
|
112
|
+
end
|
113
|
+
|
126
114
|
end
|
127
115
|
end
|
128
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.0
|
4
|
+
version: 0.1.0
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -102,7 +102,9 @@ files:
|
|
102
102
|
- gemstory.gemspec
|
103
103
|
- lib/gemstory.rb
|
104
104
|
- lib/gemstory/cli.rb
|
105
|
-
- lib/gemstory/printer.rb
|
105
|
+
- lib/gemstory/printer/helpers.rb
|
106
|
+
- lib/gemstory/printer/horizontal.rb
|
107
|
+
- lib/gemstory/printer/vertical.rb
|
106
108
|
- lib/gemstory/reader.rb
|
107
109
|
- lib/gemstory/version.rb
|
108
110
|
homepage: https://github.com/EdwinRozario/gemstory
|
@@ -121,9 +123,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
123
|
version: '0'
|
122
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
125
|
requirements:
|
124
|
-
- - "
|
126
|
+
- - ">="
|
125
127
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
128
|
+
version: '0'
|
127
129
|
requirements: []
|
128
130
|
rubyforge_project:
|
129
131
|
rubygems_version: 2.7.3
|
data/lib/gemstory/printer.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Gemstory
|
2
|
-
class Printer
|
3
|
-
attr_reader :history
|
4
|
-
|
5
|
-
STATUS_CODE = { up: " \u2191 ", down: " \u2193 ", next: " \u2192 " }
|
6
|
-
|
7
|
-
def initialize(history)
|
8
|
-
@history = history
|
9
|
-
end
|
10
|
-
|
11
|
-
def call
|
12
|
-
@history.history.sort.each do |name, changes|
|
13
|
-
print "#{name}"
|
14
|
-
|
15
|
-
(@history.max_gem_name_size - name.to_s.length).times { print ' ' }
|
16
|
-
|
17
|
-
print ": "
|
18
|
-
|
19
|
-
changes.each do |change|
|
20
|
-
date_string = change[:date].strftime('%d.%m.%Y')
|
21
|
-
|
22
|
-
unless changes.index(change).zero?
|
23
|
-
print STATUS_CODE[:next]
|
24
|
-
end
|
25
|
-
|
26
|
-
print "#{change[:version]}#{STATUS_CODE[change[:change]]}(#{date_string})"
|
27
|
-
end
|
28
|
-
|
29
|
-
puts ' '
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|