bootic_cli 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14a54ce4a89784dff4a594eb5d16ee9b9a3bc10e
4
- data.tar.gz: 3ccae9ef9c150991409e60ec8ffd2763728eaab9
3
+ metadata.gz: 1635165613bb3c1108f62bcf3fb9a455b66a22cc
4
+ data.tar.gz: b9eda84070803bdf7892769033bc5ceb4dd38b05
5
5
  SHA512:
6
- metadata.gz: d0571df846d44ca03ca5385573a9e0f5dae6928bda9dbe210f3c8a403b8fbed3518c68996fd54d15fb4bfd8d9eed6c24a30cc9a5db37c5fa5a3b72adecbded13
7
- data.tar.gz: 29d21d81ef59ac13ce3e832f099fa90aa453e36769646e738957ffe672d6521e1e8b2d2f2d62fea47c3b265966ff0c88650aa464572da8638d2920fe469335f2
6
+ metadata.gz: 2921db246029beec8a51e242a5635524a7106fc8f2d2cd93cd52b660597b4bee084ed04ef09109ee2502fce068be135a276f08d002fdbde761653d1d78fb5124
7
+ data.tar.gz: 07db650fb21e51a90e1042c940ada82a8af43abdb85f6a34a183caa391153bca54c6b045f4c248abfc4e8910171b9683fecfc55965dc6ad52f60cad3d732121b
data/README.md CHANGED
@@ -6,50 +6,45 @@ CLI to interact with the [Bootic.net API](https://developers.bootic.net/) and ru
6
6
 
7
7
  Install in your system.
8
8
 
9
- ```
10
- gem install bootic_cli
11
- ```
9
+ gem install bootic_cli
12
10
 
13
11
  ## Usage
14
12
 
15
- ```
16
- btc help
17
- btc login
18
- btc console
19
- ```
13
+ bootic help
14
+ bootic setup
15
+ bootic login
16
+ bootic console
20
17
 
21
18
  ### Console
22
19
 
23
- `btc console` launches an API session into an IRB console. You'll have `root` and `shop` API entities already initialized for you.
20
+ `bootic console` launches an API session into an IRB console. You'll have `root` and `shop` API entities already initialized for you.
24
21
 
25
22
  ```
26
- shop.orders(status: "all").each do |o|
27
- puts o.total
28
- end
23
+ > shop.orders(status: "all").each do |o|
24
+ > puts o.total
25
+ > end
29
26
 
30
- explain shop
27
+ > explain shop
31
28
 
32
- list shop.products
29
+ > list shop.products
33
30
 
34
- explain_link shop, :products
31
+ > explain_link shop, :products
35
32
  ```
36
33
 
37
34
  Access the configured client:
38
35
 
39
36
  ```
40
- client session.client
41
- new_root = client.from_url("https://some.endpoint.com")
37
+ > client session.client
38
+ > new_root = client.from_url("https://some.endpoint.com")
42
39
  ```
43
40
 
44
41
  ### Custom scripts
45
42
 
46
43
  You can run simple Ruby scripts in the context of an API session with
47
44
 
48
- ```
49
- btc runner my_script.rb
50
- ```
45
+ bootic runner my_script.rb
51
46
 
52
- Your script will be provided with the following variables
47
+ Your script will be provided with the following variables:
53
48
 
54
49
  ```ruby
55
50
  # the API root resource
@@ -59,50 +54,52 @@ root
59
54
  shop
60
55
  ```
61
56
 
62
- An example script that lists your shop's products
57
+ An example script that lists your shop's products:
63
58
 
64
59
  ```ruby
65
60
  # list_products.rb
66
- shop.products.full_set.each do |pr|
67
- puts pr.title
61
+ shop.products.full_set.each do |p|
62
+ puts p.title
68
63
  end
69
64
  ```
70
65
 
71
- You run it with
66
+ You run it with:
72
67
 
73
68
  ```
74
- btc runner list_products.rb
69
+ bootic runner list_products.rb
75
70
  ```
76
71
 
77
72
  ### Custom Thor commands
78
73
 
79
- More advanced scripts can be written as [Thor]() commands. Any scripts in `~/btc` will be loaded automatically.
74
+ More advanced scripts can be written as [Thor]() commands. Any scripts in `~/.bootic` will be loaded automatically.
80
75
 
81
76
  ```ruby
82
- # ~/btc/list_products
77
+ # ~/.bootic/list_products
83
78
  class ListProducts < BooticCli::Command
79
+
84
80
  desc "list", "list products by status"
85
81
  option :s, banner: "<status>"
86
82
  def list
87
- shop.products(status: options["s"]).full_set.each do |pr|
88
- puts pr.title
89
- end
83
+ shop.products(status: options["s"]).full_set.each do |p|
84
+ puts p.title
85
+ end
90
86
  end
87
+
91
88
  end
92
89
  ```
93
90
 
94
- Now `btc help` will list your custom `list_products` command.
91
+ Now `bootic help` will list your custom `list_products` command.
95
92
 
96
93
  ```
97
- btc help list_products
94
+ bootic help list_products
98
95
 
99
96
  # list hidden products
100
- btc list_products list -s hidden
97
+ bootic list_products list -s hidden
101
98
  ```
102
99
 
103
100
  ## Development
104
101
 
105
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec btc` to use the code located in this directory, ignoring other installed copies of this gem.
102
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec bootic` to use the code located in this directory, ignoring other installed copies of this gem.
106
103
 
107
104
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
108
105
 
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
-
6
5
  task :default => :spec
data/lib/bootic_cli.rb CHANGED
@@ -1 +1 @@
1
- require "bootic_cli/cli"
1
+ require 'bootic_cli/cli'
@@ -9,7 +9,7 @@ module BooticCli
9
9
  include Thor::Actions
10
10
  include BooticCli::Connectivity
11
11
 
12
- CUSTOM_COMMANDS_DIR = ENV.fetch("BTC_CUSTOM_COMMANDS_PATH") { File.join(ENV["HOME"], "btc") }
12
+ CUSTOM_COMMANDS_DIR = ENV.fetch('BTC_CUSTOM_COMMANDS_PATH') { File.join(ENV['HOME'], 'bootic') }
13
13
 
14
14
  # override Thor's help method to print banner and check for keys
15
15
  def help
@@ -32,7 +32,7 @@ module BooticCli
32
32
  if session.setup?
33
33
  input = ask "Looks like you're already set up. Do you want to re-enter your app's credentials? [n]", :magenta
34
34
  if input != 'y'
35
- say 'Thought so. Bye!'
35
+ say 'Thought so. You can run `bootic help` for a list of supported commands.'
36
36
  exit(1)
37
37
  end
38
38
  else
@@ -85,24 +85,24 @@ module BooticCli
85
85
  if session.logged_in?
86
86
  input = ask "Looks like you're already logged in. Do you want to redo this step? [n]", :magenta
87
87
  if input != 'y'
88
- say 'Thought so. Bye!'
88
+ say "That's what I thought! Try running `bootic help`."
89
89
  exit(1)
90
90
  end
91
91
  end
92
92
 
93
- username = ask("Enter your Bootic email:", :bold)
94
- pwd = ask("Enter your Bootic password:", :bold, echo: false)
93
+ email = ask("Enter your Bootic email:", :bold)
94
+ pass = ask("Enter your Bootic password:", :bold, echo: false)
95
95
 
96
- if username.strip == '' or pwd.strip == ''
96
+ if email.strip == '' or email['@'].nil? or pass.strip == ''
97
97
  say "\nPlease make sure to enter valid data.", :red
98
98
  exit 1
99
99
  end
100
100
 
101
- say "\n\nAlrighty! Getting access token for #{username}...\n"
101
+ say "\n\nAlrighty! Getting access token for #{email}...\n"
102
102
 
103
103
  begin
104
- session.login(username, pwd, scope)
105
- say "Great success! You're now logged in as #{username} (#{scope})", :green
104
+ session.login(email, pass, scope)
105
+ say "Great success! You're now logged in as #{email} (#{scope})", :green
106
106
  say "For a list of available commands, run `bootic help`."
107
107
  rescue StandardError => e
108
108
  say e.message, :red
@@ -6,7 +6,7 @@ module BooticCli
6
6
  class Store
7
7
  VERSION = 1
8
8
  DEFAULT_NAMESPACE = 'production'.freeze
9
- DIRNAME = '.btc'.freeze
9
+ DIRNAME = '.bootic'.freeze
10
10
  FILE_NAME = 'store.pstore'.freeze
11
11
 
12
12
  def initialize(base_dir: ENV['HOME'], dir: DIRNAME, namespace: DEFAULT_NAMESPACE)
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootic_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  requirements: []
200
200
  rubyforge_project:
201
- rubygems_version: 2.6.13
201
+ rubygems_version: 2.5.1
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: Bootic command-line client.