gemshine 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25bf278d9f7c5b0976b41233add9f68ebc420a0d
4
- data.tar.gz: f55db9aab0136e8bad032dc901c15b5ee4f77429
3
+ metadata.gz: 9fa09e476c4fe67b9cd33fa0d06b16c88f6469ac
4
+ data.tar.gz: 059c1ab86f61f15e2e0f60201b68d777264d1165
5
5
  SHA512:
6
- metadata.gz: dca0d8ecb13e13369ab4859b8b1b9120b6dd9c857f9634d88c2e835b92d81fe9e1c668a81e783b560b47002b25df1bcb11893d11318fac80d1892280a061f109
7
- data.tar.gz: 88b07d2b854000a73d6b8eaea8edddefe11322d4f78ed7bb08846f0d2f6e93b72cb11b38dd7c8da94fa9249304df83a9a318d6bf7c7fb6afc721ce96a9a35e03
6
+ metadata.gz: 8052d8b19b87f12e9a0533f19b2a9d25f758f13eb683dc292b3a5015a639ecaa83a084a2cdf2f0c4e2f6c45c933a381fc7580c74b382f8f04d576c7c80972a1b
7
+ data.tar.gz: 87b6b361ada593885405245deb9c900227d28a54093149c40c8ea2d493f6828ffe2f4f0677fe55e12d62f0568e1b740d89fe91fe02f6f3b5b7935e5e630b1ded
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ## What is gemshine?
2
2
 
3
- Gemshine recursively searches a given path for all ruby projects and reports back a table showing the latest version of each gem you have installed in addition the version supplied by that project's Gemfile.
3
+ Gemshine recursively searches a given path for all ruby projects and reports back a table showing the latest version of each gem you have installed in addition to the version you have installed locally for that project.
4
4
 
5
5
  ### What problem does it solve and why is it useful?
6
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.
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. `bundle outdated` partly solves this problem but not quite.
8
8
 
9
9
  **To check for updates manually without gemshine** involves the following excruciating workflow:
10
10
 
@@ -19,6 +19,14 @@ A typical rails project might have 40 or even 80 gems and keeping track of when
19
19
  9. Repeat n times for each project you want to retrieve this information for.
20
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
21
 
22
+ **To check for updates with bundle outdated instead of gemshine** involves the following boring workflow:
23
+
24
+ 1. Open a terminal.
25
+ 2. `cd` into a directory containing a Gemfile and type `bundle outdated`.
26
+ 3. Mentally parse out the gems you probably don't care about (dependencies of dependencies).
27
+ 4. Repeat step 2 and 3 until you are done checking all of your projects.
28
+ - This is annoying when you have 15 rails projects to go through.
29
+
22
30
  **To check for updates with gemshine** involves the following awesome workflow:
23
31
 
24
32
  1. Open a terminal.
@@ -31,40 +39,34 @@ After typing: `$ gemshine path /path/to/some/rails/app`
31
39
  You would see a table similar to this:
32
40
 
33
41
  ```
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
- +----------------------+------------+---------+
42
+ +-------------------------+-----------------+----------------+-----------------+
43
+ | awesomeapp |
44
+ +-------------------------+-----------------+----------------+-----------------+
45
+ | Gem | Defined | Installed | Latest |
46
+ +-------------------------+-----------------+----------------+-----------------+
47
+ | bootstrap-sass | ~> 3.0.1 | 3.0.3.0 | 3.1.1.1 |
48
+ | bullet | ~> 4.7.1 | 4.7.1 | 4.8.0 |
49
+ | dotenv | | 0.9.0 | 0.11.1 |
50
+ | dotenv-rails | ~> 0.9.0 | 0.9.0 | 0.11.1 |
51
+ | favicon_maker | ~> 1.1.0 | 1.1.1 | 1.1.2 |
52
+ | font-awesome-rails | ~> 4.0.3.1 | 4.0.3.1 | 4.0.3.2 |
53
+ | foreman | | 0.63.0 | 0.67.0 |
54
+ | jquery-rails | ~> 3.0.4 | 3.0.4 | 3.1.0 |
55
+ | meta_request | | 0.2.8 | 0.3.0 |
56
+ | puma | ~> 2.7.1 | 2.7.1 | 2.8.2 |
57
+ | rack-mini-profiler | | 0.9.0 | 0.9.1 |
58
+ | rails | = 4.0.2 | 4.0.2 | 4.1.0 |
59
+ | sass | | 3.2.14 | 3.3.6 |
60
+ | sass-rails | ~> 4.0.1 | 4.0.1 | 4.0.3 |
61
+ | sidekiq | ~> 2.17.4 | 2.17.4 | 3.0.0 |
62
+ | sinatra | | 1.4.4 | 1.4.5 |
63
+ | sitemap_generator | ~> 4.3.1 | 4.3.1 | 5.0.2 |
64
+ | turbolinks | ~> 1.3.1 | 1.3.1 | 2.2.2 |
65
+ | uglifier | ~> 2.4.0 | 2.4.0 | 2.5.0 |
66
+ | whenever | | 0.9.0 | 0.9.2 |
67
+ +-------------------------+-----------------+----------------+-----------------+
68
+ | 20 outdated gems | | | |
69
+ +-------------------------+-----------------+----------------+-----------------+
68
70
  ```
69
71
 
70
72
  ## Installation
@@ -76,5 +78,5 @@ You would see a table similar to this:
76
78
  Here is an overview of the available commands. You can find out more information about each command and flag by simply
77
79
  running `gemshine <command name> help` from your terminal. You can also type `gemshine` on its own to see a list of all commands.
78
80
 
79
- - Get the latest gem versions for this project and compare them to your Gemfile's version
81
+ - Get the latest gem versions for this project and compare them to your installed version
80
82
  - `gemshine path <PROJECT_PATH>`
data/lib/gemshine/cli.rb CHANGED
@@ -5,7 +5,7 @@ module Gemshine
5
5
  class CLI < Thor
6
6
  desc 'path PROJECT_PATH', ''
7
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.
8
+ `gemshine path myapp` will recursively search through the myapp path and report the installed vs latest gem versions for all ruby projects.
9
9
  D
10
10
  def path(app_name)
11
11
  Command.new(app_name, options).path
@@ -7,6 +7,10 @@ module Gemshine
7
7
  include Thor::Shell
8
8
  include Thor::Actions
9
9
 
10
+ MSG_MISSING_GEMFILE = 'A Gemfile could not be found for:'
11
+ MSG_GATHER_OUTDATED = 'Gathering outdated top level gems for:'
12
+ MSG_UP_TO_DATE = 'Every top level gem is up to date for this project.'
13
+
10
14
  def initialize(app_name = '', options = {})
11
15
  @app_name = app_name
12
16
  @options = options
@@ -16,110 +20,125 @@ module Gemshine
16
20
  end
17
21
 
18
22
  def path
19
- rows = []
20
- gems_regex = ''
21
- gems_total = 0
22
-
23
23
  ruby_project_directories.each do |project_dir|
24
24
  gemfile_path = File.join(project_dir, 'Gemfile')
25
+ project_name = File.basename(project_dir)
25
26
 
26
- if File.exists?(gemfile_path)
27
- File.open(gemfile_path, 'r').each_line do |line|
28
- clean_gem_line = line.strip
27
+ log_project File.basename(project_dir)
29
28
 
30
- if clean_gem_line.start_with?('gem ')
31
- gem_info = parse_gemfile_line(clean_gem_line)
29
+ unless File.exists?(gemfile_path)
30
+ log_missing project_name
31
+ next
32
+ end
32
33
 
33
- rows << gem_info
34
+ gem_table build_gem_list(bundle_outdated(project_dir), project_dir), project_name
35
+ end
36
+ end
37
+
38
+ def version
39
+ puts "Gemshine version #{VERSION}"
40
+ end
34
41
 
35
- gems_regex << "^#{gem_info[0]}$|"
42
+ private
36
43
 
37
- gems_total += 1
38
- end
39
- end
44
+ def ruby_project_directories
45
+ gemfiles = run("find #{@app_name} -type f -name Gemfile", capture: true)
46
+ gemfile_paths = gemfiles.split("\n")
40
47
 
41
- rows.sort!
48
+ gemfile_paths.map { |gemfile| File.dirname(gemfile) }
49
+ end
42
50
 
43
- log_project File.basename(project_dir)
51
+ def bundle_outdated(path)
52
+ run "cd #{path} && bundle outdated && cd -", capture: true
53
+ end
44
54
 
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)
55
+ def build_gem_list(data, project_dir)
56
+ plucked_gems(data, project_dir).map! { |gem| parse_gem_data(gem) }
57
+ end
49
58
 
50
- parse_rubygems_response rubygems_data, rows
59
+ def plucked_gems(bundle_data, project_dir)
60
+ lines = bundle_data.split("\n")
51
61
 
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
62
+ gemfile_path = File.join(project_dir, 'Gemfile')
63
+ gemspec_path = Dir.glob("#{project_dir}/*.gemspec").first
64
+ gemfile_contents = IO.read(gemfile_path)
57
65
 
58
- puts
59
- puts table
60
- end
66
+ gemspec_path ? gemspec_contents = IO.read(gemspec_path) : gemspec_contents = ''
61
67
 
62
- rows = []
63
- gems_regex = ''
64
- gems_total = 0
68
+ lines.keep_if do |line|
69
+ line.strip!
70
+ line.start_with?('*')
65
71
  end
66
- end
67
- end
68
72
 
69
- def version
70
- puts "Gemshine version #{VERSION}"
71
- end
73
+ lines.keep_if do |line|
74
+ parts = line.split
72
75
 
73
- private
76
+ parts[0] == '*' ? is_gem_line = true : is_gem_line = false
74
77
 
75
- def parse_gemfile_line(gem_line)
76
- line_parts = gem_line.split(',')
77
- gem_name = line_parts[0][5...-1]
78
+ is_gem_line ? name = parts[1][0..-1] : name = ''
78
79
 
79
- if line_parts[1]
80
- might_be_version = line_parts[1].strip
81
- else
82
- might_be_version = ''
83
- end
80
+ expression = /\b#{name}\b/
84
81
 
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 = '--------->'
82
+ is_gem_line && gemfile_contents.match(expression) || gemspec_contents.match(expression)
89
83
  end
90
84
 
91
- [gem_name, gem_version, 'N/A']
85
+ lines.map! { |line| line[2..-1] }
92
86
  end
93
87
 
94
- def parse_rubygems_response(rubygems_data, gemlist_rows)
95
- rubygems_parts = rubygems_data.split("\n")
88
+ def parse_gem_data(line)
89
+ parts = line.split
90
+
91
+ name = parts[0]
92
+ ver_installed = parts[3][0...-1]
93
+ ver_latest = parts[1][1..-1]
94
+ ver_specific = parts[4]
95
+ ver_defined = ''
96
+ ver_operator = ''
97
+ ver_locked = ''
98
+
99
+ if ver_specific
100
+ ver_operator = parts[6][1..-1]
101
+ ver_locked = parts[7][0...-1]
102
+ ver_defined = "#{ver_operator} #{ver_locked}"
103
+ end
96
104
 
97
- rubygems_parts.to_enum.each_with_index do |gem_data, i|
98
- gem_data_parts = gem_data.split
105
+ [name, ver_defined, ver_installed, ver_latest]
106
+ end
99
107
 
100
- might_be_latest_gem_version = gem_data_parts[1][1..-1].strip
108
+ def gem_table(rows, title)
109
+ if rows.size == 0
110
+ log_up_to_date
111
+ return
112
+ end
101
113
 
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
114
+ rows.sort!
107
115
 
108
- gemlist_rows[i][2] = latest_gem_version
116
+ table = Terminal::Table.new title: title, headings: %w(Gem Defined Installed Latest), style: {width: 80} do |t|
117
+ t.rows = rows
118
+ t.add_separator
119
+ t.add_row ["#{rows.size} outdated gems", '', '', '']
109
120
  end
121
+
122
+ puts
123
+ puts table
110
124
  end
111
125
 
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")
126
+ def log_project(project_name)
127
+ puts
128
+ say_status 'info', "\e[1m#{MSG_GATHER_OUTDATED}\e[0m", :yellow
129
+ say_status 'project', project_name, :cyan
130
+ puts
131
+ end
115
132
 
116
- gemfile_paths.map { |gemfile| File.dirname(gemfile) }
133
+ def log_up_to_date
134
+ puts
135
+ say_status 'nice', "#{MSG_UP_TO_DATE}", :magenta
117
136
  end
118
137
 
119
- def log_project(project_name)
138
+ def log_missing(project_name)
120
139
  puts
121
- say_status 'info', "\e[1mGathering the latest gem versions for:\e[0m", :yellow
122
- say_status 'project', project_name, :cyan
140
+ say_status 'skip', "\e[1m#{MSG_MISSING_GEMFILE}\e[0m", :red
141
+ say_status 'project', project_name, :yellow
123
142
  puts
124
143
  end
125
144
  end
@@ -1,3 +1,3 @@
1
1
  module Gemshine
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -4,15 +4,11 @@ class TestCLI < Minitest::Unit::TestCase
4
4
  include Gemshine::Test
5
5
 
6
6
  def test_path
7
- create_dummy_gemfile
8
-
9
7
  out, err = capture_subprocess_io do
10
8
  gemshine 'path Gemfile'
11
9
  end
12
10
 
13
- assert_match /4 total gems/, out
14
-
15
- system "rm -rf #{TEST_PATH}"
11
+ assert_match /Gathering/, out
16
12
  end
17
13
 
18
14
  def test_version
@@ -22,24 +18,4 @@ class TestCLI < Minitest::Unit::TestCase
22
18
 
23
19
  assert_match /Gemshine/, out
24
20
  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
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemshine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Janetakis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor