Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove the group_by_revisions stuff, it belongs in its own method

  • Loading branch information...
commit c32a3bcc3ff45e6d4d71452f50ac5c8c3eb7e7d0 1 parent 6af334c
@henrikhodne henrikhodne authored
Showing with 2 additions and 46 deletions.
  1. +2 −27 lib/context-io/file.rb
  2. +0 −19 spec/file_spec.rb
View
29 lib/context-io/file.rb
@@ -100,13 +100,6 @@ class File < Resource
# @option query [#to_i] :indexed_after Only include files attached to
# messages indexed after this timestamp. This is not the same as the date
# of the email, it is the time Context.IO indexed this message.
- # @option query [true, false] :group_by_revisions (false) If this is set to
- # true, the method will return an array of Hashes, where each Hash
- # represents a group of revisions of the same file. The Hash has an
- # `:occurences` field, which is an Array of {File} objects, a `:file_name`
- # field, which is the name of the file, and a `:latest_date` field, which
- # is a Time object representing the last time a message with this file was
- # sent.
# @option query [#to_i] :limit The maximum count of results to return.
# @option query [#to_i] :offset (0) The offset to begin returning files at.
#
@@ -125,9 +118,7 @@ class File < Resource
# @example Find JP(E)G files
# files = ContextIO::File.all(account, :file_name => /\.jpe?g$/)
#
- # @return [Array<File>, Array<Hash>] The matching file objects. If the
- # `:group_by_revisions` flag is set, the return value changes, see the
- # documentation for that flag above.
+ # @return [Array<File>] The matching file objects.
def self.all(account, query={})
if query[:file_name] && query[:file_name].is_a?(Regexp)
query[:file_name] = "/#{query[:file_name].source}/"
@@ -139,25 +130,9 @@ def self.all(account, query={})
end
end
- if query[:group_by_revisions]
- query[:group_by_revisions] = query[:group_by_revisions] ? '1' : '0'
- end
-
account_id = account.is_a?(Account) ? account.id : account.to_s
get("/2.0/accounts/#{account_id}/files", query).map do |file|
- if query[:group_by_revisions]
- occurences = file['occurences'].map do |file|
- File.from_json(account_id, file)
- end
-
- {
- :occurences => occurences,
- :file_name => file['file_name'],
- :latest_date => Time.at(file['latest_date'].to_i)
- }
- else
- File.from_json(account_id, file)
- end
+ File.from_json(account_id, file)
end
end
View
19 spec/file_spec.rb
@@ -52,25 +52,6 @@
@request.should have_been_requested
end
-
- context 'group_by_revisions' do
- before(:each) do
- json_files = File.read(File.join(@fixtures_path, 'files_group.json'))
- @request = stub_request(:get, @files_url).
- with(:query => { :group_by_revisions => '1' }).
- to_return(:body => json_files)
- end
-
- it 'converts occurences to File objects' do
- files = ContextIO::File.all(@account, :group_by_revisions => true)
- files.first[:occurences].first.should be_a(ContextIO::File)
- end
-
- it 'converts latest_date to a Time object' do
- files = ContextIO::File.all(@account, :group_by_revisions => true)
- files.first[:latest_date].should be_a(Time)
- end
- end
end
describe '#content' do
Please sign in to comment.
Something went wrong with that request. Please try again.