gemstory 0.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f4dfe20d0bcd65da9fa41ca0dcb5eaaf827e153f1f17e12d9fd899f0520b4457
4
+ data.tar.gz: 65ffab20ccc2ff9fb35e79c8f93cdfe43ab956f1ae13e70db5a9c412f0e3cd70
5
+ SHA512:
6
+ metadata.gz: 2c0d55bae3466456c9a5e2abc14e95820fc59ab04517dcf077cc404a089fa7df4a450aa16558be2f61f4fb8d709521fa3d090ae0cbe4648f8a2efefcc54cb665
7
+ data.tar.gz: b97b88ce2a49a308aab64564d2151fc8248cf9e9626bee03c080d39787785b031558523691a51aff22ec2c319d73c595d4e32e0af4e094fe581dccbe67e62bc3
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at edwin@boost.co.nz. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in gemstory.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gemstory (0.1.0.beta1)
5
+ thor (~> 0.20.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.2)
11
+ diff-lcs (1.3)
12
+ method_source (0.9.0)
13
+ pry (0.11.3)
14
+ coderay (~> 1.1.0)
15
+ method_source (~> 0.9.0)
16
+ rake (10.5.0)
17
+ rspec (3.7.0)
18
+ rspec-core (~> 3.7.0)
19
+ rspec-expectations (~> 3.7.0)
20
+ rspec-mocks (~> 3.7.0)
21
+ rspec-core (3.7.1)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-expectations (3.7.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.7.0)
26
+ rspec-mocks (3.7.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-support (3.7.1)
30
+ thor (0.20.0)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.16)
37
+ gemstory!
38
+ pry (~> 0.11.3)
39
+ rake (~> 10.0)
40
+ rspec (~> 3.7)
41
+
42
+ BUNDLED WITH
43
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Edwin Rozario
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,43 @@
1
+ # Gemstory
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/gemstory`. 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 'gemstory'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install gemstory
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Gemstory project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gemstory/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gemstory"
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(__FILE__)
data/bin/gemstory ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby -wU
2
+
3
+ require 'gemstory'
4
+
5
+ Gemstory::Cli.new(ARGV).execute
data/bin/setup ADDED
@@ -0,0 +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
data/gemstory.gemspec ADDED
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gemstory/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'gemstory'
8
+ spec.version = Gemstory::VERSION
9
+ spec.authors = ['Edwin Rozario']
10
+ spec.email = ['rozarioed@gmail.com']
11
+
12
+ spec.summary = %q{CLI tool to map the history of gems in a project}
13
+ spec.description = %q{Version changes of all the Gems in a project that has a Gemfile.lock is tracked through time}
14
+ spec.homepage = "https://github.com/EdwinRozario/gemstory"
15
+ spec.license = 'MIT'
16
+
17
+ spec.default_executable = 'gemstory'
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
29
+ f.match(%r{^(test|spec|features)/})
30
+ end
31
+ # spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
33
+ #spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_runtime_dependency 'thor', '~> 0.20.0'
37
+ # spec.add_runtime_dependency 'progress'
38
+
39
+ spec.add_development_dependency 'bundler', '~> 1.16'
40
+ spec.add_development_dependency 'rake', '~> 10.0'
41
+ spec.add_development_dependency 'rspec', '~> 3.7'
42
+ spec.add_development_dependency 'pry', '~> 0.11.3'
43
+ end
44
+
@@ -0,0 +1,17 @@
1
+ require 'thor'
2
+
3
+ module Gemstory
4
+ class Cli < Thor
5
+ attr_reader :history
6
+
7
+ def initialize(argv)
8
+ @history = Gemstory::Reader.new
9
+ end
10
+
11
+ desc "execute", "Will print the history of your gems"
12
+ def execute
13
+ @history.call
14
+ Gemstory::Printer.new(@history).call
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,130 @@
1
+ require 'date'
2
+ # require 'progress'
3
+
4
+ module Gemstory
5
+ class Reader
6
+ attr_reader :logs, :line, :date, :max_gem_name_size,
7
+ :commit, :section, :history, :dates, :log_count
8
+
9
+ SECTIONS = %w[GEM PLATFORMS DEPENDENCIES BUNDLED\ WITH].freeze
10
+
11
+ def initialize
12
+ @dates = []
13
+ @max_gem_name_size = 0
14
+ @logs = `git log --reverse --follow -p -- Gemfile.lock`
15
+ @log_count = `git rev-list --all --count Gemfile.lock`
16
+ @history = {}
17
+ end
18
+
19
+ def compare_version(gem_name, version)
20
+ return :up if @history[gem_name].empty?
21
+
22
+ last_version = Gem::Version.new(@history[gem_name].last[:version])
23
+ current_version = Gem::Version.new(version)
24
+
25
+
26
+ if last_version < current_version
27
+ :up
28
+ elsif last_version > current_version
29
+ :down
30
+ else
31
+ false
32
+ end
33
+
34
+ rescue
35
+ :up
36
+ end
37
+
38
+ def add_line
39
+ return unless gem?
40
+ ruby_gem = line.slice(1, 1000)
41
+ tab_length = ruby_gem[/\A */].size
42
+
43
+ return unless tab_length == 4
44
+
45
+ ruby_gem.strip!
46
+ gem_name_part = ruby_gem.match(/(.*)(?= \()/)
47
+
48
+ if gem_name_part
49
+ gem_name = gem_name_part[0]
50
+ version = ruby_gem.match(/(?<=\()(.*?)(?=\))/)[0]
51
+ else
52
+ gem_name = ruby_gem
53
+ version = nil
54
+ end
55
+
56
+ @max_gem_name_size = gem_name.length if gem_name.length > @max_gem_name_size
57
+
58
+ version_status = compare_version(gem_name.to_sym, version)
59
+
60
+ return unless version_status
61
+
62
+ @history[gem_name.to_sym] ||= []
63
+
64
+ @history[gem_name.to_sym] << { date: @date, commit: @commit,
65
+ version: version, change: version_status,
66
+ hierarchy: tab_length }
67
+
68
+ @history[gem_name.to_sym] = @history[gem_name.to_sym].sort_by { |changes| changes[:date] }
69
+ end
70
+
71
+ def gem?
72
+ @line.match(/(.*)(\()(.*?)(\))/)
73
+ end
74
+
75
+ def new_line?
76
+ @line.match(/^\+ /)
77
+ end
78
+
79
+ def date?
80
+ matches = @line.match(/(?<=^Date: )(.*)/)
81
+
82
+ if matches
83
+ @date = Date.parse(matches[0])
84
+ @dates << @date
85
+ true
86
+ else
87
+ false
88
+ end
89
+ end
90
+
91
+ def commit?
92
+ matches = @line.match(/(?<=^commit )(.*)/)
93
+
94
+ if matches
95
+ @commit = matches[0]
96
+ true
97
+ else
98
+ false
99
+ end
100
+ end
101
+
102
+ def section?
103
+ sections = SECTIONS.map { |section| section if line.include? section }.compact
104
+
105
+ unless sections.empty?
106
+ @section = sections.first
107
+ true
108
+ else
109
+ false
110
+ end
111
+ end
112
+
113
+ def categorize
114
+ section
115
+ end
116
+
117
+ def call
118
+ # @logs.each_line.with_progress('Reading Gemfile.lock history') do |line|
119
+ puts 'Reading Gemfile.lock history'
120
+ @logs.each_line do |line|
121
+ @line = line.strip
122
+
123
+ next if commit?
124
+ next if date?
125
+
126
+ add_line if new_line?
127
+ end
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,3 @@
1
+ module Gemstory
2
+ VERSION = "0.1.0.beta1"
3
+ end
data/lib/gemstory.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'gemstory/version'
2
+ require 'gemstory/reader'
3
+ require 'gemstory/printer'
4
+ require 'gemstory/cli'
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gemstory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.beta1
5
+ platform: ruby
6
+ authors:
7
+ - Edwin Rozario
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.20.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.20.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.11.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.11.3
83
+ description: Version changes of all the Gems in a project that has a Gemfile.lock
84
+ is tracked through time
85
+ email:
86
+ - rozarioed@gmail.com
87
+ executables:
88
+ - console
89
+ - gemstory
90
+ - setup
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".gitignore"
95
+ - ".rspec"
96
+ - ".travis.yml"
97
+ - CODE_OF_CONDUCT.md
98
+ - Gemfile
99
+ - Gemfile.lock
100
+ - LICENSE.txt
101
+ - README.md
102
+ - Rakefile
103
+ - bin/console
104
+ - bin/gemstory
105
+ - bin/setup
106
+ - gemstory.gemspec
107
+ - lib/gemstory.rb
108
+ - lib/gemstory/cli.rb
109
+ - lib/gemstory/printer.rb
110
+ - lib/gemstory/reader.rb
111
+ - lib/gemstory/version.rb
112
+ homepage: https://github.com/EdwinRozario/gemstory
113
+ licenses:
114
+ - MIT
115
+ metadata:
116
+ allowed_push_host: https://rubygems.org
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">"
129
+ - !ruby/object:Gem::Version
130
+ version: 1.3.1
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.7.3
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: CLI tool to map the history of gems in a project
137
+ test_files: []