flood-cli 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli/console.rb +2 -1
- data/lib/flood-cli.rb +1 -0
- data/lib/flood-cli/flood-cli.rb +24 -6
- data/lib/flood-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e736687a41e9fdd824ba23d5378a36a1ed7125c6
|
4
|
+
data.tar.gz: 17ff74365819278b842f0aeff24103d2285233f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d547701fd7f064dc8acb760056fa0cffba24f5f9339a8ba7c1763956de9c616dd8e2671d7fd0624a8a6a2ca20cbc1b864049b3090a9b97c98bf303d37f110c9
|
7
|
+
data.tar.gz: 852fa0a565a6bcf7d6aa594f32a0003006674627cbbfcec806011a70242a99d79a81b26995c7a69057030ef69c98c64e658e763140edc36e4f0826c9e71b67d0
|
data/lib/cli/console.rb
CHANGED
@@ -4,6 +4,7 @@ class FloodCli
|
|
4
4
|
module Cli
|
5
5
|
class Console < Thor
|
6
6
|
desc 'login', 'Login to Flood IO'
|
7
|
+
option :verbose, default: false
|
7
8
|
def login
|
8
9
|
say('Enter your Flood IO credentials.', :yellow)
|
9
10
|
email = ask('Email: ')
|
@@ -13,7 +14,7 @@ class FloodCli
|
|
13
14
|
endpoint = ask('Endpoint: ', default: 'https://api.flood.io')
|
14
15
|
proxy = ask('HTTP Proxy: ')
|
15
16
|
|
16
|
-
cli = FloodCli.new(endpoint: endpoint, proxy: proxy, config: config)
|
17
|
+
cli = FloodCli.new(endpoint: endpoint, proxy: proxy, config: config, verbose: options[:verbose])
|
17
18
|
cli.login(email: email, password: password)
|
18
19
|
end
|
19
20
|
|
data/lib/flood-cli.rb
CHANGED
data/lib/flood-cli/flood-cli.rb
CHANGED
@@ -64,6 +64,8 @@ class FloodCli
|
|
64
64
|
|
65
65
|
def error(response)
|
66
66
|
"HTTP #{response.code.to_s} #{JSON.parse(response)['error']}"
|
67
|
+
rescue JSON::ParserError
|
68
|
+
"HTTP #{response.code.to_s} #{response}"
|
67
69
|
end
|
68
70
|
|
69
71
|
def parse(response)
|
@@ -77,18 +79,34 @@ class FloodCli
|
|
77
79
|
end
|
78
80
|
|
79
81
|
def token
|
80
|
-
@config && @config[:token]
|
82
|
+
raw_token = @config && @config[:token]
|
83
|
+
if version_i == 1
|
84
|
+
'Basic ' + Base64.encode64("#{raw_token}:").chomp
|
85
|
+
else
|
86
|
+
raw_token
|
87
|
+
end
|
81
88
|
end
|
82
89
|
|
83
90
|
def endpoint
|
84
|
-
@endpoint ||= @config && @config[:endpoint]
|
91
|
+
@endpoint ||= (@config && @config[:endpoint]) || 'https://api.flood.io'
|
92
|
+
@endpoint
|
93
|
+
end
|
94
|
+
|
95
|
+
def version
|
96
|
+
(@config && @config[:version].to_i) || 2
|
85
97
|
end
|
86
98
|
|
87
99
|
def headers
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
100
|
+
if version == 1
|
101
|
+
{
|
102
|
+
content_type: :json
|
103
|
+
}
|
104
|
+
else
|
105
|
+
{
|
106
|
+
content_type: :json,
|
107
|
+
accept: 'application/vnd.flood.v2'
|
108
|
+
}
|
109
|
+
end
|
92
110
|
end
|
93
111
|
|
94
112
|
def headers_with_token
|
data/lib/flood-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flood-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Koopmans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|