curate_tumblr 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +20 -6
- data/curate_tumblr.gemspec +2 -2
- data/lib/curate_tumblr/curator.rb +38 -20
- data/lib/curate_tumblr/utilities/monkey.rb +4 -4
- data/spec/factories.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -4,10 +4,6 @@ Reblog and follow in your Tumblr from a file of links.
|
|
4
4
|
|
5
5
|
Grow you Tumblr audience by automating the boring tasks !
|
6
6
|
|
7
|
-
### v1.0.5 ###
|
8
|
-
* Stop if Tumblr error "Not Authorized" (bad oauth)
|
9
|
-
* Better error messages if problem with directories or config file
|
10
|
-
|
11
7
|
|
12
8
|
### Installation
|
13
9
|
|
@@ -206,13 +202,19 @@ If strange things happen :
|
|
206
202
|
|
207
203
|
To reblog a post you need its reblog key.
|
208
204
|
|
209
|
-
|
205
|
+
To have it you have to send a request to tumblr with the post tumblr and id.
|
206
|
+
In infos hash post from Tumblr you'll have the reblog key
|
210
207
|
|
211
208
|
You can use :
|
212
209
|
|
210
|
+
*get_hash_post* in CurateTumblr::Publish::Client
|
211
|
+
to have the reblog key
|
212
|
+
|
213
|
+
or
|
213
214
|
*CurateTumblr::Tumblr::ExtractLinks.get_reblog_key_from_reblog_url*
|
215
|
+
if the url contains the reblog key (www.tumblr.com/reblog/...)
|
214
216
|
|
215
|
-
and *reblog_post_key* in CurateTumblr::Publish
|
217
|
+
and *reblog_post_key* to reblog it in CurateTumblr::Publish::Reblog
|
216
218
|
|
217
219
|
|
218
220
|
## Todo
|
@@ -221,6 +223,18 @@ and *reblog_post_key* in CurateTumblr::Publish.Reblog
|
|
221
223
|
* hidden oauth (are you enough paranoid ?)
|
222
224
|
|
223
225
|
|
226
|
+
## Versions ##
|
227
|
+
|
228
|
+
### v1.0.6 ###
|
229
|
+
* Better error messages if no oauth in config file
|
230
|
+
|
231
|
+
### v1.0.5 ###
|
232
|
+
* Stop if Tumblr error "Not Authorized" (bad oauth)
|
233
|
+
|
234
|
+
### v1.0.4 ###
|
235
|
+
* Better error messages if problem with directories or config file
|
236
|
+
|
237
|
+
|
224
238
|
## Copyright
|
225
239
|
|
226
240
|
The Curate Tumblr gem is Copyright (c) 2013 David Tysman and is licensed under the MIT License.
|
data/curate_tumblr.gemspec
CHANGED
@@ -2,9 +2,9 @@ Gem::Specification.new do |gem|
|
|
2
2
|
gem.add_dependency 'tumblr_client'
|
3
3
|
gem.add_dependency 'logger'
|
4
4
|
gem.name = 'curate_tumblr'
|
5
|
-
gem.version = '1.0.
|
5
|
+
gem.version = '1.0.6'
|
6
6
|
gem.authors = ['David Tysman']
|
7
|
-
gem.description = 'CurateTumblr - reblog and follow Tumblr links'
|
7
|
+
gem.description = 'CurateTumblr - reblog and follow Tumblr links, extract infos from the posts, add tags and links'
|
8
8
|
gem.summary = 'Reblog and follow Tumblr'
|
9
9
|
gem.email = 'web@davidtysman.com'
|
10
10
|
gem.files = `git ls-files`.split("\n")
|
@@ -89,38 +89,56 @@ module CurateTumblr
|
|
89
89
|
|
90
90
|
def check_config_files
|
91
91
|
if !Dir.exists?( @directory )
|
92
|
-
|
93
|
-
@is_stop = true
|
94
|
-
return false
|
92
|
+
return error_config( "The directory #{@directory} doesn't exist", "You need it for your tumblrs subdirectories. \nPlease create it or change the path." )
|
95
93
|
end
|
96
94
|
if !Dir.exists?( get_path_tumblr )
|
97
|
-
|
98
|
-
@is_stop = true
|
99
|
-
return false
|
95
|
+
return error_config( "The directory #{get_path_tumblr} doesn't exist", "You need it for your tumblr links and config. \nPlease create it or change the path." )
|
100
96
|
end
|
101
97
|
if !Dir.exists?( get_path_links )
|
102
|
-
|
103
|
-
@is_stop = true
|
104
|
-
return false
|
98
|
+
return error_config( "The directory #{get_path_links} doesn't exist", "You need it for set the links to follow and reblog. \nPlease create it or change the path." )
|
105
99
|
end
|
106
100
|
if !Dir.exists?( get_path_logs )
|
107
|
-
|
108
|
-
@is_stop = true
|
109
|
-
return false
|
101
|
+
return error_config( "The directory #{get_path_logs} doesn't exist", "The application needs it for write logs. \nPlease create it or change the path." )
|
110
102
|
end
|
111
103
|
if !File.exists?( get_filename_config )
|
112
|
-
|
113
|
-
@is_stop = true
|
114
|
-
return false
|
104
|
+
return error_config( "The config file #{get_filename_config} doesn't exist", "You need it for set oauth tokens. \nPlease create it or change the path." )
|
115
105
|
end
|
116
106
|
if !File.exists?( get_filename_links )
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
107
|
+
return error_config( "The file #{get_filename_links} doesn't exist", "You need it for set the links to reblog. \nPlease create it or change the path." )
|
108
|
+
end
|
109
|
+
return false if !check_config_key( Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH, "you need to write it in config file to write inside the oauth tokens to send requests to Tumblr", false )
|
110
|
+
return false if !check_config_key( Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH_CONSUMER_KEY, "you need to write it inside '#{Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH}' in config file to send requests to Tumblr" )
|
111
|
+
return false if !check_config_key( Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH_CONSUMER_SECRET, "you need to write it inside '#{Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH}' in config file to send requests to Tumblr" )
|
112
|
+
return false if !check_config_key( Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH_TOKEN, "you need to write it inside '#{Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH}' in config file to send requests to Tumblr" )
|
113
|
+
return false if !check_config_key( Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH_TOKEN_SECRET, "you need to write it inside '#{Tumblr::Client::HASH_CONFIG_CLIENT_OAUTH}' in config file to send requests to Tumblr" )
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
def check_config_key( key, about, is_check_empty=true )
|
118
|
+
ar_key = []
|
119
|
+
File.open( get_filename_config, "r" ) do |file_config|
|
120
|
+
ar_key = file_config.grep( /#{key}:/ )
|
121
|
+
if ar_key.count <= 0
|
122
|
+
return error_config( "There is no '#{key}' in #{get_filename_config}", about )
|
123
|
+
end
|
124
|
+
end
|
125
|
+
if is_check_empty
|
126
|
+
if ar_key[0].split(":").count <= 1
|
127
|
+
return error_config( "'#{key}' is empty in #{get_filename_config}", about )
|
128
|
+
end
|
129
|
+
if ar_key[0].split(":")[1].gsub( /\s+/, "" ).gsub( /"/, "" ).empty?
|
130
|
+
return error_config( "'#{key}' is empty in #{get_filename_config}", about )
|
131
|
+
end
|
132
|
+
end
|
121
133
|
true
|
122
134
|
end
|
123
135
|
|
136
|
+
def error_config( error, about )
|
137
|
+
puts "\nOups! #{error} \n#{about}"
|
138
|
+
@is_stop = true
|
139
|
+
false
|
140
|
+
end
|
141
|
+
|
124
142
|
def get_config_from_yaml
|
125
143
|
if @is_stop
|
126
144
|
@log_tumblr.error( "don't get config because must stop" )
|
@@ -237,7 +255,7 @@ module CurateTumblr
|
|
237
255
|
private
|
238
256
|
|
239
257
|
def stop_and_alert(message, is_display=true, is_log=true )
|
240
|
-
@log_tumblr.error( message ) if is_log
|
258
|
+
@log_tumblr.error( message ) if is_log && @log_tumblr
|
241
259
|
puts "\n*** Stop it ! #{message} ***" if is_display
|
242
260
|
stop_it!
|
243
261
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Hash
|
2
|
-
def check_key( key )
|
3
|
-
raise "no key '#{key}' in Hash #{to_s}" if !self.has_key?( key )
|
4
|
-
raise "no key '#{key}' in Hash #{to_s}" if self[key].nil?
|
5
|
-
raise "key '#{key}' is empty in Hash #{to_s}" if self[key].empty?
|
2
|
+
def check_key( key, where='' )
|
3
|
+
raise "no key '#{key}' in Hash #{to_s} #{where}" if !self.has_key?( key )
|
4
|
+
raise "no key '#{key}' in Hash #{to_s} #{where}" if self[key].nil?
|
5
|
+
raise "key '#{key}' is empty in Hash #{to_s} #{where}" if self[key].empty?
|
6
6
|
end
|
7
7
|
end
|
data/spec/factories.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curate_tumblr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,7 +43,8 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description: CurateTumblr - reblog and follow Tumblr links
|
46
|
+
description: CurateTumblr - reblog and follow Tumblr links, extract infos from the
|
47
|
+
posts, add tags and links
|
47
48
|
email: web@davidtysman.com
|
48
49
|
executables: []
|
49
50
|
extensions: []
|