cdd 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -2
- data/lib/cdd/search.rb +5 -4
- data/lib/cdd/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -100,7 +100,7 @@ vaults = cdd.vaults
|
|
100
100
|
vault = vaults.first
|
101
101
|
search = vault.searches.first
|
102
102
|
projects = vault.projects
|
103
|
-
search.export(projects, "sdf") do |data|
|
103
|
+
search.export(projects, [], "sdf") do |data|
|
104
104
|
puts data
|
105
105
|
end
|
106
106
|
```
|
@@ -109,6 +109,8 @@ end
|
|
109
109
|
|
110
110
|
The synchronous export method is provided as a courtesy. If you could be exporting any non-trivial amount of data, you should use the aynchronous method.
|
111
111
|
|
112
|
+
In this example, we will use publicly accessible data sets, this should result in a larger result set (and why we are using the )
|
113
|
+
|
112
114
|
To begin an export using the method ```Search#start_export```. This will return an ```Export``` object which can be polled or used to retrieve data.
|
113
115
|
|
114
116
|
```ruby
|
@@ -119,7 +121,8 @@ vaults = cdd.vaults
|
|
119
121
|
vault = vaults.first
|
120
122
|
search = vault.searches.first
|
121
123
|
projects = vault.projects
|
122
|
-
|
124
|
+
data_sets = vault.data_sets
|
125
|
+
export = search.start_export(projects, data_sets, "sdf")
|
123
126
|
export_state = export.poll
|
124
127
|
puts export_state["status"]
|
125
128
|
```
|
data/lib/cdd/search.rb
CHANGED
@@ -3,15 +3,16 @@ module CDD
|
|
3
3
|
attr_accessor :name
|
4
4
|
attr_accessor :vault
|
5
5
|
|
6
|
-
def start_export(projects=[], format="csv")
|
6
|
+
def start_export(projects=[], data_sets=[], format="csv")
|
7
7
|
project_ids = projects.collect { |p| p.id }
|
8
|
-
|
8
|
+
data_set_ids = data_sets.collect { |ds| ds.id }
|
9
|
+
params = { :search => self.id, :projects => project_ids.join(","), :data_sets => data_set_ids.join(",") }
|
9
10
|
result = JSON.parse(RestClient.post("#{client.url}#{vault.export_url(format)}", params, { "X-CDD-Token" => client.token }))
|
10
11
|
CDD::Export.new(client, { :search => self, :vault => vault, :format => format }.merge(result))
|
11
12
|
end
|
12
13
|
|
13
|
-
def export(projects=[], format="csv", &block)
|
14
|
-
e = start_export(projects, format)
|
14
|
+
def export(projects=[], data_sets=[], format="csv", &block)
|
15
|
+
e = start_export(projects, data_sets, format)
|
15
16
|
state = e.poll
|
16
17
|
while ["new", "started", "starting"].include?(state["status"]) do
|
17
18
|
state = e.poll
|
data/lib/cdd/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
segments:
|
116
116
|
- 0
|
117
|
-
hash:
|
117
|
+
hash: -2196299000825545808
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
segments:
|
125
125
|
- 0
|
126
|
-
hash:
|
126
|
+
hash: -2196299000825545808
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
129
|
rubygems_version: 1.8.24
|