tumblr-rb 1.3.0 → 2.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.travis.yml +7 -0
  2. data/Gemfile +15 -8
  3. data/Gemfile.lock +65 -65
  4. data/LICENSE +4 -2
  5. data/README.md +31 -84
  6. data/Rakefile +8 -68
  7. data/bin/tumblr +3 -133
  8. data/lib/tumblr.rb +7 -184
  9. data/lib/tumblr/authentication.rb +71 -0
  10. data/lib/tumblr/client.rb +148 -0
  11. data/lib/tumblr/command_line_interface.rb +222 -0
  12. data/lib/tumblr/credentials.rb +31 -0
  13. data/lib/tumblr/post.rb +253 -171
  14. data/lib/tumblr/post/answer.rb +17 -0
  15. data/lib/tumblr/post/audio.rb +22 -10
  16. data/lib/tumblr/post/chat.rb +25 -0
  17. data/lib/tumblr/post/link.rb +22 -9
  18. data/lib/tumblr/post/photo.rb +29 -10
  19. data/lib/tumblr/post/quote.rb +17 -10
  20. data/lib/tumblr/post/text.rb +18 -0
  21. data/lib/tumblr/post/video.rb +26 -11
  22. data/lib/tumblr/version.rb +3 -0
  23. data/lib/tumblr/views/error.erb +6 -0
  24. data/lib/tumblr/views/form.erb +11 -0
  25. data/lib/tumblr/views/layout.erb +41 -0
  26. data/lib/tumblr/views/success.erb +6 -0
  27. data/man/tumblr.1 +67 -65
  28. data/man/tumblr.1.html +131 -108
  29. data/man/tumblr.1.ronn +76 -57
  30. data/man/tumblr.5 +48 -68
  31. data/man/tumblr.5.html +106 -114
  32. data/man/tumblr.5.ronn +38 -51
  33. data/spec/fixtures/posts.json +10 -0
  34. data/spec/fixtures/typical_animated_gif.gif +0 -0
  35. data/spec/spec_helper.rb +12 -0
  36. data/spec/tumblr/authentication_spec.rb +57 -0
  37. data/spec/tumblr/client_spec.rb +223 -0
  38. data/spec/tumblr/credentials_spec.rb +63 -0
  39. data/spec/tumblr/post_spec.rb +125 -0
  40. data/tumblr-rb.gemspec +16 -89
  41. metadata +101 -102
  42. data/lib/tumblr/authenticator.rb +0 -18
  43. data/lib/tumblr/post/conversation.rb +0 -15
  44. data/lib/tumblr/post/regular.rb +0 -14
  45. data/lib/tumblr/reader.rb +0 -191
  46. data/lib/tumblr/writer.rb +0 -39
  47. data/test/fixtures/vcr_cassettes/authenticate/authenticate.yml +0 -39
  48. data/test/fixtures/vcr_cassettes/read/all_pages.yml +0 -34
  49. data/test/fixtures/vcr_cassettes/read/authenticated.yml +0 -40
  50. data/test/fixtures/vcr_cassettes/read/authentication_failure.yml +0 -33
  51. data/test/fixtures/vcr_cassettes/read/like.yml +0 -31
  52. data/test/fixtures/vcr_cassettes/read/mwunsch.yml +0 -101
  53. data/test/fixtures/vcr_cassettes/read/optional.yml +0 -48
  54. data/test/fixtures/vcr_cassettes/read/pages.yml +0 -36
  55. data/test/fixtures/vcr_cassettes/read/tumblrgemtest.yml +0 -42
  56. data/test/fixtures/vcr_cassettes/read/unlike.yml +0 -31
  57. data/test/fixtures/vcr_cassettes/write/delete.yml +0 -31
  58. data/test/fixtures/vcr_cassettes/write/edit.yml +0 -31
  59. data/test/fixtures/vcr_cassettes/write/reblog.yml +0 -31
  60. data/test/fixtures/vcr_cassettes/write/write.yml +0 -31
  61. data/test/helper.rb +0 -44
  62. data/test/test_tumblr.rb +0 -710
@@ -1,94 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/tumblr/version', __FILE__)
5
3
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{tumblr-rb}
8
- s.version = "1.3.0"
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Mark Wunsch"]
6
+ gem.email = ["mark@markwunsch.com"]
7
+ gem.description = %q{Ruby library and command line utility to interact with the Tumblr API.}
8
+ gem.summary = %q{Ruby library and command line utility to interact with Tumblr.}
9
+ gem.homepage = %q{http://github.com/mwunsch/tumblr}
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Mark Wunsch"]
12
- s.date = %q{2010-04-14}
13
- s.default_executable = %q{tumblr}
14
- s.description = %q{Ruby library and command line utility to work with the Tumblr Blogging Platform, powered by Weary.}
15
- s.email = %q{mark@markwunsch.com}
16
- s.executables = ["tumblr"]
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.md"
20
- ]
21
- s.files = [
22
- ".gitignore",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "LICENSE",
26
- "README.md",
27
- "Rakefile",
28
- "bin/tumblr",
29
- "lib/tumblr.rb",
30
- "lib/tumblr/authenticator.rb",
31
- "lib/tumblr/post.rb",
32
- "lib/tumblr/post/audio.rb",
33
- "lib/tumblr/post/conversation.rb",
34
- "lib/tumblr/post/link.rb",
35
- "lib/tumblr/post/photo.rb",
36
- "lib/tumblr/post/quote.rb",
37
- "lib/tumblr/post/regular.rb",
38
- "lib/tumblr/post/video.rb",
39
- "lib/tumblr/reader.rb",
40
- "lib/tumblr/writer.rb",
41
- "man/tumblr.1",
42
- "man/tumblr.1.html",
43
- "man/tumblr.1.ronn",
44
- "man/tumblr.5",
45
- "man/tumblr.5.html",
46
- "man/tumblr.5.ronn",
47
- "test/fixtures/vcr_cassettes/authenticate/authenticate.yml",
48
- "test/fixtures/vcr_cassettes/read/all_pages.yml",
49
- "test/fixtures/vcr_cassettes/read/authenticated.yml",
50
- "test/fixtures/vcr_cassettes/read/authentication_failure.yml",
51
- "test/fixtures/vcr_cassettes/read/like.yml",
52
- "test/fixtures/vcr_cassettes/read/mwunsch.yml",
53
- "test/fixtures/vcr_cassettes/read/optional.yml",
54
- "test/fixtures/vcr_cassettes/read/pages.yml",
55
- "test/fixtures/vcr_cassettes/read/tumblrgemtest.yml",
56
- "test/fixtures/vcr_cassettes/read/unlike.yml",
57
- "test/fixtures/vcr_cassettes/write/delete.yml",
58
- "test/fixtures/vcr_cassettes/write/edit.yml",
59
- "test/fixtures/vcr_cassettes/write/reblog.yml",
60
- "test/fixtures/vcr_cassettes/write/write.yml",
61
- "test/helper.rb",
62
- "test/test_tumblr.rb",
63
- "tumblr-rb.gemspec"
64
- ]
65
- s.homepage = %q{http://github.com/mwunsch/tumblr}
66
- s.rdoc_options = ["--charset=UTF-8"]
67
- s.require_paths = ["lib"]
68
- s.rubygems_version = %q{1.3.6}
69
- s.summary = %q{Ruby wrapper and command line interface to the Tumblr API.}
70
- s.test_files = [
71
- "test/helper.rb",
72
- "test/test_tumblr.rb"
73
- ]
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "tumblr-rb"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Tumblr::VERSION
74
17
 
75
- if s.respond_to? :specification_version then
76
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
77
- s.specification_version = 3
78
-
79
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
80
- s.add_runtime_dependency(%q<weary>, [">= 0.7.1"])
81
- s.add_runtime_dependency(%q<highline>, [">= 1.5.2"])
82
- s.add_development_dependency(%q<bundler>, [">= 0.9.19"])
83
- else
84
- s.add_dependency(%q<weary>, [">= 0.7.1"])
85
- s.add_dependency(%q<highline>, [">= 1.5.2"])
86
- s.add_dependency(%q<bundler>, [">= 0.9.19"])
87
- end
88
- else
89
- s.add_dependency(%q<weary>, [">= 0.7.1"])
90
- s.add_dependency(%q<highline>, [">= 1.5.2"])
91
- s.add_dependency(%q<bundler>, [">= 0.9.19"])
92
- end
18
+ gem.add_runtime_dependency "weary", "~> 1.1.0"
19
+ gem.add_runtime_dependency "sinatra", "~> 1.3.2"
20
+ gem.add_runtime_dependency "thor", "~> 0.16.0"
93
21
  end
94
-
metadata CHANGED
@@ -1,75 +1,74 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tumblr-rb
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 3
8
- - 0
9
- version: 1.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0.alpha
5
+ prerelease: 6
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Mark Wunsch
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-04-14 00:00:00 -04:00
18
- default_executable: tumblr
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: weary
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.1.0
22
+ type: :runtime
22
23
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- - 7
30
- - 1
31
- version: 0.7.1
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: sinatra
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.3.2
32
38
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: highline
36
39
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 5
44
- - 2
45
- version: 1.5.2
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.16.0
46
54
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: bundler
50
55
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- - 9
58
- - 19
59
- version: 0.9.19
60
- type: :development
61
- version_requirements: *id003
62
- description: Ruby library and command line utility to work with the Tumblr Blogging Platform, powered by Weary.
63
- email: mark@markwunsch.com
64
- executables:
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.16.0
62
+ description: Ruby library and command line utility to interact with the Tumblr API.
63
+ email:
64
+ - mark@markwunsch.com
65
+ executables:
65
66
  - tumblr
66
67
  extensions: []
67
-
68
- extra_rdoc_files:
69
- - LICENSE
70
- - README.md
71
- files:
68
+ extra_rdoc_files: []
69
+ files:
72
70
  - .gitignore
71
+ - .travis.yml
73
72
  - Gemfile
74
73
  - Gemfile.lock
75
74
  - LICENSE
@@ -77,70 +76,70 @@ files:
77
76
  - Rakefile
78
77
  - bin/tumblr
79
78
  - lib/tumblr.rb
80
- - lib/tumblr/authenticator.rb
79
+ - lib/tumblr/authentication.rb
80
+ - lib/tumblr/client.rb
81
+ - lib/tumblr/command_line_interface.rb
82
+ - lib/tumblr/credentials.rb
81
83
  - lib/tumblr/post.rb
84
+ - lib/tumblr/post/answer.rb
82
85
  - lib/tumblr/post/audio.rb
83
- - lib/tumblr/post/conversation.rb
86
+ - lib/tumblr/post/chat.rb
84
87
  - lib/tumblr/post/link.rb
85
88
  - lib/tumblr/post/photo.rb
86
89
  - lib/tumblr/post/quote.rb
87
- - lib/tumblr/post/regular.rb
90
+ - lib/tumblr/post/text.rb
88
91
  - lib/tumblr/post/video.rb
89
- - lib/tumblr/reader.rb
90
- - lib/tumblr/writer.rb
92
+ - lib/tumblr/version.rb
93
+ - lib/tumblr/views/error.erb
94
+ - lib/tumblr/views/form.erb
95
+ - lib/tumblr/views/layout.erb
96
+ - lib/tumblr/views/success.erb
91
97
  - man/tumblr.1
92
98
  - man/tumblr.1.html
93
99
  - man/tumblr.1.ronn
94
100
  - man/tumblr.5
95
101
  - man/tumblr.5.html
96
102
  - man/tumblr.5.ronn
97
- - test/fixtures/vcr_cassettes/authenticate/authenticate.yml
98
- - test/fixtures/vcr_cassettes/read/all_pages.yml
99
- - test/fixtures/vcr_cassettes/read/authenticated.yml
100
- - test/fixtures/vcr_cassettes/read/authentication_failure.yml
101
- - test/fixtures/vcr_cassettes/read/like.yml
102
- - test/fixtures/vcr_cassettes/read/mwunsch.yml
103
- - test/fixtures/vcr_cassettes/read/optional.yml
104
- - test/fixtures/vcr_cassettes/read/pages.yml
105
- - test/fixtures/vcr_cassettes/read/tumblrgemtest.yml
106
- - test/fixtures/vcr_cassettes/read/unlike.yml
107
- - test/fixtures/vcr_cassettes/write/delete.yml
108
- - test/fixtures/vcr_cassettes/write/edit.yml
109
- - test/fixtures/vcr_cassettes/write/reblog.yml
110
- - test/fixtures/vcr_cassettes/write/write.yml
111
- - test/helper.rb
112
- - test/test_tumblr.rb
103
+ - spec/fixtures/posts.json
104
+ - spec/fixtures/typical_animated_gif.gif
105
+ - spec/spec_helper.rb
106
+ - spec/tumblr/authentication_spec.rb
107
+ - spec/tumblr/client_spec.rb
108
+ - spec/tumblr/credentials_spec.rb
109
+ - spec/tumblr/post_spec.rb
113
110
  - tumblr-rb.gemspec
114
- has_rdoc: true
115
111
  homepage: http://github.com/mwunsch/tumblr
116
112
  licenses: []
117
-
118
113
  post_install_message:
119
- rdoc_options:
120
- - --charset=UTF-8
121
- require_paths:
114
+ rdoc_options: []
115
+ require_paths:
122
116
  - lib
123
- required_ruby_version: !ruby/object:Gem::Requirement
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- segments:
128
- - 0
129
- version: "0"
130
- required_rubygems_version: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- segments:
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ segments:
135
124
  - 0
136
- version: "0"
125
+ hash: 1099195226141486085
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>'
130
+ - !ruby/object:Gem::Version
131
+ version: 1.3.1
137
132
  requirements: []
138
-
139
133
  rubyforge_project:
140
- rubygems_version: 1.3.6
134
+ rubygems_version: 1.8.23
141
135
  signing_key:
142
136
  specification_version: 3
143
- summary: Ruby wrapper and command line interface to the Tumblr API.
144
- test_files:
145
- - test/helper.rb
146
- - test/test_tumblr.rb
137
+ summary: Ruby library and command line utility to interact with Tumblr.
138
+ test_files:
139
+ - spec/fixtures/posts.json
140
+ - spec/fixtures/typical_animated_gif.gif
141
+ - spec/spec_helper.rb
142
+ - spec/tumblr/authentication_spec.rb
143
+ - spec/tumblr/client_spec.rb
144
+ - spec/tumblr/credentials_spec.rb
145
+ - spec/tumblr/post_spec.rb
@@ -1,18 +0,0 @@
1
- class Tumblr
2
- class Authenticator < Weary::Base
3
-
4
- headers({"User-Agent" => Tumblr::USER_AGENT})
5
-
6
- def initialize(*credentials)
7
- @defaults = {:email => credentials[0], :password => credentials[1]} unless credentials.blank?
8
- end
9
-
10
- # http://www.tumblr.com/docs/en/api#authenticate
11
- post :authenticate do |auth|
12
- auth.url = 'http://www.tumblr.com/api/authenticate'
13
- auth.requires = [:email, :password]
14
- auth.with = [:'include-theme']
15
- end
16
-
17
- end
18
- end
@@ -1,15 +0,0 @@
1
- class Tumblr
2
- class Post
3
- class Conversation < Post
4
-
5
- def initialize(chat, post_id = nil)
6
- super post_id
7
- self.conversation = chat
8
- @type = :conversation
9
- end
10
-
11
- parameters :conversation, :title
12
-
13
- end
14
- end
15
- end
@@ -1,14 +0,0 @@
1
- class Tumblr
2
- class Post
3
- class Regular < Post
4
-
5
- def initialize(post_id = nil)
6
- super post_id
7
- @type = :regular
8
- end
9
-
10
- parameters :title, :body
11
-
12
- end
13
- end
14
- end
@@ -1,191 +0,0 @@
1
- #TODO: Documentation
2
- class Tumblr
3
- class Reader < Weary::Base
4
-
5
- headers({"User-Agent" => Tumblr::USER_AGENT})
6
-
7
- def initialize(*credentials)
8
- @defaults = {:email => credentials[0], :password => credentials[1]} unless credentials.blank?
9
- end
10
-
11
- # http://www.tumblr.com/docs/en/api#api_read
12
- def read(username, params={})
13
- self.class.read username, :get, parameters(params)
14
- end
15
-
16
- # http://www.tumblr.com/docs/en/api#api_pages
17
- def pages(username)
18
- Weary.get("http://#{username}.tumblr.com/api/pages")
19
- end
20
-
21
- def all_pages(username)
22
- raise 'You must provide an email address and password' if defaults.blank?
23
- Weary.post("http://#{username}.tumblr.com/api/pages") do |req|
24
- req.with = {:email => defaults[:email], :password => defaults[:password]}
25
- end
26
- end
27
-
28
- # http://www.tumblr.com/docs/en/api#authenticated_read
29
- def authenticated_read(username, params={})
30
- raise 'You must provide an email address and password' unless (params.include?(:email) && params.include?(:password)) || defaults
31
- self.class.read username, :post, parameters(params)
32
- end
33
-
34
- # Setup parameters for Reads
35
- def parameters(params)
36
- allowed = [:start,:num,:type,:id,:filter,:tagged,:search,:state,:email,:password]
37
- params.merge! defaults if defaults
38
- params.reject {|key,value| !allowed.include? key }
39
- end
40
-
41
- # Transform ALL of the posts for user/group to Post objects.
42
- # This could take a while...
43
- def get_all_posts(username, start = 0, total = nil)
44
- first_read = authenticated_read(username, {:num => 50,:start => start}).perform
45
- raise %Q(Tumblr response was not successful, "#{first_read.code}: #{first_read.message}") if !first_read.success?
46
- posts = self.class.get_posts(first_read)
47
- offset = start + posts.count
48
- post_total = total || first_read['tumblr']['posts']['total'].to_i
49
- if post_total > offset
50
- posts |= get_all_posts(username, offset, post_total)
51
- end
52
- posts
53
- end
54
-
55
- # Get the Posts as Post objects from a Read response.
56
- # Pass an additional type parameter to only get Posts of a certain type.
57
- def self.get_posts(response, type = nil)
58
- tumblr_post = response['tumblr']['posts']['post']
59
- if tumblr_post
60
- posts = tumblr_post.respond_to?(:each_pair) ? [tumblr_post] : tumblr_post
61
- posts.collect! { |post| build_post(post) }
62
- return posts.select {|post| post.is_a?(Tumblr.map(type)) } if type
63
- posts
64
- end
65
- end
66
-
67
- # Build a Post object from Reader's Post XML
68
- def self.build_post(post)
69
- setup_post(post) do |tumblr_post|
70
- tumblr_post.date = post['date_gmt']
71
- tumblr_post.format = post['format'].to_sym if post['format']
72
- tumblr_post.slug = post['slug']
73
- tumblr_post.tags post['tag'] if post['tag']
74
- tumblr_post.reblog_key = post['reblog_key'] if post['reblog_key']
75
- end
76
- end
77
-
78
- # Helper method to facilitate standard GET Read and Authenticated Read
79
- def self.read(username, via = :get, params = {})
80
- Weary.request("http://#{username}.tumblr.com/api/read/", via) do |req|
81
- req.with = params unless params.blank?
82
- end
83
- end
84
-
85
- # http://www.tumblr.com/docs/en/api#api_dashboard
86
- post :dashboard do |dashboard|
87
- dashboard.url = "http://www.tumblr.com/api/dashboard"
88
- dashboard.requires = [:email,:password]
89
- dashboard.with = [:start,:num,:type,:filter,:likes]
90
- end
91
-
92
- # http://www.tumblr.com/docs/en/api#api_likes
93
- post :likes do |likes|
94
- likes.url = "http://www.tumblr.com/api/likes"
95
- likes.requires = [:email, :password]
96
- likes.with = [:start, :num, :filter]
97
- end
98
-
99
- # http://www.tumblr.com/docs/en/api#api_liking
100
- post :like do |like|
101
- like.url = "http://www.tumblr.com/api/like"
102
- like.requires = [:email, :password, :'post-id', :'reblog-key']
103
- end
104
-
105
- # http://www.tumblr.com/docs/en/api#api_liking
106
- post :unlike do |unlike|
107
- unlike.url = "http://www.tumblr.com/api/unlike"
108
- unlike.requires = [:email, :password, :'post-id', :'reblog-key']
109
- end
110
-
111
- private
112
-
113
- def self.setup_post(post)
114
- post_type = post['type'].to_sym
115
- tumblr_post = case post_type
116
- when :regular
117
- build_regular(post)
118
- when :photo
119
- build_photo(post)
120
- when :quote
121
- build_quote(post)
122
- when :link
123
- build_link(post)
124
- when :conversation
125
- build_conversation(post)
126
- when :video
127
- build_video(post)
128
- when :audio
129
- build_audio(post)
130
- else
131
- raise "#{post_type} is not a recognized Tumblr post type."
132
- end
133
- yield tumblr_post if block_given?
134
- tumblr_post
135
- end
136
-
137
- def self.build_regular(post)
138
- post_id = post['id']
139
- regular = Tumblr::Post::Regular.new(post_id)
140
- regular.body = post['regular_body']
141
- regular.title = post['regular_title']
142
- regular
143
- end
144
-
145
- def self.build_photo(post)
146
- post_id = post['id']
147
- photo = Tumblr::Post::Photo.new(post_id)
148
- photo.source = post['photo_url'].first
149
- photo.caption = post['photo_caption']
150
- photo.click_through_url = post['photo_link_url']
151
- photo
152
- end
153
-
154
- def self.build_quote(post)
155
- post_id = post['id']
156
- quote = Tumblr::Post::Quote.new(post['quote_text'], post_id)
157
- quote.source = post['quote_source']
158
- quote
159
- end
160
-
161
- def self.build_link(post)
162
- post_id = post['id']
163
- link = Tumblr::Post::Link.new(post['link_url'], post_id)
164
- link.name = post['link_text']
165
- link.description = post['link_description']
166
- link
167
- end
168
-
169
- def self.build_conversation(post)
170
- post_id = post['id']
171
- chat = Tumblr::Post::Conversation.new(post['conversation_text'], post_id)
172
- chat.title = post['conversation_title']
173
- chat
174
- end
175
-
176
- def self.build_video(post)
177
- post_id = post['id']
178
- video = Tumblr::Post::Video.new(post['video_player'], post_id)
179
- video.caption = post['video_caption']
180
- video
181
- end
182
-
183
- def self.build_audio(post)
184
- post_id = post['id']
185
- audio = Tumblr::Post::Audio.new(post_id)
186
- audio.caption = post['audio_caption']
187
- audio
188
- end
189
-
190
- end
191
- end