mandao 0.0.3pre4 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/mandao.rb +2 -59
- data/lib/mandao/configuration.rb +1 -0
- data/lib/mandao/resources/address_list.rb +4 -0
- data/lib/mandao/resources/base.rb +6 -7
- data/lib/mandao/resources/document.rb +2 -0
- data/lib/mandao/version.rb +1 -1
- data/lib/mandao/xml_format.rb +0 -8
- data/spec/spec_helper.rb +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 283514286e8a45320e9455b7ea5261e53633fffd
|
4
|
+
data.tar.gz: bfed794aab83411b262b6823f3c9afa9bd4640f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dca5d0b8c7b2de887cd267fabf96673c575eb6ff04ade9dc0a57437ac3dc8d45e2158fdfb5f152b55ed328d4790c31ef5c3392f0939218139700f20ca53fca15
|
7
|
+
data.tar.gz: 35f9fb1c9202f6806746c71639b9a3cadd3d50e588a689f6774ec39e28def5f7ea97703f993ca630390efc6bcd90d5d7bf1b57f1e8e48a55fe79476c0d0a477c
|
data/lib/mandao.rb
CHANGED
@@ -1,61 +1,4 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
2
|
-
|
3
|
-
require 'rest_client'
|
4
|
-
require 'active_resource'
|
5
|
-
|
6
1
|
require 'mandao/version'
|
2
|
+
Dir.glob(File.expand_path('../resources/*', __FILE__)).each { |file| require(file) }
|
7
3
|
require 'mandao/xml_format'
|
8
|
-
require 'mandao/
|
9
|
-
|
10
|
-
module Mandao
|
11
|
-
|
12
|
-
class << self
|
13
|
-
attr_accessor :configuration
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.configure
|
17
|
-
self.configuration ||= Configuration.new
|
18
|
-
yield(configuration)
|
19
|
-
Mandao::Base.activate(api_endpoint: Mandao.config.api_endpoint, default_format: Mandao.config.format)
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.config
|
23
|
-
self.configuration
|
24
|
-
end
|
25
|
-
|
26
|
-
class Configuration
|
27
|
-
attr_accessor :endpoint
|
28
|
-
attr_accessor :username
|
29
|
-
attr_accessor :password
|
30
|
-
attr_accessor :protocol
|
31
|
-
attr_accessor :format
|
32
|
-
|
33
|
-
VALID_OPTIONS_KEYS = [:endpoint, :username, :password]
|
34
|
-
REQUIRED_OPTIONS = [:username, :password]
|
35
|
-
DEFAULT_PROTOCOL = "https".freeze
|
36
|
-
DEFAULT_ENDPOINT = 'stage.rest.click2mail.com/v1'.freeze # TODO [ add production endpoint by default ]
|
37
|
-
DEFAULT_FORMAT = ActiveResource::Formats::XmlFormat
|
38
|
-
|
39
|
-
def initialize
|
40
|
-
@endpoint = DEFAULT_ENDPOINT
|
41
|
-
@protocol = DEFAULT_PROTOCOL
|
42
|
-
@format = DEFAULT_FORMAT
|
43
|
-
end
|
44
|
-
|
45
|
-
def api_endpoint
|
46
|
-
"#{@protocol}://#{@username}:#{@password}@#{@endpoint}/"
|
47
|
-
end
|
48
|
-
|
49
|
-
def valid?
|
50
|
-
REQUIRED_OPTIONS.each do |opt|
|
51
|
-
raise StandardError, 'You must provide username and password.' if send(opt)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
require 'mandao/resources/address'
|
60
|
-
require 'mandao/resources/address_list'
|
61
|
-
require 'mandao/resources/document'
|
4
|
+
require 'mandao/configuration'
|
data/lib/mandao/configuration.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
|
+
require 'active_resource'
|
2
|
+
require File.expand_path('../../configuration', __FILE__)
|
3
|
+
|
1
4
|
module Mandao
|
2
5
|
class Base < ActiveResource::Base
|
3
6
|
self.include_format_in_path = false
|
4
7
|
|
5
8
|
class << self
|
6
9
|
|
7
|
-
def activate
|
8
|
-
|
9
|
-
|
10
|
-
self.format = options[:default_format]
|
11
|
-
rescue
|
12
|
-
raise 'Missing api_endpoint, default_format configuration'
|
13
|
-
end
|
10
|
+
def activate
|
11
|
+
self.site = Mandao.config.api_endpoint
|
12
|
+
self.format = Mandao.config.format
|
14
13
|
end
|
15
14
|
|
16
15
|
def parse_response(xml)
|
data/lib/mandao/version.rb
CHANGED
data/lib/mandao/xml_format.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -4,10 +4,10 @@ require 'active_resource'
|
|
4
4
|
require 'rest_client'
|
5
5
|
|
6
6
|
require File.expand_path('../../lib/mandao', __FILE__)
|
7
|
-
|
8
|
-
|
7
|
+
require File.expand_path('../../lib/mandao/resources/base', __FILE__)
|
8
|
+
require File.expand_path('../../lib/mandao/xml_format', __FILE__)
|
9
9
|
require File.expand_path('..//mandao/stub_requests', __FILE__)
|
10
|
-
|
10
|
+
Dir.glob(File.expand_path('../../lib/mandao/resources/*', __FILE__)).each { |file| require(file) }
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
13
|
config.include WebMock::API
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mandao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marlon Mantilla
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -138,9 +138,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
|
-
- - "
|
141
|
+
- - ">="
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
143
|
+
version: '0'
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project:
|
146
146
|
rubygems_version: 2.2.2
|