gemshine 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d74f57beaaae1610da5b3238f92e17693fa7e14c
4
+ data.tar.gz: 4e5e26b486f9342c118c40b552f6d6c4d44486ef
5
+ SHA512:
6
+ metadata.gz: 2474c7421663957cd35ccc05f962f8b27ecc3b4993d18a4497ef76a9dad8d7116134511552588ff898432af0a024dd667f18a0de83380193ff3774c355f122c0
7
+ data.tar.gz: f1032515367fe3c2ef871febc252bbdb04743a18f81a55ecb559dca0cd53f747580cda47ecbbe4e2e73f73bd22f1ef89e763e3b14cd2a5af648d5ba37aff566c
@@ -0,0 +1,8 @@
1
+ .DS_Store
2
+ */**.DS_Store
3
+ ._*
4
+ .*.sw*
5
+ *~
6
+ .idea/
7
+ *.gem
8
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gemshine.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Nick Janetakis <nick.janetakis@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,80 @@
1
+ ## What is gemshine?
2
+
3
+ Gemshine recursively searches a given path and reports back both the latest version and your Gemfile's version of each gem you have in that project.
4
+
5
+ ### What problem does it solve and why is it useful?
6
+
7
+ A typical rails project might have 40 or even 80 gems and keeping track of when a gem author updates each gem is painful.
8
+
9
+ **To check for updates manually without gemshine** involves the following excruciating workflow:
10
+
11
+ 1. Open a path in your editor.
12
+ 2. Open a web browser and visit [rubygems.org](http://www.rubygems.org)
13
+ 3. Align them side by side.
14
+ 4. Goto a project's Gemfile in your editor.
15
+ 5. Search rubygems.org for the first gem in your list.
16
+ 6. Glance at the latest version and compare it to your Gemfile's version.
17
+ 7. Repeat this 1-100+ times depending on how many gems you have.
18
+ 8. Move onto the next project in your path.
19
+ 9. Repeat n times for each project you want to retrieve this information for.
20
+ 10. Get up and look in the mirror to see if you can see your eye spasm after doing this workflow only once.
21
+
22
+ **To check for updates with gemshine** involves the following awesome workflow:
23
+
24
+ 1. Open a terminal.
25
+ 2. Type `gemshine path /some/path` and enjoy the show.
26
+
27
+ ### Example usage and output
28
+
29
+ After typing: `$ gemshine path /path/to/some/rails/app`
30
+
31
+ You would see a table similar to this:
32
+
33
+ ```
34
+ +----------------------+------------+---------+
35
+ | awesomeapp |
36
+ +----------------------+------------+---------+
37
+ | Gem | Gemfile | Latest |
38
+ +----------------------+------------+---------+
39
+ | bootstrap-sass | ~> 3.0.1 | 3.1.1.1 |
40
+ | bullet | ~> 4.7.1 | 4.8.0 |
41
+ | coffee-rails | ~> 4.0.1 | 4.0.1 |
42
+ | custom_configuration | ---------> | 0.0.2 |
43
+ | dotenv-rails | ~> 0.9.0 | 0.11.1 |
44
+ | favicon_maker | ~> 1.1.0 | 1.1.2 |
45
+ | font-awesome-rails | ~> 4.0.3.1 | 4.0.3.1 |
46
+ | foreman | >= 0.63.0 | 0.67.0 |
47
+ | jquery-rails | ~> 3.0.4 | 3.1.0 |
48
+ | jquery-turbolinks | ~> 2.0.1 | 2.0.2 |
49
+ | kaminari | ~> 0.15.1 | 0.15.1 |
50
+ | meta_request | ---------> | 0.3.0 |
51
+ | pg | ---------> | 0.17.1 |
52
+ | puma | ~> 2.7.1 | 2.8.2 |
53
+ | rack-mini-profiler | ---------> | 0.9.1 |
54
+ | railroady | ~> 1.1.1 | 1.1.1 |
55
+ | rails | 4.0.3 | 4.1.0 |
56
+ | redis-rails | ~> 4.0.0 | 4.0.0 |
57
+ | sass-rails | ~> 4.0.1 | 4.0.3 |
58
+ | sdoc | ~> 0.4.0 | 0.4.0 |
59
+ | sidekiq | ~> 2.17.4 | 3.0.0 |
60
+ | sinatra | >= 1.3.0 | 1.4.5 |
61
+ | sitemap_generator | ~> 4.3.1 | 5.0.2 |
62
+ | turbolinks | ~> 1.3.1 | 2.2.2 |
63
+ | uglifier | ~> 2.4.0 | 2.5.0 |
64
+ | whenever | ---------> | 0.9.2 |
65
+ +----------------------+------------+---------+
66
+ | 26 total gems | | |
67
+ +----------------------+------------+---------+
68
+ ```
69
+
70
+ ## Installation
71
+
72
+ `gem install gemshine`
73
+
74
+ ## Commands
75
+
76
+ Here is an overview of the available commands. You can find out more information about each command and flag by simply
77
+ running `gemshine <command name> help` from your terminal. You can also type `gemshine` on its own to see a list of all commands.
78
+
79
+ - Get the latest gem versions for this project and compare them to your Gemfile's version
80
+ - `gemshine path <PROJECT_PATH>`
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ git_path = File.expand_path('../../.git', __FILE__)
4
+
5
+ if File.exist?(git_path)
6
+ $:.unshift(File.expand_path('../../lib', __FILE__))
7
+ end
8
+
9
+ require 'gemshine/cli'
10
+ Gemshine::CLI.start(ARGV)
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gemshine/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'gemshine'
8
+ spec.version = Gemshine::VERSION
9
+ spec.authors = ['Nick Janetakis']
10
+ spec.email = ['nick.janetakis@gmail.com']
11
+ spec.summary = %q{Compare your ruby project's gem versions to their latest versions.}
12
+ spec.description = %q{Enter a path and gemshine will recursively explore every ruby project and show you both the latest version and your current version of each gem in your Gemfile.}
13
+ spec.homepage = 'https://github.com/nickjj/gemshine'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'thor', '~> 0'
22
+ spec.add_dependency 'terminal-table', '~> 1.4'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.5'
25
+ spec.add_development_dependency 'rake', '~> 0'
26
+ spec.add_development_dependency 'minitest', '~> 4.7'
27
+ end
@@ -0,0 +1,5 @@
1
+ require 'gemshine/version'
2
+ require 'gemshine/cli'
3
+
4
+ module Gemshine
5
+ end
@@ -0,0 +1,23 @@
1
+ require 'thor'
2
+ require 'gemshine/command'
3
+
4
+ module Gemshine
5
+ class CLI < Thor
6
+ desc 'path PROJECT_PATH', ''
7
+ long_desc <<-D
8
+ `gemshine path myapp` will recursively search through the myapp path and report the current vs latest gem versions for all ruby projects.
9
+ D
10
+ def path(app_name)
11
+ Command.new(app_name, options).path
12
+ end
13
+
14
+ desc 'version', ''
15
+ long_desc <<-D
16
+ `gemshine --version` will print the current version.
17
+ D
18
+ def version
19
+ Command.new.version
20
+ end
21
+ map %w(-v --version) => :version
22
+ end
23
+ end
@@ -0,0 +1,126 @@
1
+ require 'terminal-table'
2
+ require 'gemshine/version'
3
+
4
+ module Gemshine
5
+ class Command
6
+ include Thor::Base
7
+ include Thor::Shell
8
+ include Thor::Actions
9
+
10
+ def initialize(app_name = '', options = {})
11
+ @app_name = app_name
12
+ @options = options
13
+
14
+ self.destination_root = Dir.pwd
15
+ @behavior = :invoke
16
+ end
17
+
18
+ def path
19
+ rows = []
20
+ gems_regex = ''
21
+ gems_total = 0
22
+
23
+ ruby_project_directories.each do |project_dir|
24
+ gemfile_path = File.join(project_dir, 'Gemfile')
25
+
26
+ if File.exists?(gemfile_path)
27
+ File.open(gemfile_path, 'r').each_line do |line|
28
+ clean_gem_line = line.strip
29
+
30
+ if clean_gem_line.start_with?('gem ')
31
+ gem_info = parse_gemfile_line(clean_gem_line)
32
+
33
+ rows << gem_info
34
+
35
+ gems_regex << "^#{gem_info[0]}$|"
36
+
37
+ gems_total += 1
38
+ end
39
+ end
40
+
41
+ rows.sort!
42
+
43
+ log_project File.basename(project_dir)
44
+
45
+ if gems_regex.empty?
46
+ puts "There are no gems defined in this project's Gemfile"
47
+ else
48
+ rubygems_data = run("gem list '#{gems_regex[0...-1]}' --remote --all", capture: true)
49
+
50
+ parse_rubygems_response rubygems_data, rows
51
+
52
+ table = Terminal::Table.new title: File.basename(project_dir), headings: %w(Gem Gemfile Latest) do |t|
53
+ t.rows = rows
54
+ t.add_separator
55
+ t.add_row ["#{gems_total} total gems", '', '']
56
+ end
57
+
58
+ puts
59
+ puts table
60
+ end
61
+
62
+ rows = []
63
+ gems_regex = ''
64
+ gems_total = 0
65
+ end
66
+ end
67
+ end
68
+
69
+ def version
70
+ puts "Gemshine version #{VERSION}"
71
+ end
72
+
73
+ private
74
+
75
+ def parse_gemfile_line(gem_line)
76
+ line_parts = gem_line.split(',')
77
+ gem_name = line_parts[0][5...-1]
78
+
79
+ if line_parts[1]
80
+ might_be_version = line_parts[1].strip
81
+ else
82
+ might_be_version = ''
83
+ end
84
+
85
+ if might_be_version && (might_be_version.start_with?('"') || might_be_version.start_with?("'"))
86
+ gem_version = line_parts[1][2...-1]
87
+ else
88
+ gem_version = '--------->'
89
+ end
90
+
91
+ [gem_name, gem_version, 'N/A']
92
+ end
93
+
94
+ def parse_rubygems_response(rubygems_data, gemlist_rows)
95
+ rubygems_parts = rubygems_data.split("\n")
96
+
97
+ rubygems_parts.to_enum.each_with_index do |gem_data, i|
98
+ gem_data_parts = gem_data.split
99
+
100
+ might_be_latest_gem_version = gem_data_parts[1][1..-1].strip
101
+
102
+ if might_be_latest_gem_version.end_with?(',')
103
+ latest_gem_version = might_be_latest_gem_version[0...-1]
104
+ else
105
+ latest_gem_version = might_be_latest_gem_version
106
+ end
107
+
108
+ gemlist_rows[i][2] = latest_gem_version
109
+ end
110
+ end
111
+
112
+ def ruby_project_directories
113
+ rails_gemfiles = run("find #{@app_name} -type f -name Gemfile", capture: true)
114
+ gemfile_paths = rails_gemfiles.split("\n")
115
+
116
+ gemfile_paths.map { |gemfile| File.dirname(gemfile) }
117
+ end
118
+
119
+ def log_project(project_name)
120
+ puts
121
+ say_status 'info', "\e[1mGathering the latest gem versions for:\e[0m", :yellow
122
+ say_status 'project', project_name, :cyan
123
+ puts
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,3 @@
1
+ module Gemshine
2
+ VERSION = '0.1.2'
3
+ end
@@ -0,0 +1,45 @@
1
+ require_relative '../test_helper'
2
+
3
+ class TestCLI < Minitest::Unit::TestCase
4
+ include Gemshine::Test
5
+
6
+ def test_path
7
+ create_dummy_gemfile
8
+
9
+ out, err = capture_subprocess_io do
10
+ gemshine 'path Gemfile'
11
+ end
12
+
13
+ assert_match /4 total gems/, out
14
+
15
+ system 'rm -rf /tmp/gemshine'
16
+ end
17
+
18
+ def test_version
19
+ out, err = capture_subprocess_io do
20
+ gemshine 'version'
21
+ end
22
+
23
+ assert_match /Gemshine/, out
24
+ end
25
+
26
+ private
27
+
28
+ def create_dummy_gemfile
29
+ gems = []
30
+ gems << 'gem "rails", "~> 4.1.0"'
31
+ gems << ' gem "sidekiq", "~> 2.17.4"'
32
+ gems << 'gem "whenever", require: false'
33
+ gems << 'gemwhenever",,,,d,,e'
34
+ gems << 'gem "sdoc", "~> 0.4.0", require: false'
35
+ gems << ' '
36
+
37
+ gemfile_path = "#{TEST_PATH}/Gemfile"
38
+
39
+ system "mkdir -p #{TEST_PATH}"
40
+
41
+ File.open(gemfile_path, 'w+') do |f|
42
+ gems.each { |element| f.puts(element) }
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,16 @@
1
+ require 'minitest/autorun'
2
+ require 'securerandom'
3
+
4
+ module Gemshine
5
+ module Test
6
+ BINARY_PATH = File.absolute_path('../../bin/gemshine',__FILE__)
7
+ TEST_PATH = '/tmp/gemshine'
8
+
9
+ def gemshine(command)
10
+ cmd, project_path = command.split(' ')
11
+ command = "#{cmd} #{TEST_PATH}/#{project_path}" if command.include?(' ')
12
+
13
+ system "#{BINARY_PATH} #{command}"
14
+ end
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gemshine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Nick Janetakis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-25 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
+ 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: terminal-table
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.7'
83
+ description: Enter a path and gemshine will recursively explore every ruby project
84
+ and show you both the latest version and your current version of each gem in your
85
+ Gemfile.
86
+ email:
87
+ - nick.janetakis@gmail.com
88
+ executables:
89
+ - gemshine
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/gemshine
99
+ - gemshine.gemspec
100
+ - lib/gemshine.rb
101
+ - lib/gemshine/cli.rb
102
+ - lib/gemshine/command.rb
103
+ - lib/gemshine/version.rb
104
+ - test/integration/cli_test.rb
105
+ - test/test_helper.rb
106
+ homepage: https://github.com/nickjj/gemshine
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.0
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Compare your ruby project's gem versions to their latest versions.
130
+ test_files:
131
+ - test/integration/cli_test.rb
132
+ - test/test_helper.rb