braspag-rest 0.4.1 → 0.4.2

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: 54d0afe4cefd06614c6ec739bb9829f3caee5f34
4
- data.tar.gz: bb35f725856fede67ca255076ce1d43127260f49
3
+ metadata.gz: 62b25a333c0bdec698188695c3228d65232f54a8
4
+ data.tar.gz: af4d8fa509a8275d8646dcaf6d4bcb6c7ab91d9c
5
5
  SHA512:
6
- metadata.gz: 8a60b794f4f1d39b4dc7cca185811ece85b98fae23e4ce4944005ef5f87bd12a2a4404598c15299e56c3d93c9232819888fb1dede60766f6fa07b3577b0e860a
7
- data.tar.gz: b90810a36e6f94b4cf5519e1ec7a3c0c3cd19384d11628437a49fded4bb84148310bc8a6bfffd5cc4fed08e9860b418aa8b75d9e631cf34c12339f7ba0bdec95
6
+ metadata.gz: f9e14942adec9f0ede0064495f0864509013ecbc050b378f343727d4eaca6ba749b72899ea2f1fbda17056f3d5b56286ea259af255a5f8e96af50dce62829de1
7
+ data.tar.gz: a0a5ee325313e7c0b2aaca7b26a8ddfffa78f574f4595d046c137bbeaf207925fd46b56b0f3041926c36db6a7ab323fd9776be2bab6e7831ab6e692bc3fc9258
data/README.md CHANGED
@@ -22,6 +22,50 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
+ ### Configuration
26
+
27
+ The gem looks for a default `config/braspag-rest.yml` configuration file, with
28
+ environment (`RACK_ENV` or `RAILS_ENV`) settings for the Braspag API.
29
+
30
+ ```yml
31
+ # config/braspag-rest.yml
32
+ development:
33
+ url: 'https://apisandbox.braspag.com.br'
34
+ query_url: 'https://apiquerysandbox.braspag.com.br'
35
+ merchant_id: 'Your MerchantId here'
36
+ merchant_key: 'Your MerchantKey here'
37
+ ```
38
+
39
+ If you want to use a different file or manually set which environment should be
40
+ used, you can create an initializer file and use the `BraspagRest.config` method
41
+ to set your config.
42
+
43
+ ```ruby
44
+ # config/initializers/braspag-rest.rb
45
+ BraspagRest.config do |config|
46
+ config.config_file_path = 'config/path/here.yml'
47
+ config.enviroment = 'production'
48
+ end
49
+ ```
50
+
51
+ You can use ERB blocks to interpolate values from your environment variables into
52
+ the configuration if you are using something like [dotenv](https://github.com/bkeepers/dotenv)
53
+ to handle configuration values that shouldn't be present in the source code.
54
+
55
+ ```yml
56
+ # config/braspag-rest.yml
57
+ development:
58
+ url: 'https://apisandbox.braspag.com.br'
59
+ query_url: 'https://apiquerysandbox.braspag.com.br'
60
+ merchant_id: 'Your MerchantId here'
61
+ merchant_key: 'Your MerchantKey here'
62
+ production:
63
+ url: <%= ENV['BRASPAG_URL'] %>
64
+ query_url: <%= ENV['BRASPAG_QUERY_URL'] %>
65
+ merchant_id: <%= ENV['BRASPAG_MERCHANT_ID'] %>
66
+ merchant_key: <%= ENV['BRASPAG_MERCHANT_KEY'] %>
67
+ ```
68
+
25
69
  ### Authorize an order
26
70
 
27
71
  ```rb
@@ -97,4 +141,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Dinda-
97
141
  ## License
98
142
 
99
143
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
100
-
@@ -3,8 +3,6 @@ require 'yaml'
3
3
 
4
4
  module BraspagRest
5
5
  class Configuration
6
- include Singleton
7
-
8
6
  attr_accessor :environment, :logger, :config_file_path
9
7
 
10
8
  def config_file_path
@@ -38,7 +36,7 @@ module BraspagRest
38
36
  private
39
37
 
40
38
  def config
41
- @config ||= YAML.load(File.read(config_file_path))[environment]
39
+ @config ||= YAML.load(ERB.new(File.read(config_file_path)).result)[environment]
42
40
  end
43
41
  end
44
42
  end
@@ -82,7 +82,7 @@ module BraspagRest
82
82
  end
83
83
 
84
84
  def config
85
- @config ||= BraspagRest::Configuration.instance
85
+ @config ||= BraspagRest.config
86
86
  end
87
87
  end
88
88
  end
@@ -1,3 +1,3 @@
1
1
  module BraspagRest
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/braspag-rest.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module BraspagRest
2
2
  def self.config
3
- yield BraspagRest::Configuration.instance if block_given?
4
-
5
- BraspagRest::Configuration.instance
3
+ @config ||= BraspagRest::Configuration.new
4
+ yield @config if block_given?
5
+ @config
6
6
  end
7
7
  end
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braspag-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dinda Dev Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client