nsicloudooo 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -135,7 +135,7 @@ module NSICloudooo
135
135
  #
136
136
  #
137
137
  # @param [String] key of the desired document
138
- # @return [String] key of the desired document's thumbnail
138
+ # @return [String] key of the desired document's thumbnail
139
139
  #
140
140
  # @example
141
141
  # nsicloudooo.thumbnail_key_for("some key")
@@ -149,10 +149,47 @@ module NSICloudooo
149
149
  execute_request(request)["thumbnail"]
150
150
  end
151
151
 
152
+
153
+ # Enqueue a document to have its metadata extracted
154
+ #
155
+ #
156
+ # @param [String] key of the desired document
157
+ # @param [String] type of the desired document ('tcc' or 'event')
158
+ # @return [Hash] response
159
+ # * "doc_key" [String] the key to access the granulated document if the sam node it was stored
160
+ #
161
+ # @raise NSICloudooo::Errors::Client::MissingParametersError when an invalid or incomplete set of parameters is provided
162
+ # @raise NSICloudooo::Errors::Client::SAMConnectionError when cannot connect to the SAM node
163
+ # @raise NSICloudooo::Errors::Client::AuthenticationError when invalids user and/or password are provided
164
+ # @raise NSICloudooo::Errors::Client::KeyNotFoundError when an invalid sam_uid is provided
165
+ #
166
+ def extract_metadata(document_key, type)
167
+ request = prepare_request :POST, {:sam_uid => document_key, :type => type, :metadata => true}.to_json
168
+ execute_request(request)
169
+ end
170
+
171
+ # Return the key of the metadata of a document
172
+ #
173
+ #
174
+ # @param [String] key of the desired document
175
+ # @return [String] key of the desired document's metadata or false if the metadata wasn't extracted yet
176
+ #
177
+ # @example
178
+ # nsicloudooo.metadata_key_for("some key")
179
+ #
180
+ # @raise NSICloudooo::Errors::Client::SAMConnectionError when cannot connect to the SAM node
181
+ # @raise NSICloudooo::Errors::Client::AuthenticationError when invalids user and/or password are provided
182
+ # @raise NSICloudooo::Errors::Client::KeyNotFoundError when an invalid key is provided
183
+ #
184
+ def metadata_key_for(document_key)
185
+ request = prepare_request :GET, {:doc_key => document_key, :metadata => true}.to_json
186
+ execute_request(request)["metadata_key"]
187
+ end
188
+
152
189
  # Pre-configure the NSICloudooo module with default params for the NSICloudooo::Client
153
190
  #
154
191
  # @yield a Configuration object (see {NSICloudooo::Client::Configuration})
155
- #
192
+ #
156
193
  # @example
157
194
  # NSICloudooo::Client.configure do
158
195
  # user "why"
@@ -16,6 +16,10 @@ module NSICloudooo
16
16
  filename = incoming["filename"]
17
17
  filename = File.basename(incoming["doc_link"]) if incoming.has_key? "doc_link"
18
18
  callback = incoming["callback"] || nil
19
+ metadata = incoming['metadata']
20
+ unless metadata.nil?
21
+ return {doc_key: incoming["sam_uid"]}.to_json
22
+ end
19
23
  verb = incoming["verb"] || nil
20
24
  if filename.include? "secs"
21
25
  seconds = filename.split(".")[0].delete("secs").to_i
@@ -41,6 +45,9 @@ module NSICloudooo
41
45
  return {done: true}.to_json
42
46
  end
43
47
  elsif incoming.has_key? "doc_key"
48
+ if incoming.has_key? "metadata"
49
+ return {"metadata_key" => "metadata for #{incoming['doc_key']}"}.to_json
50
+ end
44
51
  return {:images => [], :files => [], :thumbnail => ['thumbnail key',]}.to_json
45
52
  end
46
53
  return 404 if incoming["key"].include? "dont"
data/nsicloudooo.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "nsicloudooo"
8
- s.version = "0.4.1"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Douglas Camata"]
12
- s.date = "2012-07-31"
12
+ s.date = "2012-12-04"
13
13
  s.description = "A simple gem to access a nsi.cloudooo node"
14
14
  s.email = "d.camata@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -101,6 +101,18 @@ describe NSICloudooo do
101
101
 
102
102
  end
103
103
 
104
+ context "metadata extraction" do
105
+ it "can enqueue documents already stored to metadata extraction" do
106
+ response = @nsicloudooo.extract_metadata('some key', 'tcc')
107
+ response["doc_key"].should == 'some key'
108
+ end
109
+
110
+ it "can access the metadata key when it's already extracted" do
111
+ response = @nsicloudooo.extract_metadata('some key', 'tcc')
112
+ @nsicloudooo.metadata_key_for(response["doc_key"]).should == "metadata for #{response["doc_key"]}"
113
+ end
114
+ end
115
+
104
116
  context "get configuration" do
105
117
  before do
106
118
  NSICloudooo::Client.configure do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nsicloudooo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
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: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2012-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  segments:
148
148
  - 0
149
- hash: 1653432833353157753
149
+ hash: -3981209681326791150
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  none: false
152
152
  requirements: