adash 0.0.5 → 0.0.6

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: c3bf354baae4874d47f0f6fd795da1a4663ad874
4
- data.tar.gz: ce988ab6a88d3fc484d04a117f1ccac76270c22b
3
+ metadata.gz: e77acc65e5e0c50937e10fdd3bb5aacd656b0aeb
4
+ data.tar.gz: 1f8502ee18f880e50e84e4c6e62369bfdf942fba
5
5
  SHA512:
6
- metadata.gz: 7ce593770dc9943926f45f597296cd1bc4cdbceeaaba6087f48cde0dda6d82eb75dca6f0dcf3f2c893571be64d525ea6b0bc0fbba7573fabf21bc45195289610
7
- data.tar.gz: c0b143679b7536438aa40acd827067b7f5a508c25b58e0ccc223780054e116cba9be9b4a50e96a3b18af9becbd86b632537cc0f8c7729651a42e088b1dd9fd61
6
+ metadata.gz: d4a2eb2bcf01c249d7975d9f667d8038cc49f958d3b639e2a0ac02e39a1e686e8bb5fa78946c42ba244d218f9902249da99db9008824a695ba61aafb9952446e
7
+ data.tar.gz: 7a90a65826e0dff7b3916fda0819600696ab097dafc7ccd5382f4bc56bea811dc66b5d4db6766e0f8171b950cad6c647f12322e83ab5d0a7e042f54b65feaa71
data/README.md CHANGED
@@ -35,6 +35,8 @@ $ adash init lozenge 01234567-89ab-cdef-0123-456789abcdef
35
35
  WEBrick web server runs intenally, and a browser is opened for it.
36
36
  You are requested OAuth authorization and DRS initialization.
37
37
 
38
+ You can use `--test` option for test purchase mode: `adash init lozenge 01234567-89ab-cdef-0123-456789abcdef --test`
39
+
38
40
  ### `adash list`
39
41
 
40
42
  The sub-command `adash list` shows initialized devices list.
@@ -102,6 +104,12 @@ You can delete device from Adash and Amazon.
102
104
  $ adash deregistrate lozenge
103
105
  ```
104
106
 
107
+ ### `--credentials` Option
108
+
109
+ You can specify credentials file path: `adash -c ~/foo/bar list`
110
+
111
+ Default credentials file path is `~/.config/adash/credentials`.
112
+
105
113
  ## Contributing
106
114
 
107
115
  Bug reports and pull requests are welcome on GitHub at https://github.com/aycabta/adash.
@@ -110,4 +118,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/aycabt
110
118
  ## License
111
119
 
112
120
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
113
-
data/Rakefile CHANGED
@@ -1,3 +1,3 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- task :default => :spec
3
+ task :default
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["aycabta@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Adash is a Dash Replenishment Service CLI client}
13
- spec.description = %Q{Adash is a Dash Replenishment Service CLI client.\nYou will login with OAuth (Login with Amazon) and replenish items.}
13
+ spec.description = %Q{Adash is a Dash Replenishment Service CLI client.\nYou will login with OAuth (Login with Amazon) and replenish items.\n}
14
14
  spec.homepage = "https://github.com/aycabta/adash"
15
15
  spec.license = "MIT"
16
16
 
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.13"
23
- spec.add_development_dependency "rake", "~> 12.0"
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
24
24
  spec.add_dependency "amazon-drs"
25
25
  spec.add_dependency "launchy"
26
26
  end
data/exe/adash CHANGED
@@ -4,6 +4,7 @@ $: << File.expand_path("../../lib/", __FILE__)
4
4
 
5
5
  require 'adash'
6
6
  require 'optparse'
7
+ require 'adash/config'
7
8
 
8
9
  def run_sub_command(adash, subcmd, argv)
9
10
  case subcmd
@@ -68,15 +69,20 @@ def help
68
69
  puts ' replenish'
69
70
  end
70
71
 
72
+ help_option = false
71
73
  opt = OptionParser.new
72
74
  opt.on('-h', '--help') {
73
- help
75
+ help_option = true
76
+ }
77
+ opt.on('-c', '--credentials CREDENTIALS_PATH') { |path|
78
+ puts "Use credentials file: #{path}"
79
+ Adash::Config.credentials_path = path
74
80
  }
75
81
 
76
82
  adash = Adash::Manager.new
77
83
 
78
84
  argv = opt.order(ARGV)
79
- if argv.empty?
85
+ if help_option || argv.empty?
80
86
  help
81
87
  else
82
88
  subcmd = argv.shift
@@ -67,7 +67,11 @@ module Adash
67
67
  end
68
68
  client = create_client_from_device(device)
69
69
  resp = client.deregistrate_device
70
- save_credentials_without_device_model(device['device_model'])
70
+ if resp.instance_of?(AmazonDrs::Error)
71
+ STDERR.puts resp.inspect
72
+ else
73
+ save_credentials_without_device_model(device['device_model'])
74
+ end
71
75
  0
72
76
  end
73
77
 
@@ -1,6 +1,5 @@
1
1
  module Adash
2
2
  class Config
3
-
4
3
  open("#{File.expand_path('../../../data', __FILE__)}/client", 'r') do |f|
5
4
  @@client_id = f.readline.chomp
6
5
  @@client_secret = f.readline.chomp
@@ -23,5 +22,9 @@ module Adash
23
22
  def self.credentials_path
24
23
  @@credentials_path
25
24
  end
25
+
26
+ def self.credentials_path=(new_path)
27
+ @@credentials_path = new_path
28
+ end
26
29
  end
27
30
  end
@@ -1,3 +1,3 @@
1
1
  module Adash
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -16,7 +16,19 @@ module Adash
16
16
  @code_box = Queue.new
17
17
  @code_cv = ConditionVariable.new
18
18
  @code_mutex = Mutex.new
19
- @server = WEBrick::HTTPServer.new({ :BindAddress => '127.0.0.1', :Port => Adash::Config.redirect_port })
19
+ @start_box = Queue.new
20
+ @start_cv = ConditionVariable.new
21
+ @start_mutex = Mutex.new
22
+ @server = WEBrick::HTTPServer.new({
23
+ :BindAddress => '127.0.0.1',
24
+ :Port => Adash::Config.redirect_port,
25
+ :StartCallback => proc {
26
+ @start_mutex.synchronize {
27
+ @start_box.push(true)
28
+ @start_cv.signal
29
+ }
30
+ }
31
+ })
20
32
  @server.mount_proc('/getting_started', proc { |req, res|
21
33
  res.content_type = 'text/html'
22
34
  content = %Q`<p>Please go to <a href="#{ERB::Util.html_escape(amazon_authorization_url(@device_model, @serial))}">initial tour</a>.</p>`
@@ -40,8 +52,12 @@ module Adash
40
52
  def get_code
41
53
  t = Thread.new do
42
54
  @code_mutex.synchronize {
43
- # TODO: wait for WEBrick launch
44
- Launchy.open("http://localhost:#{Adash::Config.redirect_port}/getting_started")
55
+ @start_mutex.synchronize {
56
+ while @start_box.size == 0
57
+ @start_cv.wait(@start_mutex)
58
+ end
59
+ Launchy.open("http://localhost:#{Adash::Config.redirect_port}/getting_started")
60
+ }
45
61
  while @code_box.size == 0
46
62
  @code_cv.wait(@code_mutex)
47
63
  sleep 1
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code Ass
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-10 00:00:00.000000000 Z
11
+ date: 2017-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '12.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '12.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: amazon-drs
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: |-
69
+ description: |
70
70
  Adash is a Dash Replenishment Service CLI client.
71
71
  You will login with OAuth (Login with Amazon) and replenish items.
72
72
  email: