dewey 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,22 @@
1
+ ## 0.2.4 (November 2, 2010)
2
+
3
+ Additions:
4
+
5
+ - Support downloading drawings
6
+ - Support downloading presentations
7
+ - Drawing mime support and validation
8
+ - put! method to raise on failed requests
9
+
10
+ Changes:
11
+
12
+ - Add support for new style export options (exportFormat & format)
13
+
14
+ Bugfixes:
15
+
16
+ - Fix search results pulling the feed id and not just the entry id
17
+ - Fix entries pulling the feed along with the resource id
18
+ - Remove calls to blank?
19
+
1
20
  ## 0.2.3 (October 30, 2010)
2
21
 
3
22
  Additions:
data/README.md CHANGED
@@ -1,21 +1,23 @@
1
1
  ::::::::: :::::::::: ::: ::: :::::::::: ::: :::
2
2
  :+: :+: :+: :+: :+: :+: :+: :+:
3
- +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+
4
- +#+ +:+ +#++:++# +#+ +:+ +#+ +#++:++# +#++:
5
- +#+ +#+ +#+ +#+ +#+#+ +#+ +#+ +#+
6
- #+# #+# #+# #+#+# #+#+# #+# #+#
3
+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+
4
+ +#+ +:+ +#++:++# +#+ +:+ +#+ +#++:++# +#++:
5
+ +#+ +#+ +#+ +#+ +#+#+ +#+ +#+ +#+
6
+ #+# #+# #+# #+#+# #+#+# #+# #+#
7
7
  ######### ########## ### ### ########## ###
8
8
 
9
- Dewey allows you to simply upload, download and delete files from your Google
10
- Docs account.
11
9
 
12
- Let Google do all of the hard work of converting your documents!
10
+ # Light, simple Google Docs library for Ruby.
11
+
12
+ Dewey focuses on the simple cases of authorizing, searching, and managing the
13
+ files on a Google Docs account. Really, it stemmed from the need to use Docs
14
+ great document conversion services.
13
15
 
14
16
  ## Note
15
17
 
16
18
  Dewey is in alpha. It is not recommended you use this in production code.
17
19
 
18
- ## Authorization
20
+ ## Authentication
19
21
 
20
22
  You can configure Dewey to connect with either ClientLogin or OAuth. If you choose
21
23
  OAuth you'll only have to authenticate the first time you connect and subsequent
@@ -23,11 +25,11 @@ connections will use the saved token.
23
25
 
24
26
  ClientLogin
25
27
 
26
- Dewey.authorization :client, :email => 'example@gmail.com', :password => 'password'
27
-
28
+ Dewey.authentication :client, :email => 'example@gmail.com', :password => 'password'
29
+
28
30
  OAuth
29
31
 
30
- Dewey.authorization :oauth, :idontknowwhatgoeshereyet
32
+ Dewey.authentication :oauth, :idontknowwhatgoeshereyet
31
33
 
32
34
  ## File Operations
33
35
 
@@ -3,9 +3,11 @@ module Dewey
3
3
  GOOGLE_SPRD_URL = "https://spreadsheets.google.com"
4
4
  GOOGLE_LOGIN_URL = "https://www.google.com/accounts/ClientLogin"
5
5
 
6
- GOOGLE_FEED_URL = GOOGLE_DOCS_URL + "/feeds/default/private/full"
7
- GOOGLE_DOCUMENT_URL = GOOGLE_DOCS_URL + "/feeds/download/documents/Export"
8
- GOOGLE_SPREADSHEET_URL = GOOGLE_SPRD_URL + "/feeds/download/spreadsheets/Export"
6
+ GOOGLE_FEED_URL = GOOGLE_DOCS_URL + "/feeds/default/private/full"
7
+ GOOGLE_DOCUMENT_URL = GOOGLE_DOCS_URL + "/feeds/download/documents/Export"
8
+ GOOGLE_DRAWING_URL = GOOGLE_DOCS_URL + "/feeds/download/drawings/Export"
9
+ GOOGLE_PRESENTATION_URL = GOOGLE_DOCS_URL + "/feeds/download/presentations/Export"
10
+ GOOGLE_SPREADSHEET_URL = GOOGLE_SPRD_URL + "/feeds/download/spreadsheets/Export"
9
11
 
10
12
  class DeweyException < Exception; end
11
13
  class DeweyAuthorizationException < Exception; end
@@ -17,4 +19,4 @@ require 'dewey/https'
17
19
  require 'dewey/mime'
18
20
  require 'dewey/utils'
19
21
  require 'dewey/validation'
20
- require 'dewey/version'
22
+ require 'dewey/version'
@@ -58,7 +58,7 @@ module Dewey
58
58
  # @option options [Symbol] :title An alternative title, to be used instead
59
59
  # of the filename
60
60
  #
61
- # @return [String, Boolean] The id if upload was successful, false otherwise
61
+ # @return [String, nil] The id if upload was successful, nil otherwise
62
62
  def put(file, options = {})
63
63
  extension = File.extname(file.path).sub('.', '')
64
64
  basename = File.basename(file.path, ".#{extension}")
@@ -81,10 +81,14 @@ module Dewey
81
81
  if response.kind_of?(Net::HTTPCreated)
82
82
  extract_ids(response.body).first
83
83
  else
84
- false
84
+ nil
85
85
  end
86
86
  end
87
87
 
88
+ def put!(file, options = {})
89
+ put(file, options) || raise(DeweyException, "Unable to put document")
90
+ end
91
+
88
92
  # Download a file. You may optionally specify a format for export.
89
93
  #
90
94
  # @param [String] query A resource id or title, `document:12345` or
@@ -111,14 +115,23 @@ module Dewey
111
115
  when 'document'
112
116
  url << GOOGLE_DOCUMENT_URL
113
117
  url << "?docID=#{id}"
118
+ when 'drawing'
119
+ url << GOOGLE_DRAWING_URL
120
+ url << "?docID=#{id}"
121
+ when 'presentation'
122
+ url << GOOGLE_PRESENTATION_URL
123
+ url << "?docID=#{id}"
114
124
  when 'spreadsheet'
115
125
  url << GOOGLE_SPREADSHEET_URL
116
126
  url << "?key=#{id}"
127
+ else
128
+ raise DeweyException, "Invalid service: #{service}"
117
129
  end
118
130
 
119
- unless format.blank?
131
+ unless format.empty?
120
132
  if Dewey::Validation.valid_export_format?(format, service)
121
- url << "&exportFormat=#{format}" unless format.blank?
133
+ url << "&exportFormat=#{format}"
134
+ url << "&format=#{format}" if service == 'document'
122
135
  else
123
136
  raise DeweyException, "Invalid format: #{format}"
124
137
  end
@@ -257,12 +270,12 @@ module Dewey
257
270
  # @return [Array] Array of document ids
258
271
  def extract_ids(response) #:nodoc:
259
272
  xml = REXML::Document.new(response)
260
- xml.elements.collect('//id') { |e| e.text.gsub('%3A', ':') }.reject(&:blank?)
273
+ xml.elements.collect('//entry//id') { |e| e.text.split('/').last.gsub('%3A', ':') }
261
274
  end
262
275
 
263
276
  # Is the string an id or a search query?
264
277
  def is_id?(string)
265
- string.match(/^(doc|spr|pres).+:.+$/)
278
+ string.match(/^[a-z]+:.+$/)
266
279
  end
267
280
  end
268
281
  end
@@ -11,6 +11,12 @@ module Dewey
11
11
  :sxw => 'application/vnd.sun.xml.writer',
12
12
  :txt => 'text/plain'
13
13
  }
14
+
15
+ DRAWING_MIMETYPES = {
16
+ :jpeg => 'image/jpeg',
17
+ :png => 'image/png',
18
+ :svg => 'image/svg+xml'
19
+ }
14
20
 
15
21
  PRESENTATION_MIMETYPES = {
16
22
  :pps => 'application/vnd.ms-powerpoint',
@@ -36,13 +42,16 @@ module Dewey
36
42
  when /csv/ then SPREADSHEET_MIMETYPES[:csv]
37
43
  when /doc$/ then DOCUMENT_MIMETYPES[:doc]
38
44
  when /docx/ then DOCUMENT_MIMETYPES[:docx]
45
+ when /jpeg/ then DRAWING_MIMETYPES[:jpeg]
39
46
  when /htm/ then DOCUMENT_MIMETYPES[:html]
40
47
  when /ods/ then SPREADSHEET_MIMETYPES[:ods]
41
48
  when /odt/ then DOCUMENT_MIMETYPES[:odt]
42
49
  when /pdf/ then DOCUMENT_MIMETYPES[:pdf]
50
+ when /png/ then DRAWING_MIMETYPES[:png]
43
51
  when /pps/ then PRESENTATION_MIMETYPES[:pps]
44
52
  when /ppt/ then PRESENTATION_MIMETYPES[:ppt]
45
53
  when /rtf/ then DOCUMENT_MIMETYPES[:rtf]
54
+ when /svg/ then DRAWING_MIMETYPES[:svg]
46
55
  when /sxw/ then DOCUMENT_MIMETYPES[:sxw]
47
56
  when /tab/ then SPREADSHEET_MIMETYPES[:tab]
48
57
  when /tsv/ then SPREADSHEET_MIMETYPES[:tsv]
@@ -66,6 +75,7 @@ module Dewey
66
75
 
67
76
  def self.guess_service(mime_type)
68
77
  services = { :document => DOCUMENT_MIMETYPES,
78
+ :drawing => DRAWING_MIMETYPES,
69
79
  :presentation => PRESENTATION_MIMETYPES,
70
80
  :spreadsheet => SPREADSHEET_MIMETYPES }
71
81
 
@@ -76,4 +86,4 @@ module Dewey
76
86
  nil
77
87
  end
78
88
  end
79
- end
89
+ end
@@ -1,6 +1,7 @@
1
1
  module Dewey
2
2
 
3
3
  DOCUMENT_EXPORT_FORMATS = [:txt, :odt, :pdf, :html, :rtf, :doc, :png, :zip]
4
+ DRAWING_EXPORT_FORMATS = [:jpeg, :pdf, :png, :svg]
4
5
  PRESENTATION_EXPORT_FORMATS = [:swf, :pdf, :png, :ppt]
5
6
  SPREADSHEET_EXPORT_FORMATS = [:xls, :csv, :pdf, :ods, :tsv, :html]
6
7
 
@@ -24,6 +25,7 @@ module Dewey
24
25
 
25
26
  case service
26
27
  when :document then Dewey::DOCUMENT_MIMETYPES.has_key?(format)
28
+ when :drawing then Dewey::DRAWING_MIMETYPES.has_key?(format)
27
29
  when :presentation then Dewey::PRESENTATION_MIMETYPES.has_key?(format)
28
30
  when :spreadsheet then Dewey::SPREADSHEET_MIMETYPES.has_key?(format)
29
31
  else
@@ -46,6 +48,7 @@ module Dewey
46
48
 
47
49
  case service
48
50
  when :document then Dewey::DOCUMENT_EXPORT_FORMATS.include?(format)
51
+ when :drawing then Dewey::DRAWING_EXPORT_FORMATS.include?(format)
49
52
  when :presentation then Dewey::PRESENTATION_EXPORT_FORMATS.include?(format)
50
53
  when :spreadsheet then Dewey::SPREADSHEET_EXPORT_FORMATS.include?(format)
51
54
  else
@@ -1,3 +1,3 @@
1
1
  module Dewey
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Parker Selbert
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-30 00:00:00 -05:00
17
+ date: 2010-11-02 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,20 @@ dependencies:
30
30
  version: "0"
31
31
  type: :development
32
32
  version_requirements: *id001
33
- description: Dewey is a no-frills tool for utilizing Google Docs ability to convert documents between formats
33
+ - !ruby/object:Gem::Dependency
34
+ name: webmock
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ description: Light, simple Google Docs library for Ruby.
34
47
  email:
35
48
  - parker@sorentwo.com
36
49
  executables: []
@@ -83,6 +96,6 @@ rubyforge_project: dewey
83
96
  rubygems_version: 1.3.7
84
97
  signing_key:
85
98
  specification_version: 3
86
- summary: Google Docs fueled document conversion
99
+ summary: Simple Google Docs library.
87
100
  test_files: []
88
101