groupdocs 1.2.2 → 1.2.3

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.
@@ -140,6 +140,34 @@ module GroupDocs
140
140
  signed_documents
141
141
  end
142
142
 
143
+ #
144
+ # Returns a document metadata by given path.
145
+ #
146
+ # @param [String] path Full path to document
147
+ # @param [Hash] access Access credentials
148
+ # @option access [String] :client_id
149
+ # @option access [String] :private_key
150
+ # @return [Array<GroupDocs::Document::View>]
151
+ #
152
+ def self.metadata!(path, access = {})
153
+ json = Api::Request.new do |request|
154
+ request[:access] = access
155
+ request[:method] = :GET
156
+ request[:path] = "/doc/{{client_id}}/files/#{path}"
157
+ end.execute!
158
+
159
+ Document::MetaData.new do |metadata|
160
+ metadata.id = json[:id]
161
+ metadata.guid = json[:guid]
162
+ metadata.page_count = json[:page_count]
163
+ metadata.views_count = json[:views_count]
164
+ if json[:last_view]
165
+ metadata.last_view = json[:last_view]
166
+ metadata.last_view.document = new(file: Storage::File.new(json))
167
+ end
168
+ end
169
+ end
170
+
143
171
  # @attr [GroupDocs::Storage::File] file
144
172
  attr_accessor :file
145
173
  # @attr [Time] process_date
@@ -1,3 +1,3 @@
1
1
  module GroupDocs
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  end # GroupDocs
@@ -121,6 +121,31 @@ describe GroupDocs::Document do
121
121
  end
122
122
  end
123
123
 
124
+ describe ',metadata!' do
125
+ before(:each) do
126
+ mock_api_server(load_json('document_metadata'))
127
+ end
128
+
129
+ it 'accepts access credentials hash' do
130
+ lambda do
131
+ described_class.metadata!('document_one.doc', client_id: 'client_id', private_key: 'private_key')
132
+ end.should_not raise_error(ArgumentError)
133
+ end
134
+
135
+ it 'returns GroupDocs::Document::MetaData object' do
136
+ described_class.metadata!('document_one.doc').should be_a(GroupDocs::Document::MetaData)
137
+ end
138
+
139
+ it 'sets last view as GroupDocs::Document::View object if document was viewed at least once' do
140
+ described_class.metadata!('document_one.doc').last_view.should be_a(GroupDocs::Document::View)
141
+ end
142
+
143
+ it 'does not set last view if document has never been viewed' do
144
+ mock_api_server('{ "status": "Ok", "result": { "last_view": null }}')
145
+ described_class.metadata!('document_one.doc').last_view.should be_nil
146
+ end
147
+ end
148
+
124
149
  it { should have_accessor(:file) }
125
150
  it { should have_accessor(:process_date) }
126
151
  it { should have_accessor(:outputs) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupdocs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -422,7 +422,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
422
422
  version: '0'
423
423
  segments:
424
424
  - 0
425
- hash: -621879364264010468
425
+ hash: 568401921435177902
426
426
  required_rubygems_version: !ruby/object:Gem::Requirement
427
427
  none: false
428
428
  requirements:
@@ -431,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
431
431
  version: '0'
432
432
  segments:
433
433
  - 0
434
- hash: -621879364264010468
434
+ hash: 568401921435177902
435
435
  requirements: []
436
436
  rubyforge_project:
437
437
  rubygems_version: 1.8.24