curate_tumblr 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -225,13 +225,16 @@ and *reblog_post_key* to reblog it in CurateTumblr::Publish::Reblog
225
225
 
226
226
  ## Versions ##
227
227
 
228
- ### v1.0.6 ###
228
+ v1.0.7
229
+ * Better check config file
230
+
231
+ v1.0.6
229
232
  * Better error messages if no oauth in config file
230
233
 
231
- ### v1.0.5 ###
234
+ v1.0.5
232
235
  * Stop if Tumblr error "Not Authorized" (bad oauth)
233
236
 
234
- ### v1.0.4 ###
237
+ v1.0.4
235
238
  * Better error messages if problem with directories or config file
236
239
 
237
240
 
@@ -2,7 +2,7 @@ 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.6'
5
+ gem.version = '1.0.7'
6
6
  gem.authors = ['David Tysman']
7
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'
@@ -88,24 +88,12 @@ module CurateTumblr
88
88
  end
89
89
 
90
90
  def check_config_files
91
- if !Dir.exists?( @directory )
92
- return error_config( "The directory #{@directory} doesn't exist", "You need it for your tumblrs subdirectories. \nPlease create it or change the path." )
93
- end
94
- if !Dir.exists?( get_path_tumblr )
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." )
96
- end
97
- if !Dir.exists?( get_path_links )
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." )
99
- end
100
- if !Dir.exists?( get_path_logs )
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." )
102
- end
103
- if !File.exists?( get_filename_config )
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." )
105
- end
106
- if !File.exists?( get_filename_links )
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
91
+ return false if !check_config_dir( @directory, "You need it for your tumblrs subdirectories." )
92
+ return false if !check_config_dir( get_path_tumblr, "You need it for your tumblr links and config." )
93
+ return false if !check_config_dir( get_path_links, "You need it for set the links to follow and reblog." )
94
+ return false if !check_config_dir( get_path_logs, "The application needs it for write logs." )
95
+ return false if !check_config_file( get_filename_config, "You need it for set oauth tokens." )
96
+ return false if !check_config_file( get_filename_links, "You need it for set the links to reblog." )
109
97
  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
98
  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
99
  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" )
@@ -114,6 +102,20 @@ module CurateTumblr
114
102
  true
115
103
  end
116
104
 
105
+ def check_config_dir( dir, about )
106
+ if !Dir.exists?( dir )
107
+ return error_config( "The directory #{dir} doesn't exist", about + "\nPlease create it or change the path." )
108
+ end
109
+ true
110
+ end
111
+
112
+ def check_config_file( file, about )
113
+ if !File.exists?( file )
114
+ return error_config( "The file #{file} doesn't exist", about + "\nPlease create it or change the path." )
115
+ end
116
+ true
117
+ end
118
+
117
119
  def check_config_key( key, about, is_check_empty=true )
118
120
  ar_key = []
119
121
  File.open( get_filename_config, "r" ) do |file_config|
data/spec/factories.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'factory_girl'
2
2
 
3
3
  def get_tumblr_name
4
- "testitnowyeah14"
4
+ "testcuratetumblr2
5
5
  end
6
6
 
7
7
  def get_tumblr_directory
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.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: