rbcli 0.1.5 → 0.1.6
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/README.md +6 -10
- data/examples/mytool +2 -2
- data/lib/rbcli/autoupdate/autoupdate.rb +5 -5
- data/lib/rbcli/autoupdate/gem_updater.rb +1 -2
- data/lib/rbcli/autoupdate/github_updater.rb +1 -2
- data/lib/rbcli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e1fdf57f967275989d85da3af7efe4be4548c19355a38ad413b5a3eda93df29
|
4
|
+
data.tar.gz: 021efa89a89181c7ec705250824a8c6c3fc1009d9dcbcf5b3480d66f1996d47d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35c7c37d74f54d15ca6393e5a6f9f73b34bbc957a63ff5cd5b0d5e62fdf8643e19a23ec70adab4088b2816c45329b31c309346939726c22f89de491e33b022e
|
7
|
+
data.tar.gz: deb5e7bb66af850aa3278f40826ff506302bf4ae9817cf63f8dac23a6bd0fd9db924ea684aa7ea10ef628b7fbcb6ee6893480639c3f995648423d1c05069569d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -82,8 +82,8 @@ Rbcli::Configurate.me do
|
|
82
82
|
|
83
83
|
option :name, 'Give me your name', type: :string, default: 'Foo', required: false, permitted: ['Jack', 'Jill'] # (Optional, Multiple) Add a global CLI parameter. Supported types are :string, :boolean, :integer, :float, :date, and :io. Can be called multiple times.
|
84
84
|
|
85
|
-
autoupdate github_repo: 'akhoury6/rbcli', access_token: nil, enterprise_hostname: nil,
|
86
|
-
autoupdate gem: 'rbcli',
|
85
|
+
autoupdate github_repo: 'akhoury6/rbcli', access_token: nil, enterprise_hostname: nil, force_update: false # (Optional) Check for updates to this application at a GitHub repo. The repo must use version number tags in accordance to best practices: https://help.github.com/articles/creating-releases/
|
86
|
+
autoupdate gem: 'rbcli', force_update: false # (Optional) Check for updates to this application through RubyGems.org.
|
87
87
|
|
88
88
|
default_action do |opts| # (Optional) The default code to execute when no subcommand is given. If not present, the help is shown (same as -h)
|
89
89
|
puts "Hello, #{opts[:name]}."
|
@@ -374,10 +374,10 @@ Two sources are currently supported: Github (including Enterprise) and RubyGems.
|
|
374
374
|
|
375
375
|
The GitHub update check works best when paired with GitHub's best practices on releases. See here: https://help.github.com/articles/creating-releases/
|
376
376
|
|
377
|
-
RBCli will check your github repo's tags and compare that version number with one
|
377
|
+
RBCli will check your github repo's tags and compare that version number with one you configured Rbcli with.
|
378
378
|
|
379
379
|
```ruby
|
380
|
-
autoupdate github_repo: 'akhoury6/rbcli', access_token: nil, enterprise_hostname: nil,
|
380
|
+
autoupdate github_repo: 'akhoury6/rbcli', access_token: nil, enterprise_hostname: nil, force_update: false # (Optional) Check for updates to this application at a GitHub repo. The repo must use version number tags in accordance to best practices: https://help.github.com/articles/creating-releases/
|
381
381
|
```
|
382
382
|
The `github_repo` should point to the repo using the `user/repo` syntax.
|
383
383
|
|
@@ -385,21 +385,17 @@ The `access_token` can be overridden by the user via their configuration file, s
|
|
385
385
|
|
386
386
|
The `enterprise_hostname` setting allows you to point RBCli at a local GitHub Enterprise server.
|
387
387
|
|
388
|
-
The `this_version` parameter should be set to the current version of the tool that the user is running. Here we leverage the default version location that is used for the RBCli gem itself. In your tool, you should replace this with your own version number.
|
389
|
-
|
390
388
|
Setting `force_update: true` will halt execution if an update is available, forcing the user to update.
|
391
389
|
|
392
390
|
### Rubygems.org Update Check
|
393
391
|
|
394
|
-
The Rubygems update check will check if there is a new published version of the gem on Rubygems.org.
|
392
|
+
The Rubygems update check will check if there is a new published version of the gem on Rubygems.org. The latest published version is compared to the version number you configured RBCli with.
|
395
393
|
|
396
394
|
```ruby
|
397
|
-
autoupdate gem: 'rbcli',
|
395
|
+
autoupdate gem: 'rbcli', force_update: false # (Optional) Check for updates to this application through RubyGems.org.
|
398
396
|
```
|
399
397
|
|
400
398
|
The `gem` parameter should simply state the name of the gem.
|
401
|
-
|
402
|
-
The `this_version` parameter should be set to the current version of the tool that the user is running. Here we leverage the default version location that is used for the RBCli gem itself. In your tool, you should replace this with your own version number.
|
403
399
|
|
404
400
|
Setting `force_update: true` will halt execution if an update is available, forcing the user to update.
|
405
401
|
|
data/examples/mytool
CHANGED
@@ -22,8 +22,8 @@ Rbcli::Configurate.me do
|
|
22
22
|
|
23
23
|
option :name, 'Give me your name', type: :string, default: 'Foo', required: false, permitted: ['Jack', 'Jill'] # (Optional, Multiple) Add a global CLI parameter. Supported types are :string, :boolean, :integer, :float, :date, and :io. Can be called multiple times.
|
24
24
|
|
25
|
-
autoupdate github_repo: 'akhoury6/rbcli', access_token: nil, enterprise_hostname: nil,
|
26
|
-
autoupdate gem: 'rbcli',
|
25
|
+
autoupdate github_repo: 'akhoury6/rbcli', access_token: nil, enterprise_hostname: nil, force_update: false # (Optional) Check for updates to this application at a GitHub repo. The repo must use version number tags in accordance to best practices: https://help.github.com/articles/creating-releases/
|
26
|
+
autoupdate gem: 'rbcli', force_update: false # (Optional) Check for updates to this application through RubyGems.org.
|
27
27
|
|
28
28
|
default_action do |opts| # (Optional) The default code to execute when no subcommand is given. If not present, the help is shown (same as -h)
|
29
29
|
puts "Hello, #{opts[:name]}."
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Rbcli::Configurate
|
2
|
-
def self.autoupdate gem: nil, github_repo: nil, access_token: nil, enterprise_hostname: nil,
|
2
|
+
def self.autoupdate gem: nil, github_repo: nil, access_token: nil, enterprise_hostname: nil, force_update: false
|
3
3
|
raise StandardError.new "Autoupdater can not have both a gem and git target defined. Please pick one." if gem and giturl
|
4
4
|
raise StandardError.new "Only one autoupdater can be defined." if @data[:autoupdater]
|
5
5
|
if gem
|
6
6
|
#Rbcli::Autoupdate::GemUpdater.save_defaults
|
7
|
-
@data[:autoupdater] = Rbcli::Autoupdate::GemUpdater.new gem,
|
7
|
+
@data[:autoupdater] = Rbcli::Autoupdate::GemUpdater.new gem, force_update
|
8
8
|
else
|
9
9
|
Rbcli::Autoupdate::GithubUpdater.save_defaults
|
10
|
-
@data[:autoupdater] = Rbcli::Autoupdate::GithubUpdater.new github_repo, access_token, enterprise_hostname,
|
10
|
+
@data[:autoupdater] = Rbcli::Autoupdate::GithubUpdater.new github_repo, access_token, enterprise_hostname, force_update
|
11
11
|
end
|
12
12
|
@data[:autoupdater].show_message if @data[:autoupdater].update_available?
|
13
13
|
end
|
@@ -27,11 +27,11 @@ module Rbcli::Autoupdate
|
|
27
27
|
|
28
28
|
def update_available?
|
29
29
|
@latest_version = get_latest_version
|
30
|
-
Gem::Version.new(@latest_version) > Gem::Version.new(
|
30
|
+
Gem::Version.new(@latest_version) > Gem::Version.new(Rbcli.configuration[:version])
|
31
31
|
end
|
32
32
|
|
33
33
|
def show_message
|
34
|
-
puts "WARNING: An update is available to #{Rbcli::Configurate::configuration[:scriptname]}. You are currently running version #{
|
34
|
+
puts "WARNING: An update is available to #{Rbcli::Configurate::configuration[:scriptname]}. You are currently running version #{Rbcli.configuration[:version]}; the latest is #{@latest_version || get_latest_version}."
|
35
35
|
puts update_message
|
36
36
|
puts "\n"
|
37
37
|
if @force_update
|
@@ -5,10 +5,9 @@ module Rbcli::Autoupdate
|
|
5
5
|
class GemUpdater
|
6
6
|
include Common
|
7
7
|
|
8
|
-
def initialize gemname,
|
8
|
+
def initialize gemname, force_update
|
9
9
|
@gemname = gemname
|
10
10
|
@uri = URI.parse "https://rubygems.org/api/v1/versions/#{gemname}/latest.json"
|
11
|
-
@this_version = this_version
|
12
11
|
@force_update = force_update
|
13
12
|
end
|
14
13
|
|
@@ -4,9 +4,8 @@ module Rbcli::Autoupdate
|
|
4
4
|
class GithubUpdater
|
5
5
|
include Common
|
6
6
|
|
7
|
-
def initialize reponame, access_token, enterprise_hostname,
|
7
|
+
def initialize reponame, access_token, enterprise_hostname, force_update
|
8
8
|
@reponame = reponame
|
9
|
-
@this_version = this_version
|
10
9
|
@force_update = force_update
|
11
10
|
|
12
11
|
access_token = Rbcli.config.key?(:github_updatecheck) ? (Rbcli.config[:github_updatecheck][:access_token] || access_token) : access_token
|
data/lib/rbcli/version.rb
CHANGED