chimps 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -9
- data/Gemfile.lock +14 -10
- data/README.rdoc +146 -240
- data/Rakefile +4 -33
- data/VERSION +1 -1
- data/lib/chimps/config.rb +35 -21
- data/lib/chimps/{utils/error.rb → error.rb} +1 -12
- data/lib/chimps/query_request.rb +67 -0
- data/lib/chimps/request.rb +82 -108
- data/lib/chimps/response.rb +62 -22
- data/lib/chimps/utils/typewriter.rb +90 -0
- data/lib/chimps/utils/uses_curl.rb +22 -12
- data/lib/chimps/utils.rb +50 -6
- data/lib/chimps/workflows/download.rb +72 -0
- data/lib/chimps/workflows/upload.rb +113 -0
- data/lib/chimps.rb +12 -12
- data/spec/chimps/query_request_spec.rb +44 -0
- data/spec/chimps/request_spec.rb +92 -0
- data/spec/chimps/response_spec.rb +0 -1
- data/spec/chimps/workflows/download_spec.rb +48 -0
- data/spec/spec_helper.rb +2 -19
- metadata +46 -91
- data/.document +0 -5
- data/.gitignore +0 -32
- data/CHANGELOG.textile +0 -4
- data/bin/chimps +0 -5
- data/lib/chimps/cli.rb +0 -28
- data/lib/chimps/commands/base.rb +0 -65
- data/lib/chimps/commands/batch.rb +0 -40
- data/lib/chimps/commands/create.rb +0 -31
- data/lib/chimps/commands/destroy.rb +0 -26
- data/lib/chimps/commands/download.rb +0 -46
- data/lib/chimps/commands/help.rb +0 -100
- data/lib/chimps/commands/list.rb +0 -41
- data/lib/chimps/commands/query.rb +0 -82
- data/lib/chimps/commands/search.rb +0 -48
- data/lib/chimps/commands/show.rb +0 -30
- data/lib/chimps/commands/test.rb +0 -39
- data/lib/chimps/commands/update.rb +0 -34
- data/lib/chimps/commands/upload.rb +0 -50
- data/lib/chimps/commands.rb +0 -125
- data/lib/chimps/typewriter.rb +0 -349
- data/lib/chimps/utils/log.rb +0 -48
- data/lib/chimps/utils/uses_model.rb +0 -34
- data/lib/chimps/utils/uses_yaml_data.rb +0 -93
- data/lib/chimps/workflows/batch.rb +0 -127
- data/lib/chimps/workflows/downloader.rb +0 -102
- data/lib/chimps/workflows/up.rb +0 -149
- data/lib/chimps/workflows/upload/bundler.rb +0 -249
- data/lib/chimps/workflows/upload/notifier.rb +0 -59
- data/lib/chimps/workflows/upload/token.rb +0 -77
- data/lib/chimps/workflows/upload/uploader.rb +0 -51
- data/lib/chimps/workflows.rb +0 -12
- data/spec/chimps/typewriter_spec.rb +0 -114
- data/spec/chimps/workflows/upload/bundler_spec.rb +0 -75
- data/spec/chimps/workflows/upload/token_spec.rb +0 -6
@@ -1,114 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
-
|
3
|
-
describe Chimps::Typewriter do
|
4
|
-
|
5
|
-
def dataset_1
|
6
|
-
{
|
7
|
-
'dataset' => {
|
8
|
-
'id' => 39293,
|
9
|
-
'cached_slug' => 'my-awesome-dataset',
|
10
|
-
'updated_at' => 'tomorrow',
|
11
|
-
'title' => 'My Awesome Dataset'
|
12
|
-
}
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
def dataset_2
|
17
|
-
{
|
18
|
-
'dataset' => {
|
19
|
-
'id' => 28998,
|
20
|
-
'cached_slug' => 'my-other-awesome-dataset',
|
21
|
-
'updated_at' => 'yesterday',
|
22
|
-
'title' => 'My Other Awesome Dataset'
|
23
|
-
}
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def source
|
28
|
-
{} # FIXME
|
29
|
-
end
|
30
|
-
|
31
|
-
def license
|
32
|
-
{} # FIXME
|
33
|
-
end
|
34
|
-
|
35
|
-
def resource
|
36
|
-
dataset_1
|
37
|
-
end
|
38
|
-
|
39
|
-
def resource_listing
|
40
|
-
[ dataset_1, dataset_2 ]
|
41
|
-
end
|
42
|
-
|
43
|
-
def errors
|
44
|
-
[
|
45
|
-
"A title is required.",
|
46
|
-
"A description is required."
|
47
|
-
]
|
48
|
-
end
|
49
|
-
|
50
|
-
def batch
|
51
|
-
[
|
52
|
-
{
|
53
|
-
'status' => 'created',
|
54
|
-
'resource' => resource,
|
55
|
-
'errors' => nil,
|
56
|
-
'local_paths' => []
|
57
|
-
},
|
58
|
-
{
|
59
|
-
'status' => 'invalid',
|
60
|
-
'errors' => errors
|
61
|
-
}
|
62
|
-
]
|
63
|
-
end
|
64
|
-
|
65
|
-
def search
|
66
|
-
{
|
67
|
-
'results' => [
|
68
|
-
{ 'dataset' => dataset_1 },
|
69
|
-
{ 'dataset' => dataset_2 }
|
70
|
-
]
|
71
|
-
}
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
def api_account
|
76
|
-
{
|
77
|
-
'api_key' => "tie5TeeNei2aigie",
|
78
|
-
'owner' => {
|
79
|
-
'username' => 'Infochimps'
|
80
|
-
},
|
81
|
-
'updated_at' => 'now'
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
before { @typewriter = Chimps::Typewriter.new([]) }
|
88
|
-
|
89
|
-
describe "formatting output" do
|
90
|
-
|
91
|
-
before do
|
92
|
-
@typewriter.concat([["short", "medium", "very_very_very_long"],
|
93
|
-
["medium", "very_very_long", "short"],
|
94
|
-
"Some totally long but also ignored string", # ignores strings
|
95
|
-
["very_long", ""]]) # doesn't mind mixed size rows
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should calculate its column widths before printing" do
|
99
|
-
$stdout = File.open('/dev/null', 'w')
|
100
|
-
@typewriter.print($stdout)
|
101
|
-
@typewriter.column_widths.should_not be_empty
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should correctly calculate its column widths" do
|
105
|
-
@typewriter.send(:calculate_column_widths!)
|
106
|
-
@typewriter.column_widths.should == ["very_long", "very_very_long", "very_very_very_long"].map(&:size)
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
end
|
114
|
-
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../../../spec_helper')
|
2
|
-
|
3
|
-
describe Chimps::Workflows::Upload::Bundler do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@dataset = 'foobar'
|
7
|
-
@extant_path = File.expand_path("extant_file.txt")
|
8
|
-
@non_extant_path = File.expand_path("non_extant_file.txt")
|
9
|
-
@archive_path = File.expand_path("archive.tar.bz2")
|
10
|
-
@extant_archive_path = File.expand_path("extant_archive.tar.bz2")
|
11
|
-
|
12
|
-
|
13
|
-
File.open(@extant_path, 'w') { |f| f.write("some content") }
|
14
|
-
File.open(@extant_archive_path, 'w') { |f| f.write("some, admittedly not very tar.bz2'ish, content") }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "setting the format of a bundle of input paths" do
|
18
|
-
it "should accept a format when given" do
|
19
|
-
bundler = Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_path], :fmt => 'foobar')
|
20
|
-
bundler.fmt.should == 'foobar'
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should guess a format when one isn't given" do
|
24
|
-
bundler = Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_path])
|
25
|
-
bundler.fmt.should == 'txt'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "setting the archive from a bundle of input paths" do
|
30
|
-
|
31
|
-
it "should automatically set the archive path when given no other information" do
|
32
|
-
bundler = Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_path])
|
33
|
-
File.basename(bundler.archive.path).should =~ /^chimps_/
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should use a valid archive path when given one" do
|
37
|
-
bundler = Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_path], :archive => 'foo.tar.bz2')
|
38
|
-
File.basename(bundler.archive.path).should == 'foo.tar.bz2'
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should raise an error when given a non-package or compressed-file archive path" do
|
42
|
-
lambda { Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_path], :archive => 'foo.txt') }.should raise_error(Chimps::PackagingError)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should raise an error when given a compressed-file archive path with multiple input paths" do
|
46
|
-
lambda { Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_path, @extant_archive_path], :archive => 'foo.bz2') }.should raise_error(Chimps::PackagingError)
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "processing input paths" do
|
52
|
-
|
53
|
-
it "should raise an error when no paths are given" do
|
54
|
-
lambda { Chimps::Workflows::Upload::Bundler.new(@dataset, []) }.should raise_error(Chimps::PackagingError)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should raise an error when given a local path which doesn't exist" do
|
58
|
-
lambda { Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_path, @non_extant_path]) }.should raise_error(IMW::PathError)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should set its archive path and skip packaging when passed a single, extant archive path" do
|
62
|
-
bundler = Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_archive_path])
|
63
|
-
bundler.skip_packaging?.should be_true
|
64
|
-
bundler.archive.path.should == @extant_archive_path
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should prefer the explicitly passed in archive path to the implicitly seleced archive path when passed a 1-path input array consisting of an archive as well as the :archive option" do
|
68
|
-
bundler = Chimps::Workflows::Upload::Bundler.new(@dataset, [@extant_archive_path], :archive => "foo.tar.bz2")
|
69
|
-
File.basename(bundler.archive.path).should == 'foo.tar.bz2'
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|