ugc 0.9.3 → 0.9.4
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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +26 -26
- data/README.md +14 -8
- data/bin/ugc +4 -1
- data/lib/ugc/commands/delete.rb +6 -1
- data/lib/ugc/commands/get.rb +7 -2
- data/lib/ugc/commands/login.rb +1 -1
- data/lib/ugc/commands/post.rb +8 -4
- data/lib/ugc/commands/profile.rb +1 -1
- data/lib/ugc/commands/put.rb +8 -4
- data/lib/ugc/commands/query.rb +11 -6
- data/lib/ugc/commands/target.rb +1 -1
- data/lib/ugc/helpers/curl.rb +21 -0
- data/lib/ugc/helpers/rest.rb +6 -1
- data/lib/ugc/settings.rb +5 -0
- data/lib/ugc/version.rb +1 -1
- data/ugc.gemspec +2 -2
- metadata +9 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62fd96ec45f90ca1750c59ee45fc0b74c7eaa2c0
|
|
4
|
+
data.tar.gz: 646f5efc53d15729d7d3eb69a7bae4d0d89a54a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84decc28a7bbac07174f2fb0cec3ef8d59d511f9e81123a1a03054d58bd1e6b324b7e3b616483e607dea23cfe41a544203c5cc50025ea559946026137e22139a
|
|
7
|
+
data.tar.gz: 7d6ac3c0ecc81bd9080a60e7aa9c2d791eee2cdbb3c74d02689d5e5232da8014a717f3d01d64ce8f665c4d43870618b82275c7ec36240e1a5f7d3102d4650220
|
data/Gemfile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ugc (0.9.
|
|
4
|
+
ugc (0.9.4)
|
|
5
5
|
command_line_reporter
|
|
6
|
-
gli
|
|
6
|
+
gli
|
|
7
7
|
highline
|
|
8
|
-
usergrid_iron (>= 0.
|
|
8
|
+
usergrid_iron (>= 0.9.1)
|
|
9
9
|
|
|
10
10
|
GEM
|
|
11
|
-
remote:
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
aruba (0.5.
|
|
14
|
-
childprocess (
|
|
13
|
+
aruba (0.5.3)
|
|
14
|
+
childprocess (>= 0.3.6)
|
|
15
15
|
cucumber (>= 1.1.1)
|
|
16
16
|
rspec-expectations (>= 2.7.0)
|
|
17
|
-
builder (3.
|
|
18
|
-
childprocess (0.3.
|
|
19
|
-
ffi (~> 1.0, >= 1.0.
|
|
17
|
+
builder (3.2.2)
|
|
18
|
+
childprocess (0.3.9)
|
|
19
|
+
ffi (~> 1.0, >= 1.0.11)
|
|
20
20
|
colored (1.2)
|
|
21
21
|
command_line_reporter (3.2.1)
|
|
22
22
|
colored (>= 1.2)
|
|
23
|
-
cucumber (1.2
|
|
23
|
+
cucumber (1.3.2)
|
|
24
24
|
builder (>= 2.1.2)
|
|
25
25
|
diff-lcs (>= 1.1.3)
|
|
26
|
-
gherkin (~> 2.
|
|
27
|
-
|
|
28
|
-
diff-lcs (1.
|
|
29
|
-
ffi (1.
|
|
30
|
-
gherkin (2.
|
|
31
|
-
|
|
32
|
-
gli (2.5.
|
|
33
|
-
highline (1.6.
|
|
34
|
-
json (1.
|
|
35
|
-
mime-types (1.
|
|
36
|
-
multi_json (1.7.
|
|
37
|
-
rake (10.0.
|
|
38
|
-
rdoc (
|
|
26
|
+
gherkin (~> 2.12.0)
|
|
27
|
+
multi_json (~> 1.3)
|
|
28
|
+
diff-lcs (1.2.4)
|
|
29
|
+
ffi (1.8.1)
|
|
30
|
+
gherkin (2.12.0)
|
|
31
|
+
multi_json (~> 1.3)
|
|
32
|
+
gli (2.5.6)
|
|
33
|
+
highline (1.6.19)
|
|
34
|
+
json (1.8.0)
|
|
35
|
+
mime-types (1.23)
|
|
36
|
+
multi_json (1.7.5)
|
|
37
|
+
rake (10.0.4)
|
|
38
|
+
rdoc (4.0.1)
|
|
39
39
|
json (~> 1.4)
|
|
40
40
|
rest-client (1.6.7)
|
|
41
41
|
mime-types (>= 1.16)
|
|
42
|
-
rspec-expectations (2.
|
|
43
|
-
diff-lcs (
|
|
44
|
-
usergrid_iron (0.9.
|
|
42
|
+
rspec-expectations (2.13.0)
|
|
43
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
44
|
+
usergrid_iron (0.9.1)
|
|
45
45
|
multi_json
|
|
46
46
|
rest-client
|
|
47
47
|
|
data/README.md
CHANGED
|
@@ -15,12 +15,13 @@ ugc enables convenient terminal access to Apigee's App Services (aka Usergrid).
|
|
|
15
15
|
* Can optionally emits raw output (--verbose switch)
|
|
16
16
|
* Extended SQL syntax (adds 'from' and 'limit' clauses to standard Usergrid syntax)
|
|
17
17
|
* File upload (-f or --file option) on PUT and POST
|
|
18
|
+
* Emit curl equivalent for all REST commands
|
|
18
19
|
|
|
19
20
|
## Installation
|
|
20
21
|
|
|
21
22
|
$ gem install ugc
|
|
22
23
|
|
|
23
|
-
Note: Requires Ruby 1.9.3
|
|
24
|
+
Note: Requires Ruby 1.9.3+ or Ruby 2.0. If you have issues, check your version:
|
|
24
25
|
|
|
25
26
|
$ ruby -v
|
|
26
27
|
|
|
@@ -33,14 +34,14 @@ If necessary, install a new version of Ruby. [RVM](https://rvm.io) is recommende
|
|
|
33
34
|
### Commands
|
|
34
35
|
|
|
35
36
|
delete - delete an entity
|
|
36
|
-
get, show, ls, list - retrieve a collection or entity
|
|
37
|
+
get, show, ls, list - retrieve and display a collection or entity
|
|
37
38
|
help - Shows a list of commands or help for one command
|
|
38
|
-
login -
|
|
39
|
-
post, create - non-idempotent create or update (usually create)
|
|
40
|
-
profile, profiles - set the current profile
|
|
41
|
-
put, update - idempotent create or update (usually an update)
|
|
42
|
-
query - query
|
|
43
|
-
target - set the base url, org, and app
|
|
39
|
+
login - Performs a login to the current profile
|
|
40
|
+
post, create - non-idempotent create or update (post is usually create)
|
|
41
|
+
profile, profiles - set the current profile (creates if it doesn't exist)
|
|
42
|
+
put, update - idempotent create or update (put is usually an update)
|
|
43
|
+
query - query (uses sql-like syntax)
|
|
44
|
+
target - set the base url, org, and app for the current profile
|
|
44
45
|
|
|
45
46
|
### Setup
|
|
46
47
|
|
|
@@ -177,6 +178,11 @@ If you specify column names in your query, you will be unable to reference the r
|
|
|
177
178
|
|
|
178
179
|
## Release notes
|
|
179
180
|
|
|
181
|
+
### 0.9.4
|
|
182
|
+
* New features
|
|
183
|
+
1. Emit curl equivalent commands with -c (--curl) switch
|
|
184
|
+
* eg. `$ ugc -c get something`
|
|
185
|
+
|
|
180
186
|
### 0.9.3
|
|
181
187
|
* New features
|
|
182
188
|
1. file upload function with -f (--file) switch
|
data/bin/ugc
CHANGED
|
@@ -18,9 +18,12 @@ switch [:v,:verbose], negatable: false
|
|
|
18
18
|
desc 'management'
|
|
19
19
|
switch [:m,:management], negatable: false
|
|
20
20
|
|
|
21
|
+
desc 'show curl equivalent (does not execute)'
|
|
22
|
+
switch [:c,:curl], negatable: false
|
|
23
|
+
|
|
21
24
|
desc 'draw table border'
|
|
22
25
|
default_value true
|
|
23
|
-
switch [:
|
|
26
|
+
switch [:border]
|
|
24
27
|
|
|
25
28
|
desc 'settings directory'
|
|
26
29
|
arg_name 'settings directory'
|
data/lib/ugc/commands/delete.rb
CHANGED
|
@@ -6,7 +6,12 @@ command :rm,:del,:delete do |c|
|
|
|
6
6
|
c.action do |global_options,options,args|
|
|
7
7
|
help_now! unless args[0]
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
resource = $context[args[0]]
|
|
10
|
+
if $settings.show_curl?
|
|
11
|
+
puts_curl(:delete, resource)
|
|
12
|
+
else
|
|
13
|
+
format_response resource.delete
|
|
14
|
+
end
|
|
10
15
|
end
|
|
11
16
|
|
|
12
17
|
end
|
data/lib/ugc/commands/get.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
desc 'retrieve a collection or entity'
|
|
1
|
+
desc 'retrieve and display a collection or entity'
|
|
2
2
|
|
|
3
3
|
command :get,:show,:ls,:list do |c|
|
|
4
4
|
|
|
@@ -8,7 +8,12 @@ command :get,:show,:ls,:list do |c|
|
|
|
8
8
|
c2.action do |global_options,options,args|
|
|
9
9
|
help_now! unless args[0]
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
resource = $context[args[0]]
|
|
12
|
+
if $settings.show_curl?
|
|
13
|
+
puts_curl(:get, resource)
|
|
14
|
+
else
|
|
15
|
+
format_response resource.get
|
|
16
|
+
end
|
|
12
17
|
end
|
|
13
18
|
end
|
|
14
19
|
|
data/lib/ugc/commands/login.rb
CHANGED
data/lib/ugc/commands/post.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
desc 'non-idempotent create or update (usually create)'
|
|
1
|
+
desc 'non-idempotent create or update (post is usually create)'
|
|
2
2
|
arg_name 'url [data]'
|
|
3
3
|
|
|
4
4
|
command :post,:create do |c|
|
|
@@ -10,10 +10,14 @@ command :post,:create do |c|
|
|
|
10
10
|
|
|
11
11
|
resource = $context[args[0]]
|
|
12
12
|
payload = parse_data(options[:data] || args[1])
|
|
13
|
-
if
|
|
14
|
-
|
|
13
|
+
if $settings.show_curl?
|
|
14
|
+
puts_curl(:post, resource, payload, options[:file])
|
|
15
15
|
else
|
|
16
|
-
|
|
16
|
+
if options[:file]
|
|
17
|
+
format_response multipart_upload resource, payload, options[:file]
|
|
18
|
+
else
|
|
19
|
+
format_response resource.post payload
|
|
20
|
+
end
|
|
17
21
|
end
|
|
18
22
|
end
|
|
19
23
|
|
data/lib/ugc/commands/profile.rb
CHANGED
data/lib/ugc/commands/put.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
desc 'idempotent create or update (usually an update)'
|
|
1
|
+
desc 'idempotent create or update (put is usually an update)'
|
|
2
2
|
arg_name 'url [data]'
|
|
3
3
|
|
|
4
4
|
command :put,:update do |c|
|
|
@@ -10,10 +10,14 @@ command :put,:update do |c|
|
|
|
10
10
|
|
|
11
11
|
resource = $context[args[0]]
|
|
12
12
|
payload = parse_data(options[:data] || args[1])
|
|
13
|
-
if
|
|
14
|
-
|
|
13
|
+
if $settings.show_curl?
|
|
14
|
+
puts_curl(:put, resource, payload, options[:file])
|
|
15
15
|
else
|
|
16
|
-
|
|
16
|
+
if options[:file]
|
|
17
|
+
format_response multipart_upload resource, payload, options[:file], :put
|
|
18
|
+
else
|
|
19
|
+
format_response resource.put payload
|
|
20
|
+
end
|
|
17
21
|
end
|
|
18
22
|
end
|
|
19
23
|
|
data/lib/ugc/commands/query.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
desc 'query'
|
|
2
|
-
long_desc '
|
|
1
|
+
desc 'query (uses sql-like syntax)'
|
|
2
|
+
long_desc 'query may contain "from" clause instead of specifying collection_name'
|
|
3
3
|
arg_name '[collection_name] query'
|
|
4
4
|
|
|
5
5
|
command :query do |c|
|
|
@@ -30,10 +30,15 @@ command :query do |c|
|
|
|
30
30
|
params[:limit] = limit
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
resource = $application[type]
|
|
34
|
+
if $settings.show_curl?
|
|
35
|
+
options = options.merge({ql: query}) if query
|
|
36
|
+
puts_curl(:get, resource)
|
|
37
|
+
else
|
|
38
|
+
response = resource.query query, params
|
|
39
|
+
format_collection response.collection, parsed_query['select']
|
|
40
|
+
save_response response
|
|
41
|
+
end
|
|
37
42
|
end
|
|
38
43
|
|
|
39
44
|
end
|
data/lib/ugc/commands/target.rb
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
def puts_curl(command, resource, payload=nil, file=nil)
|
|
2
|
+
headers = resource.options[:headers] || {}
|
|
3
|
+
req = RestClient::Request.new(resource.options.merge(
|
|
4
|
+
:method => :get,
|
|
5
|
+
:url => resource.url,
|
|
6
|
+
:headers => headers))
|
|
7
|
+
headers.delete(:content_type) if file
|
|
8
|
+
curl_headers = req.make_headers headers
|
|
9
|
+
curl_headers = curl_headers.map {|e| %Q[-H "#{e.join(': ')}"] }.join(' ')
|
|
10
|
+
curl = "curl -X #{command.upcase} -i #{curl_headers}"
|
|
11
|
+
if file
|
|
12
|
+
payload = multipart_payload payload || {}, file
|
|
13
|
+
payload = payload.map { |k,v|
|
|
14
|
+
File.file?(v) ? %Q[-F "#{k}=@#{File.absolute_path(v)}"] : %Q[-F "#{k}=#{v}"]
|
|
15
|
+
}.join ' '
|
|
16
|
+
curl = "#{curl} #{payload}"
|
|
17
|
+
else
|
|
18
|
+
curl = %Q[#{curl} -d '#{payload}'] if (payload)
|
|
19
|
+
end
|
|
20
|
+
puts "#{curl} #{resource.url}"
|
|
21
|
+
end
|
data/lib/ugc/helpers/rest.rb
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
def
|
|
1
|
+
def multipart_payload(payload, file)
|
|
2
2
|
payload = payload.is_a?(Hash) ? payload : MultiJson.load(payload)
|
|
3
3
|
filename = 'file'
|
|
4
4
|
filename, file = file.split '=' if file.is_a?(String)
|
|
5
5
|
file = file[1..-1] if file.start_with? '@' # be kind to curl users
|
|
6
6
|
payload[filename] = file.is_a?(File) ? file : File.new(file, 'rb')
|
|
7
|
+
payload
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def multipart_upload(resource, payload, file, method=:post, additional_headers = {})
|
|
11
|
+
payload = multipart_payload payload, file
|
|
7
12
|
payload[:multipart] = true
|
|
8
13
|
headers = (resource.options[:headers] || {}).merge(additional_headers)
|
|
9
14
|
response = RestClient::Request.execute(resource.options.merge(
|
data/lib/ugc/settings.rb
CHANGED
|
@@ -5,6 +5,7 @@ module Ugc
|
|
|
5
5
|
|
|
6
6
|
def initialize(global_options)
|
|
7
7
|
@draw_table_border = global_options[:border]
|
|
8
|
+
@show_curl = global_options[:curl]
|
|
8
9
|
@settings_file = File.join global_options[:settings], SETTINGS_FILE
|
|
9
10
|
@settings = YAML.load_file(@settings_file) rescue default_settings
|
|
10
11
|
end
|
|
@@ -76,6 +77,10 @@ module Ugc
|
|
|
76
77
|
!!@draw_table_border
|
|
77
78
|
end
|
|
78
79
|
|
|
80
|
+
def show_curl?
|
|
81
|
+
!!@show_curl
|
|
82
|
+
end
|
|
83
|
+
|
|
79
84
|
def logged_in?
|
|
80
85
|
!!access_token
|
|
81
86
|
end
|
data/lib/ugc/version.rb
CHANGED
data/ugc.gemspec
CHANGED
|
@@ -18,8 +18,8 @@ spec = Gem::Specification.new do |s|
|
|
|
18
18
|
s.add_development_dependency('rake')
|
|
19
19
|
s.add_development_dependency('rdoc')
|
|
20
20
|
s.add_development_dependency('aruba')
|
|
21
|
-
s.add_runtime_dependency('gli'
|
|
22
|
-
s.add_runtime_dependency('usergrid_iron','>= 0.
|
|
21
|
+
s.add_runtime_dependency('gli')
|
|
22
|
+
s.add_runtime_dependency('usergrid_iron','>= 0.9.1')
|
|
23
23
|
s.add_runtime_dependency('highline')
|
|
24
24
|
s.add_runtime_dependency('command_line_reporter')
|
|
25
25
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ugc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scott Ganyo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-
|
|
11
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -56,30 +56,30 @@ dependencies:
|
|
|
56
56
|
name: gli
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - '
|
|
59
|
+
- - '>='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: '0'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - '
|
|
66
|
+
- - '>='
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: usergrid_iron
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - '>='
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
75
|
+
version: 0.9.1
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - '>='
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
82
|
+
version: 0.9.1
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: highline
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -138,6 +138,7 @@ files:
|
|
|
138
138
|
- lib/ugc/commands/put.rb
|
|
139
139
|
- lib/ugc/commands/query.rb
|
|
140
140
|
- lib/ugc/commands/target.rb
|
|
141
|
+
- lib/ugc/helpers/curl.rb
|
|
141
142
|
- lib/ugc/helpers/format.rb
|
|
142
143
|
- lib/ugc/helpers/history.rb
|
|
143
144
|
- lib/ugc/helpers/parse.rb
|