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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 009216b27b5c764caacaeaaa42f148d3bb86b732
4
- data.tar.gz: d4a4f83b29620252207111c4486ed04975b8672d
3
+ metadata.gz: 64e910eff60c172a577262ba69812c7481edbdc6
4
+ data.tar.gz: fd822d76a2c83851458bd082ea75f782ee265d01
5
5
  SHA512:
6
- metadata.gz: 2e667e5b32b6c97603f14d18aa8f557086cfa631d8788b990658f8252f02e3ee5fc530c5b098bb0aa4811dbef12dc1638dc992bb7c10d06ea8c8176a2ab2797a
7
- data.tar.gz: 194ab3a837e72d02f7da41c6087ef79bc58dafac572d5fba31f54dca1c4c78a8aa333deb04e36af8e90d04db4abe2170bbfe4fd1fc8cc13ca8ef4cdd9d02b7b4
6
+ metadata.gz: 0ce72cedf4fc3d2a0cf6a726e28d3e31a4eee1050716b99d84cfe366a8f92a538875d0a90243743be5da79f7bb3320e100af25538e0bdb157184d769e63438f7
7
+ data.tar.gz: 6d14e206e510653904718dd5fb6adba8200a138caa9814f5d513a997f8f025a6a4ea3e365b403f556d89f83dc7e8069e834000525d64fd1942edf64139aa6d31
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magellan-cli (0.4.2)
4
+ magellan-cli (0.4.3)
5
5
  activesupport (~> 4.1.4)
6
6
  groovenauts-thor
7
7
  httpclient (~> 2.5)
data/lib/magellan/cli.rb CHANGED
@@ -22,6 +22,7 @@ module Magellan
22
22
  }.freeze
23
23
 
24
24
  autoload :ReferenceGenerator, "magellan/cli/reference_generator"
25
+ autoload :GemUpdate, "magellan/cli/gem_update"
25
26
 
26
27
  class << self
27
28
  attr_accessor :last_result
@@ -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 "), ARGV.include?("-V") || ARGV.include?("--verbose"))
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
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  module Cli
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
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.2
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-22 00:00:00.000000000 Z
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