wp_wrapper 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e47e1d50966b606904762e455abe7f5e79e6d5f3
4
- data.tar.gz: 8fc42273c93030fda4968248843a70445ab179f6
3
+ metadata.gz: 9b9e21959217ff182e62ebba47888d528feea4af
4
+ data.tar.gz: f397526568234c292637a38f62d0df031f19db34
5
5
  SHA512:
6
- metadata.gz: 15767b3c4d4d9abe3d261c5ce9982a4f31080e52d62b546825f2807337f46ffc53f659f3d95f49a672ad37f1a581b00493abf35fb85af39c69a947350bc00115
7
- data.tar.gz: 6e17db691d2f90b599b1629b1aa4d69cd96d0fe61a73fdb93ba0826c675dd75f5a1df817fd36185f6fec7c877f5944d4470a5891bbb15d9dcb22db55bdc7069f
6
+ metadata.gz: 23de8f530654fa563368dbdc12765c1fdab9bd62b44f206aeada12ecc483db98932a771a4714402ccef732d6a858189f76ddea0933edcab8b9d18b539c6f9c3f
7
+ data.tar.gz: a6ac0a6480b5f272b8162a527a43e6c638048f42649605d35b2a4de4cee4730eb61bc7961e4f19b952d98c3459061ea03c02bae5b79b1c1cdd92f584c3d96075
@@ -3,19 +3,22 @@ module WpWrapper
3
3
  attr_accessor :url, :username, :password
4
4
  attr_accessor :environment, :logged_in
5
5
  attr_accessor :http_client, :mechanize_client
6
+ attr_accessor :reraise_exceptions
6
7
 
7
8
  def initialize(options = {})
8
9
  options.symbolize_keys! if options.respond_to?(:symbolize_keys!)
9
10
 
10
- self.url = options.fetch(:url, nil)
11
- self.url = "#{self.url}/" unless self.url.nil? || self.url =~ /\/$/i
11
+ self.url = options.fetch(:url, nil)
12
+ self.url = "#{self.url}/" unless self.url.nil? || self.url =~ /\/$/i
12
13
 
13
- self.username = options.fetch(:username, nil)
14
- self.password = options.fetch(:password, nil)
15
- self.logged_in = false
14
+ self.username = options.fetch(:username, nil)
15
+ self.password = options.fetch(:password, nil)
16
+ self.logged_in = false
16
17
 
17
- self.http_client = HttpUtilities::Http::Client.new
18
- self.mechanize_client = HttpUtilities::Http::Mechanize::Client.new
18
+ self.http_client = HttpUtilities::Http::Client.new
19
+ self.mechanize_client = HttpUtilities::Http::Mechanize::Client.new
20
+
21
+ self.reraise_exceptions = options.fetch(:reraise_exceptions, false)
19
22
  end
20
23
 
21
24
  include WpWrapper::Modules::Authorization
@@ -27,12 +27,13 @@ module WpWrapper
27
27
 
28
28
  rescue Exception => e
29
29
  puts "#{Time.now}: Url: #{self.url}. Failed to login. Error Class: #{e.class.name}. Error Message: #{e.message}"
30
- login(retries - 1) if (retries > 0)
30
+ login(retries - 1) if retries > 0
31
+ raise WpWrapper::FailedLoginException, "Failed to login" if retries <= 0 && self.reraise_exceptions
31
32
  end
32
33
 
33
34
  else
34
35
  puts "\n\n#{Time.now}: Url: #{self.url}. Something's broken! Can't find wp-admin login form! Retrying...\n\n"
35
- login(retries - 1) if (retries > 0)
36
+ login(retries - 1) if retries > 0
36
37
  end
37
38
  end
38
39
  end
data/lib/wp_wrapper.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  module WpWrapper
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
 
4
4
  require File.join(File.dirname(__FILE__), 'wp_wrapper/railtie') if defined?(Rails)
5
-
5
+
6
+ require File.join(File.dirname(__FILE__), 'wp_wrapper/exceptions')
7
+
6
8
  require File.join(File.dirname(__FILE__), 'wp_wrapper/modules/authorization')
7
9
  require File.join(File.dirname(__FILE__), 'wp_wrapper/modules/setup')
8
10
  require File.join(File.dirname(__FILE__), 'wp_wrapper/modules/upgrade')
data/wp_wrapper.gemspec CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'wp_wrapper'
6
- s.version = '0.0.3'
6
+ s.version = '0.0.4'
7
7
 
8
8
  s.homepage = "http://github.com/Agiley/wp_wrapper"
9
9
  s.email = "sebastian@agiley.se"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wp_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Johnsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-27 00:00:00.000000000 Z
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri