mandao 0.0.3pre3 → 0.0.3pre4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57451c3efa616292fd209e60658f66250519b79c
4
- data.tar.gz: 14458bb587a8485880c245b3a160f344704c05b0
3
+ metadata.gz: 0aa8b32e91fd4baf4ec46ae90a18333efdae74aa
4
+ data.tar.gz: 93a6c21dd17eed66c2815570774de4e2f20c9a4d
5
5
  SHA512:
6
- metadata.gz: a3c49c21a887b7b4efc81f506482b4ebb952514f09a7bf0dad9033f46ab852f5b17bffc1bbfb07dc3eddb58cbf93de47fc43d7b0193bc5583ed45476dbd78e7a
7
- data.tar.gz: a30774fdc638489fab928f6b98a687382c72ce03d5f442088b0e984b2b31132a87d9e6fe12ef3538a59b8e763f401ce759b0252025e0370e2a34e92cfae3dfa1
6
+ metadata.gz: f93f636164df6448b672c63b8405540f61a66293a680ecfa62a5ee519de924e60814a318f413323f963f8d2251ea0e7fd218129f2affe7391eef6374de50f21d
7
+ data.tar.gz: cb258c09b0999467a2e73980a5aab7071e9201137cea1197b47cfb8724b85f1652e83f71731e49074ce986bfcbbe618efe15e740d584e77d5648a03cfaa438e9
@@ -1,10 +1,61 @@
1
- require 'mandao/version'
1
+ $:.unshift File.dirname(__FILE__)
2
+
2
3
  require 'rest_client'
3
4
  require 'active_resource'
4
- require 'mandao/xml_format'
5
5
 
6
+ require 'mandao/version'
7
+ require 'mandao/xml_format'
6
8
  require 'mandao/resources/base'
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
+
7
59
  require 'mandao/resources/address'
8
60
  require 'mandao/resources/address_list'
9
61
  require 'mandao/resources/document'
10
- require 'mandao/configuration'
@@ -1,5 +1,3 @@
1
- require File.expand_path('../address', __FILE__)
2
-
3
1
  module Mandao
4
2
 
5
3
  class AddressListCollection < ActiveResource::Collection
@@ -1,15 +1,16 @@
1
- require File.expand_path('../../configuration', __FILE__)
2
- require File.expand_path('../../xml_format', __FILE__)
3
-
4
1
  module Mandao
5
2
  class Base < ActiveResource::Base
6
3
  self.include_format_in_path = false
7
4
 
8
5
  class << self
9
6
 
10
- def activate
11
- self.site = Mandao.config.api_endpoint
12
- self.format = Mandao.config.format
7
+ def activate(options={})
8
+ begin
9
+ self.site = options[:api_endpoint]
10
+ self.format = options[:default_format]
11
+ rescue
12
+ raise 'Missing api_endpoint, default_format configuration'
13
+ end
13
14
  end
14
15
 
15
16
  def parse_response(xml)
@@ -1,3 +1,3 @@
1
1
  module Mandao
2
- VERSION = "0.0.3pre3"
2
+ VERSION = "0.0.3pre4"
3
3
  end
@@ -4,10 +4,10 @@ require 'active_resource'
4
4
  require 'rest_client'
5
5
 
6
6
  require File.expand_path('../../lib/mandao', __FILE__)
7
- require File.expand_path('../../lib/mandao/resources/base', __FILE__)
8
- require File.expand_path('../../lib/mandao/xml_format', __FILE__)
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
- Dir.glob(File.expand_path('../../lib/mandao/resources/*', __FILE__)).each { |file| require(file) }
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.3pre3
4
+ version: 0.0.3pre4
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-14 00:00:00.000000000 Z
11
+ date: 2014-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource