magellan-cli 0.4.2 → 0.4.3
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/lib/magellan/cli.rb +1 -0
- data/lib/magellan/cli/command.rb +9 -1
- data/lib/magellan/cli/gem_update.rb +40 -0
- data/lib/magellan/cli/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64e910eff60c172a577262ba69812c7481edbdc6
|
4
|
+
data.tar.gz: fd822d76a2c83851458bd082ea75f782ee265d01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ce72cedf4fc3d2a0cf6a726e28d3e31a4eee1050716b99d84cfe366a8f92a538875d0a90243743be5da79f7bb3320e100af25538e0bdb157184d769e63438f7
|
7
|
+
data.tar.gz: 6d14e206e510653904718dd5fb6adba8200a138caa9814f5d513a997f8f025a6a4ea3e365b403f556d89f83dc7e8069e834000525d64fd1942edf64139aa6d31
|
data/Gemfile.lock
CHANGED
data/lib/magellan/cli.rb
CHANGED
data/lib/magellan/cli/command.rb
CHANGED
@@ -12,6 +12,7 @@ module Magellan
|
|
12
12
|
# override Thor::Base.start method
|
13
13
|
def start(given_args = ARGV, config = {})
|
14
14
|
Magellan::Cli::FileAccess.ensure_config_dir
|
15
|
+
verbose = ARGV.include?("-V") || ARGV.include?("--verbose")
|
15
16
|
# class_options verbose and version are defined in Magellan::Cli::Base
|
16
17
|
if (ARGV == ["-v"] || ARGV == ["--version"])
|
17
18
|
log_info(File.basename($0) << " " << Magellan::Cli::VERSION)
|
@@ -19,6 +20,13 @@ module Magellan
|
|
19
20
|
elsif ARGV.include?("-v") || ARGV.include?("--version")
|
20
21
|
log_info(File.basename($0) << " " << Magellan::Cli::VERSION)
|
21
22
|
end
|
23
|
+
begin
|
24
|
+
GemUpdate.search do |name, v|
|
25
|
+
log_info("\n\e[32mNew version available. try `gem install #{name} -v #{v}`\e[0m\n")
|
26
|
+
end
|
27
|
+
rescue => e
|
28
|
+
log_verbose("[#{e.class}] #{e.message}", verbose)
|
29
|
+
end
|
22
30
|
begin
|
23
31
|
super(given_args, config)
|
24
32
|
rescue Magellan::Cli::Error => e
|
@@ -26,7 +34,7 @@ module Magellan
|
|
26
34
|
block_given? ? yield(e) : exit(1)
|
27
35
|
rescue => e
|
28
36
|
log_error("[#{e.class}] #{e.message}")
|
29
|
-
log_verbose(" " << e.backtrace.join("\n "),
|
37
|
+
log_verbose(" " << e.backtrace.join("\n "), verbose)
|
30
38
|
block_given? ? yield(e) : exit(1)
|
31
39
|
end
|
32
40
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "magellan/cli"
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'active_support/core_ext/string/inflections'
|
5
|
+
|
6
|
+
module Magellan
|
7
|
+
module Cli
|
8
|
+
|
9
|
+
module GemUpdate
|
10
|
+
LAST_UPDATE_SEARCHED_AT = "last_update_searched_at".freeze
|
11
|
+
UPDATE_SEARCH_INTERVAL = 1 * 24 * 60 * 60 # 1 day
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
def search
|
16
|
+
t = FileAccess.load_selections[LAST_UPDATE_SEARCHED_AT]
|
17
|
+
return nil if t && (Time.now < Time.parse(t) + UPDATE_SEARCH_INTERVAL)
|
18
|
+
name = "magellan-cli"
|
19
|
+
version = `gem search -r #{name} -q --no-details --versions`.scan(/\((.*)\)/).flatten.first
|
20
|
+
FileAccess.update_selections({LAST_UPDATE_SEARCHED_AT => Time.now.to_s})
|
21
|
+
if version
|
22
|
+
curr = Gem::Version.new(Magellan::Cli::VERSION)
|
23
|
+
last = Gem::Version.new(version)
|
24
|
+
if last > curr
|
25
|
+
yield(name, version) if block_given?
|
26
|
+
return version
|
27
|
+
else
|
28
|
+
# puts "#{curr} is newer than equal #{last}"
|
29
|
+
end
|
30
|
+
else
|
31
|
+
# puts "no gem version found for #{name}"
|
32
|
+
end
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/magellan/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magellan-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm2000
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/magellan/cli/direct.rb
|
181
181
|
- lib/magellan/cli/errors.rb
|
182
182
|
- lib/magellan/cli/file_access.rb
|
183
|
+
- lib/magellan/cli/gem_update.rb
|
183
184
|
- lib/magellan/cli/http.rb
|
184
185
|
- lib/magellan/cli/i18n.rb
|
185
186
|
- lib/magellan/cli/locales/en.yml
|