chimps-cli 0.0.1
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.
- data/Gemfile +8 -0
- data/Gemfile.lock +32 -0
- data/LICENSE +20 -0
- data/README.rdoc +322 -0
- data/Rakefile +24 -0
- data/VERSION +1 -0
- data/bin/chimps +4 -0
- data/lib/chimps-cli.rb +46 -0
- data/lib/chimps-cli/commands.rb +179 -0
- data/lib/chimps-cli/commands/base.rb +65 -0
- data/lib/chimps-cli/commands/create.rb +38 -0
- data/lib/chimps-cli/commands/delete.rb +29 -0
- data/lib/chimps-cli/commands/destroy.rb +36 -0
- data/lib/chimps-cli/commands/download.rb +40 -0
- data/lib/chimps-cli/commands/get.rb +30 -0
- data/lib/chimps-cli/commands/help.rb +100 -0
- data/lib/chimps-cli/commands/list.rb +48 -0
- data/lib/chimps-cli/commands/me.rb +30 -0
- data/lib/chimps-cli/commands/post.rb +33 -0
- data/lib/chimps-cli/commands/put.rb +33 -0
- data/lib/chimps-cli/commands/query.rb +58 -0
- data/lib/chimps-cli/commands/search.rb +54 -0
- data/lib/chimps-cli/commands/show.rb +40 -0
- data/lib/chimps-cli/commands/test.rb +37 -0
- data/lib/chimps-cli/commands/update.rb +38 -0
- data/lib/chimps-cli/commands/upload.rb +86 -0
- data/lib/chimps-cli/utils.rb +13 -0
- data/lib/chimps-cli/utils/acts_on_resource.rb +93 -0
- data/lib/chimps-cli/utils/explicit_path.rb +30 -0
- data/lib/chimps-cli/utils/http_format.rb +51 -0
- data/lib/chimps-cli/utils/uses_param_value_data.rb +90 -0
- data/spec/chimps-cli/commands/delete_spec.rb +9 -0
- data/spec/chimps-cli/commands/get_spec.rb +8 -0
- data/spec/chimps-cli/commands/help_spec.rb +18 -0
- data/spec/chimps-cli/commands/list_spec.rb +7 -0
- data/spec/chimps-cli/commands/post_spec.rb +10 -0
- data/spec/chimps-cli/commands/put_spec.rb +10 -0
- data/spec/chimps-cli/commands/show_spec.rb +7 -0
- data/spec/spec_helper.rb +52 -0
- data/spec/support/acts_on_resource.rb +22 -0
- data/spec/support/explicit_path.rb +42 -0
- data/spec/support/http_format.rb +23 -0
- data/spec/support/uses_param_value_data.rb +88 -0
- metadata +166 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
shared_examples_for 'it can set its response format' do
|
2
|
+
|
3
|
+
def described_class_command_name
|
4
|
+
described_class.to_s.split('::').last.downcase
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should use the default response format" do
|
8
|
+
set_argv(described_class_command_name)
|
9
|
+
command.response_fmt.should == described_class.default_response_fmt
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not accept a response format that isn't allowed" do
|
13
|
+
set_argv(described_class_command_name, "--response_format=foobar")
|
14
|
+
command.response_fmt.should == described_class.default_response_fmt
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should accept a response format that is allowed" do
|
18
|
+
response_fmt = described_class.allowed_response_fmts.first
|
19
|
+
set_argv(described_class_command_name, "--response_format=#{response_fmt}")
|
20
|
+
command.response_fmt.should == response_fmt
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
shared_examples_for 'it uses data' do |required_arg|
|
2
|
+
|
3
|
+
# before do
|
4
|
+
# command.config[:data] = nil
|
5
|
+
# end
|
6
|
+
|
7
|
+
def described_class_command_name
|
8
|
+
described_class.to_s.split('::').last.downcase
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "directly from the command line" do
|
12
|
+
it "should accept param, value pairs from the command line" do
|
13
|
+
set_argv(described_class_command_name, required_arg, "foo=bar", "baz=booz")
|
14
|
+
command.data.should == { 'foo' => 'bar', 'baz' => 'booz' }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "from a file" do
|
19
|
+
|
20
|
+
before do
|
21
|
+
@data = { 'foo' => 'bar', 'baz' => { 'booz' => 'bing' } }
|
22
|
+
end
|
23
|
+
after { clean_tmp_dir! }
|
24
|
+
|
25
|
+
it "should raise an error when trying to read data from a file that doesn't exist" do
|
26
|
+
in_tmp_dir do
|
27
|
+
set_argv(described_class_command_name, required_arg, "--data=input.yml")
|
28
|
+
lambda { command.data }.should raise_error()
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should parse data from a YAML input file" do
|
33
|
+
in_tmp_dir do
|
34
|
+
File.open('input.yml', 'w') { |f| f.puts @data.to_yaml }
|
35
|
+
set_argv(described_class_command_name, required_arg, "--data=input.yml")
|
36
|
+
command.data.should == @data
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should parse data from a JSON input file" do
|
41
|
+
in_tmp_dir do
|
42
|
+
File.open('input.json', 'w') { |f| f.puts @data.to_json }
|
43
|
+
set_argv(described_class_command_name, required_arg, "--data=input.json")
|
44
|
+
command.data.should == @data
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "from stdin" do
|
50
|
+
|
51
|
+
before do
|
52
|
+
@data = { 'foo' => 'bar', 'baz' => { 'booz' => 'bing' } }
|
53
|
+
@old_stdin = $stdin
|
54
|
+
@new_stdin = StringIO.new
|
55
|
+
@stat = mock("stdin stat")
|
56
|
+
@new_stdin.stub!(:stat).and_return(@stat)
|
57
|
+
$stdin = @new_stdin
|
58
|
+
end
|
59
|
+
|
60
|
+
after do
|
61
|
+
$stdin = @old_stdin
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should ignore stdin if it has no data coming in" do
|
65
|
+
@stat.stub!(:size).and_return(0)
|
66
|
+
set_argv(described_class_command_name, required_arg)
|
67
|
+
command.data.should == {}
|
68
|
+
end
|
69
|
+
|
70
|
+
# it "should read YAML data from stdin" do
|
71
|
+
# @new_stdin.puts @data.to_yaml
|
72
|
+
# @stat.stub!(:size).and_return(1)
|
73
|
+
# set_argv(described_class_command_name, required_arg)
|
74
|
+
# command.data.should == @data
|
75
|
+
# end
|
76
|
+
|
77
|
+
# it "should read JSON data from stdin" do
|
78
|
+
# @stat.stub!(:size).and_return(1)
|
79
|
+
# @new_stdin.puts @data.to_json
|
80
|
+
# set_argv(described_class_command_name, required_arg)
|
81
|
+
# command.data.should == @data
|
82
|
+
# end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chimps-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Dhruv Bansal
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-25 00:00:00 -05:00
|
19
|
+
default_executable: chimps
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
name: chimps
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 17
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 3
|
33
|
+
- 1
|
34
|
+
version: 0.3.1
|
35
|
+
requirement: *id001
|
36
|
+
type: :runtime
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
prerelease: false
|
39
|
+
name: configliere
|
40
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 23
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 3
|
49
|
+
- 2
|
50
|
+
version: 0.3.2
|
51
|
+
requirement: *id002
|
52
|
+
type: :runtime
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
prerelease: false
|
55
|
+
name: json
|
56
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirement: *id003
|
66
|
+
type: :runtime
|
67
|
+
description: Chimps CLI provides the command line program 'chimps' which allows you to easily make API calls against Infochimps web services.
|
68
|
+
email: coders@infochimps.com
|
69
|
+
executables:
|
70
|
+
- chimps
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
extra_rdoc_files:
|
74
|
+
- LICENSE
|
75
|
+
- README.rdoc
|
76
|
+
files:
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- LICENSE
|
80
|
+
- README.rdoc
|
81
|
+
- Rakefile
|
82
|
+
- VERSION
|
83
|
+
- bin/chimps
|
84
|
+
- lib/chimps-cli.rb
|
85
|
+
- lib/chimps-cli/commands.rb
|
86
|
+
- lib/chimps-cli/commands/base.rb
|
87
|
+
- lib/chimps-cli/commands/create.rb
|
88
|
+
- lib/chimps-cli/commands/delete.rb
|
89
|
+
- lib/chimps-cli/commands/destroy.rb
|
90
|
+
- lib/chimps-cli/commands/download.rb
|
91
|
+
- lib/chimps-cli/commands/get.rb
|
92
|
+
- lib/chimps-cli/commands/help.rb
|
93
|
+
- lib/chimps-cli/commands/list.rb
|
94
|
+
- lib/chimps-cli/commands/me.rb
|
95
|
+
- lib/chimps-cli/commands/post.rb
|
96
|
+
- lib/chimps-cli/commands/put.rb
|
97
|
+
- lib/chimps-cli/commands/query.rb
|
98
|
+
- lib/chimps-cli/commands/search.rb
|
99
|
+
- lib/chimps-cli/commands/show.rb
|
100
|
+
- lib/chimps-cli/commands/test.rb
|
101
|
+
- lib/chimps-cli/commands/update.rb
|
102
|
+
- lib/chimps-cli/commands/upload.rb
|
103
|
+
- lib/chimps-cli/utils.rb
|
104
|
+
- lib/chimps-cli/utils/acts_on_resource.rb
|
105
|
+
- lib/chimps-cli/utils/explicit_path.rb
|
106
|
+
- lib/chimps-cli/utils/http_format.rb
|
107
|
+
- lib/chimps-cli/utils/uses_param_value_data.rb
|
108
|
+
- spec/chimps-cli/commands/delete_spec.rb
|
109
|
+
- spec/chimps-cli/commands/get_spec.rb
|
110
|
+
- spec/chimps-cli/commands/help_spec.rb
|
111
|
+
- spec/chimps-cli/commands/list_spec.rb
|
112
|
+
- spec/chimps-cli/commands/post_spec.rb
|
113
|
+
- spec/chimps-cli/commands/put_spec.rb
|
114
|
+
- spec/chimps-cli/commands/show_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- spec/support/acts_on_resource.rb
|
117
|
+
- spec/support/explicit_path.rb
|
118
|
+
- spec/support/http_format.rb
|
119
|
+
- spec/support/uses_param_value_data.rb
|
120
|
+
has_rdoc: true
|
121
|
+
homepage: http://github.com/infochimps/chimps-cli
|
122
|
+
licenses: []
|
123
|
+
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
hash: 3
|
135
|
+
segments:
|
136
|
+
- 0
|
137
|
+
version: "0"
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
hash: 3
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
version: "0"
|
147
|
+
requirements: []
|
148
|
+
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 1.3.7
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: Chimps CLI is command-line interface for the Chimps gem (http://www.infochimps.com/labs)
|
154
|
+
test_files:
|
155
|
+
- spec/chimps-cli/commands/delete_spec.rb
|
156
|
+
- spec/chimps-cli/commands/get_spec.rb
|
157
|
+
- spec/chimps-cli/commands/help_spec.rb
|
158
|
+
- spec/chimps-cli/commands/list_spec.rb
|
159
|
+
- spec/chimps-cli/commands/post_spec.rb
|
160
|
+
- spec/chimps-cli/commands/put_spec.rb
|
161
|
+
- spec/chimps-cli/commands/show_spec.rb
|
162
|
+
- spec/spec_helper.rb
|
163
|
+
- spec/support/acts_on_resource.rb
|
164
|
+
- spec/support/explicit_path.rb
|
165
|
+
- spec/support/http_format.rb
|
166
|
+
- spec/support/uses_param_value_data.rb
|