acts_as_tumblr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,29 +30,55 @@ module ActsAsTumblr
30
30
  if args[0].is_a?(Integer)
31
31
  limit = args[0]
32
32
  tags = [""]
33
+ tumblr_address = ENV['TUMBLR_ADDRESS']
33
34
  else
34
35
  limit = 0
36
+ if args[0].include?(".")
37
+ tumblr_address = args[0]
38
+ tags = []
39
+ else
40
+ array = []
41
+ array << args[0]
42
+ tags = array.flatten
43
+ tumblr_address = ENV['TUMBLR_ADDRESS']
44
+ end
45
+ end
46
+ elsif args.count == 2
47
+ if args[0].is_a?(Integer)
48
+ limit = args[0]
49
+ tumblr_address = args[1]
50
+ tags = []
51
+ else
35
52
  array = []
36
53
  array << args[0]
37
54
  tags = array.flatten
55
+ if args[1].is_a?(Integer)
56
+ tumblr_address = ENV['TUMBLR_ADDRESS']
57
+ limit = args[1]
58
+ else
59
+ tumblr_address = args[1]
60
+ limit = 0
61
+ end
38
62
  end
39
- elsif args.count == 2
40
- limit = args[1]
63
+ elsif args.count == 3
41
64
  array = []
42
65
  array << args[0]
43
66
  tags = array.flatten
67
+ limit = args[1]
68
+ tumblr_address = args[2]
44
69
  else
45
70
  tags = []
46
71
  limit = 0
72
+ tumblr_address = ENV['TUMBLR_ADDRESS']
47
73
  end
48
- Post.get_tumblr_posts(post_type, tags, limit)
74
+ Post.get_tumblr_posts(post_type, tags, limit, tumblr_address)
49
75
  else
50
76
  super
51
77
  end
52
78
  end
53
79
 
54
- def self.get_tumblr_posts(post_type = "all", tags = [], limit = 0)
55
- api_address = "http://api.tumblr.com/v2/blog/" + ENV['TUMBLR_ADDRESS']
80
+ def self.get_tumblr_posts(post_type = "all", tags = [], limit = 0, tumblr_address = ENV['TUMBLR_ADDRESS'])
81
+ api_address = "http://api.tumblr.com/v2/blog/" + tumblr_address
56
82
  if post_type == "all"
57
83
  type = ""
58
84
  else
@@ -64,16 +90,15 @@ module ActsAsTumblr
64
90
  elsif tags.count > 1
65
91
  big_tag = tags.first
66
92
  t = "&tag=" + URI.escape(big_tag)
67
- test_address = api_address + "/posts" + type + "?api_key=" + ENV['TUMBLR_API_KEY'] + t
93
+ test_address = api_address + "/posts" + type + "?api_key=" + tumblr_address + t
68
94
  json = open(test_address).read.to_s rescue false
69
95
  if json != false
70
96
  data = JSON.parse(json)
71
97
  total_posts = data["response"]["total_posts"]
72
- puts "compare to " + total_posts.to_s
73
98
  end
74
99
  tags.each do |tag|
75
100
  t = "&tag=" + URI.escape(tag)
76
- test_address = api_address + "/posts" + type + "?api_key=" + ENV['TUMBLR_API_KEY'] + t
101
+ test_address = api_address + "/posts" + type + "?api_key=" + tumblr_address + t
77
102
  json = open(test_address).read.to_s rescue false
78
103
  if json != false
79
104
  data = JSON.parse(json)
@@ -81,7 +106,6 @@ module ActsAsTumblr
81
106
  if new_posts > total_posts
82
107
  total_posts = new_posts
83
108
  big_tag = tag
84
- puts "New total is " + total_posts.to_s + " for tag: " + big_tag
85
109
  t = "&tag=" + URI.escape(big_tag)
86
110
  end
87
111
  end
@@ -239,9 +263,9 @@ module ActsAsTumblr
239
263
  end
240
264
  end
241
265
 
242
- def update_notes
266
+ def update_notes(tumblr_address = ENV['TUMBLR_ADDRESS'])
243
267
  if self.tumblr_id?
244
- api_address = "http://api.tumblr.com/v2/blog/" + ENV['TUMBLR_ADDRESS']
268
+ api_address = "http://api.tumblr.com/v2/blog/" + tumblr_address
245
269
  address = api_address + "/posts?api_key=" + ENV['TUMBLR_API_KEY'] + "&id=" + self.tumblr_id
246
270
  puts "Connecting to... " + address
247
271
  json = open(address).read.to_s rescue false
@@ -1,3 +1,3 @@
1
1
  module ActsAsTumblr
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_tumblr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-12 00:00:00.000000000Z
12
+ date: 2012-08-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70145298538340 !ruby/object:Gem::Requirement
16
+ requirement: &70247228409320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70145298538340
24
+ version_requirements: *70247228409320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: paperclip
27
- requirement: &70145298536740 !ruby/object:Gem::Requirement
27
+ requirement: &70247228408560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70145298536740
35
+ version_requirements: *70247228408560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aws-sdk
38
- requirement: &70145298535220 !ruby/object:Gem::Requirement
38
+ requirement: &70247228407880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.3.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70145298535220
46
+ version_requirements: *70247228407880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: acts-as-taggable-on
49
- requirement: &70145298528000 !ruby/object:Gem::Requirement
49
+ requirement: &70247228407180 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.3.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70145298528000
57
+ version_requirements: *70247228407180
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: exportr
60
- requirement: &70145298526640 !ruby/object:Gem::Requirement
60
+ requirement: &70247228406040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.2.6
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70145298526640
68
+ version_requirements: *70247228406040
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: omniauth
71
- requirement: &70145298525520 !ruby/object:Gem::Requirement
71
+ requirement: &70247228404520 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70145298525520
79
+ version_requirements: *70247228404520
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: omniauth-tumblr
82
- requirement: &70145298524120 !ruby/object:Gem::Requirement
82
+ requirement: &70247228401480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70145298524120
90
+ version_requirements: *70247228401480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: tumblr_client
93
- requirement: &70145298523520 !ruby/object:Gem::Requirement
93
+ requirement: &70247228396500 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70145298523520
101
+ version_requirements: *70247228396500
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: hashie
104
- requirement: &70145298522260 !ruby/object:Gem::Requirement
104
+ requirement: &70247228390760 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70145298522260
112
+ version_requirements: *70247228390760
113
113
  description: Tumblr Essentials
114
114
  email: keith@alldayeveryday.com
115
115
  executables: []