tumblr-rb 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- # A sample Gemfile
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gem 'weary','>= 0.7.1'
4
4
  gem 'highline', '>= 1.5.2'
@@ -7,6 +7,6 @@ group :test do
7
7
  gem 'rake'
8
8
  gem 'redgreen'
9
9
  gem 'contest'
10
- gem 'vcr'
10
+ gem 'vcr', '>= 0.3.1'
11
11
  gem 'jeweler'
12
12
  end
@@ -19,7 +19,7 @@ dependencies:
19
19
  vcr:
20
20
  group:
21
21
  - :test
22
- version: ">= 0"
22
+ version: ">= 0.3.1"
23
23
  jeweler:
24
24
  group:
25
25
  - :test
@@ -29,36 +29,37 @@ dependencies:
29
29
  - :test
30
30
  version: ">= 0"
31
31
  specs:
32
+ - rake:
33
+ version: 0.8.7
34
+ - contest:
35
+ version: 0.1.2
36
+ - crack:
37
+ version: 0.1.7
38
+ - fakeweb:
39
+ version: 1.2.8
32
40
  - json_pure:
33
- version: 1.2.2
41
+ version: 1.2.4
42
+ - gemcutter:
43
+ version: 0.5.0
34
44
  - git:
35
45
  version: 1.2.5
36
- - redgreen:
37
- version: 1.2.2
46
+ - highline:
47
+ version: 1.5.2
38
48
  - rubyforge:
39
49
  version: 2.0.4
50
+ - jeweler:
51
+ version: 1.4.0
40
52
  - ruby-hmac:
41
53
  version: 0.4.0
42
- - crack:
43
- version: 0.1.7
44
54
  - oauth:
45
55
  version: 0.3.6
46
- - weary:
47
- version: 0.7.1
48
- - rake:
49
- version: 0.8.7
50
- - gemcutter:
51
- version: 0.5.0
52
- - jeweler:
53
- version: 1.4.0
54
- - contest:
55
- version: 0.1.2
56
- - highline:
57
- version: 1.5.2
58
- - fakeweb:
59
- version: 1.2.8
56
+ - redgreen:
57
+ version: 1.2.2
60
58
  - vcr:
61
- version: 0.1.2
62
- hash: bb23bf752ce2daa339a799069ab0b6df9063a3a4
63
- sources: []
64
-
59
+ version: 0.3.1
60
+ - weary:
61
+ version: 0.7.2
62
+ hash: 494102bf0992e5bb83118c12065b38b342f1de6a
63
+ sources:
64
+ - Rubygems:
65
+ uri: http://rubygems.org
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ begin
23
23
  gem.authors = ["Mark Wunsch"]
24
24
  gem.add_dependency 'weary', '>= 0.7.1'
25
25
  gem.add_dependency 'highline', '>= 1.5.2'
26
- gem.add_development_dependency "bundler", ">= 0.9.7"
26
+ gem.add_development_dependency "bundler", ">= 0.9.19"
27
27
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
28
28
  end
29
29
  Jeweler::GemcutterTasks.new
@@ -51,8 +51,6 @@ rescue LoadError
51
51
  end
52
52
  end
53
53
 
54
- task :test => :check_dependencies
55
-
56
54
  task :default => :test
57
55
 
58
56
  require 'rake/rdoctask'
@@ -1,7 +1,7 @@
1
1
  require 'weary'
2
2
 
3
3
  class Tumblr
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  GENERATOR = "The Tumblr Gem v#{VERSION}"
6
6
  USER_AGENT = "TumblrGem/#{VERSION} (+http://github.com/mwunsch/tumblr)"
7
7
 
@@ -7,6 +7,7 @@ class Tumblr
7
7
  POST_PARAMS = [:title,:body,:source,:caption,:'click-through-url',
8
8
  :quote,:name,:url,:description,:conversation,
9
9
  :embed,:'externally-hosted-url']
10
+ REBLOG_PARAMS = [:comment, :as]
10
11
 
11
12
  def self.parameters(*attributes)
12
13
  if !attributes.blank?
@@ -88,6 +89,10 @@ class Tumblr
88
89
  Writer.new(email,password).edit(to_h)
89
90
  end
90
91
 
92
+ def reblog(email, password)
93
+ Writer.new(email,password).reblog(to_h)
94
+ end
95
+
91
96
  def delete(email, password)
92
97
  Writer.new(email,password).delete(to_h)
93
98
  end
@@ -22,6 +22,13 @@ class Tumblr
22
22
  edit.with = (Post::BASIC_PARAMS | Post::POST_PARAMS)
23
23
  end
24
24
 
25
+ # http://www.tumblr.com/docs/en/api#reblogging_posts
26
+ post :reblog do |reblog|
27
+ reblog.url = 'http://www.tumblr.com/api/reblog'
28
+ reblog.requires = [:email, :password, :'post-id', :'reblog-key']
29
+ reblog.with = (Post::BASIC_PARAMS | Post::POST_PARAMS | Post::REBLOG_PARAMS)
30
+ end
31
+
25
32
  # http://www.tumblr.com/docs/en/api#deleting_posts
26
33
  post :delete do |del|
27
34
  del.url = 'http://www.tumblr.com/api/delete'
@@ -0,0 +1,31 @@
1
+ ---
2
+ - !ruby/struct:VCR::RecordedResponse
3
+ method: :post
4
+ uri: http://www.tumblr.com:80/api/reblog
5
+ response: !ruby/object:Net::HTTPCreated
6
+ body: "508128650"
7
+ body_exist: true
8
+ code: "201"
9
+ header:
10
+ p3p:
11
+ - CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
12
+ content-type:
13
+ - text/plain; charset=utf-8
14
+ connection:
15
+ - close
16
+ x-tumblr-usec:
17
+ - D=380408
18
+ server:
19
+ - Apache/2.2.3 (Red Hat)
20
+ date:
21
+ - Fri, 09 Apr 2010 12:36:41 GMT
22
+ content-length:
23
+ - "9"
24
+ x-tumblr-perf:
25
+ - "\"ch:12/country_code_for_ip,posts,tumblelogs,tumblelogs,version,users,users,tumblelogs,tumblelogs,version,users,users cm:4/rate-limiter,rate-limiter,users,version ce:0/ c:0/0 d:0/0 e:0/0\""
26
+ vary:
27
+ - Accept-Encoding
28
+ http_version: "1.1"
29
+ message: Created
30
+ read: true
31
+ socket:
@@ -11,8 +11,12 @@ end
11
11
  require 'pp'
12
12
  require 'test/unit'
13
13
  require 'contest'
14
- require 'redgreen'
15
14
  require 'vcr'
15
+ # Ruby 1.9 does not like redgreen
16
+ begin
17
+ require 'redgreen'
18
+ rescue LoadError
19
+ end
16
20
 
17
21
  begin
18
22
  require 'tumblr'
@@ -26,15 +30,15 @@ FakeWeb.allow_net_connect = false
26
30
 
27
31
  VCR.config do |c|
28
32
  # the cache_dir is where the cassette yml files will be saved.
29
- c.cache_dir = File.join(File.dirname(__FILE__),'fixtures', 'vcr_cassettes')
33
+ c.cassette_library_dir = File.join(File.dirname(__FILE__),'fixtures', 'vcr_cassettes')
30
34
 
31
35
  # this record mode will be used for any cassette you create without specifying a record mode.
32
- c.default_cassette_record_mode = :none
36
+ c.default_cassette_options = {:record => :none}
33
37
  end
34
38
 
35
39
  def hijack!(request, fixture)
36
- record_mode = File.exist?(VCR::Cassette.new(fixture).cache_file) ? :none : :unregistered
37
- VCR.with_cassette(fixture, :record => record_mode) do
40
+ record_mode = File.exist?(VCR::Cassette.new(fixture).file) ? :none : :unregistered
41
+ VCR.use_cassette(fixture, :record => record_mode) do
38
42
  request.perform
39
43
  end
40
44
  end
@@ -118,7 +118,7 @@ link
118
118
 
119
119
  test 'executes' do
120
120
  cred = {:email => 'test@testermcgee.com', :password => 'dontrevealmysecrets'}
121
- response = VCR.with_cassette('write/write') do
121
+ response = VCR.use_cassette('write/write') do
122
122
  Tumblr.execute(cred, 'Hello World.')
123
123
  end
124
124
  assert response.is_a? Weary::Response
@@ -253,7 +253,7 @@ link
253
253
 
254
254
  test 'gets all the posts for a username' do
255
255
  reader = Tumblr::Reader.new('test@testermcgee.com','dontrevealmysecrets')
256
- posts = VCR.with_cassette('read/authenticated') do
256
+ posts = VCR.use_cassette('read/authenticated') do
257
257
  reader.get_all_posts('mwunsch')
258
258
  end
259
259
  assert_equal 66, posts.count
@@ -309,6 +309,14 @@ link
309
309
  assert response.success?
310
310
  assert_equal 'Deleted', response.body
311
311
  end
312
+
313
+ test 'reblogs a post' do
314
+ assert_respond_to Tumblr::Writer.new, :reblog
315
+ publisher = Tumblr::Writer.new('test@testermcgee.com','dontrevealmysecrets')
316
+ post = {:'post-id' => "507998507", :'reblog-key' => 'DifhdmQI'}
317
+ response = hijack! publisher.reblog(post), 'write/reblog'
318
+ assert_equal 201, response.code
319
+ end
312
320
  end
313
321
 
314
322
  describe 'Authenticator' do
@@ -469,6 +477,12 @@ link
469
477
  assert post.delete('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
470
478
  end
471
479
 
480
+ test 'reblogs itself' do
481
+ post = Tumblr::Post.new(123)
482
+ post.reblog_key = '0U812'
483
+ assert post.reblog('test@testermcgee.com','dontrevealmysecrets').is_a? Weary::Request
484
+ end
485
+
472
486
  test 'likes itself' do
473
487
  post = Tumblr::Post.new(445597771)
474
488
  post.reblog_key = "DLVWOpfh"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tumblr-rb}
8
- s.version = "1.2.0"
8
+ s.version = "1.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Wunsch"]
12
- s.date = %q{2010-03-26}
12
+ s.date = %q{2010-04-14}
13
13
  s.default_executable = %q{tumblr}
14
14
  s.description = %q{Ruby library and command line utility to work with the Tumblr Blogging Platform, powered by Weary.}
15
15
  s.email = %q{mark@markwunsch.com}
@@ -56,6 +56,7 @@ Gem::Specification.new do |s|
56
56
  "test/fixtures/vcr_cassettes/read/unlike.yml",
57
57
  "test/fixtures/vcr_cassettes/write/delete.yml",
58
58
  "test/fixtures/vcr_cassettes/write/edit.yml",
59
+ "test/fixtures/vcr_cassettes/write/reblog.yml",
59
60
  "test/fixtures/vcr_cassettes/write/write.yml",
60
61
  "test/helper.rb",
61
62
  "test/test_tumblr.rb",
@@ -78,16 +79,16 @@ Gem::Specification.new do |s|
78
79
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
79
80
  s.add_runtime_dependency(%q<weary>, [">= 0.7.1"])
80
81
  s.add_runtime_dependency(%q<highline>, [">= 1.5.2"])
81
- s.add_development_dependency(%q<bundler>, [">= 0.9.7"])
82
+ s.add_development_dependency(%q<bundler>, [">= 0.9.19"])
82
83
  else
83
84
  s.add_dependency(%q<weary>, [">= 0.7.1"])
84
85
  s.add_dependency(%q<highline>, [">= 1.5.2"])
85
- s.add_dependency(%q<bundler>, [">= 0.9.7"])
86
+ s.add_dependency(%q<bundler>, [">= 0.9.19"])
86
87
  end
87
88
  else
88
89
  s.add_dependency(%q<weary>, [">= 0.7.1"])
89
90
  s.add_dependency(%q<highline>, [">= 1.5.2"])
90
- s.add_dependency(%q<bundler>, [">= 0.9.7"])
91
+ s.add_dependency(%q<bundler>, [">= 0.9.19"])
91
92
  end
92
93
  end
93
94
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 1.2.0
9
+ version: 1.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark Wunsch
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-26 00:00:00 -04:00
17
+ date: 2010-04-14 00:00:00 -04:00
18
18
  default_executable: tumblr
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -55,8 +55,8 @@ dependencies:
55
55
  segments:
56
56
  - 0
57
57
  - 9
58
- - 7
59
- version: 0.9.7
58
+ - 19
59
+ version: 0.9.19
60
60
  type: :development
61
61
  version_requirements: *id003
62
62
  description: Ruby library and command line utility to work with the Tumblr Blogging Platform, powered by Weary.
@@ -106,6 +106,7 @@ files:
106
106
  - test/fixtures/vcr_cassettes/read/unlike.yml
107
107
  - test/fixtures/vcr_cassettes/write/delete.yml
108
108
  - test/fixtures/vcr_cassettes/write/edit.yml
109
+ - test/fixtures/vcr_cassettes/write/reblog.yml
109
110
  - test/fixtures/vcr_cassettes/write/write.yml
110
111
  - test/helper.rb
111
112
  - test/test_tumblr.rb