rents 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Contributing.md +203 -0
- data/Gemfile +3 -2
- data/README.md +1 -0
- data/lib/generators/templates/rents.rb +3 -3
- data/lib/rents/array.rb +6 -0
- data/lib/rents/config/enums/brands.yml +45 -0
- data/lib/rents/config/enums/currencies.yml +35 -0
- data/lib/rents/config/enums/payment_methods.yml +20 -0
- data/lib/rents/config/enums/recurrence_periods.yml +18 -0
- data/lib/rents/config/enums/transaction_codes.yml +31 -0
- data/lib/rents/config/proxy.example.yml +4 -0
- data/lib/rents/connection.rb +87 -12
- data/lib/rents/transaction.rb +61 -5
- data/lib/rents/version.rb +1 -1
- data/lib/rents.rb +43 -5
- data/modeling/API Routes.png +0 -0
- data/rents.gemspec +1 -1
- data/spec/file_helper.rb +42 -0
- data/spec/helpers.rb +12 -0
- data/spec/rents/status_spec.rb +3 -0
- data/spec/rents/transaction_spec.rb +662 -247
- metadata +22 -11
- /data/{modelagem → modeling}/Sequence - APIClient.asta +0 -0
- /data/{modelagem → modeling}/Structure - ClassDiagram.asta +0 -0
- /data/{modelagem → modeling}/WorkFlow - LocalGEM.asta +0 -0
- /data/{modelagem → modeling}/WorkFlow - LocalGEM.png +0 -0
- /data/{modelagem → modeling}/useful_files/card_operators/cielo/test_cards.txt +0 -0
- /data/{modelagem → modeling}/useful_files/card_operators/cielo/test_keys.txt +0 -0
data/lib/rents.rb
CHANGED
@@ -7,18 +7,33 @@ require 'bigdecimal/util'
|
|
7
7
|
|
8
8
|
# Overrides
|
9
9
|
require 'rents/hash'
|
10
|
+
require 'rents/array'
|
10
11
|
|
11
12
|
# Gem files
|
12
13
|
[:version, :connection, :status, :transaction, :currency, :string].each { |lib| require "rents/#{lib}" }
|
13
14
|
|
14
15
|
module Rents
|
16
|
+
# Module attr
|
17
|
+
@@enum = nil
|
18
|
+
|
15
19
|
# Production settings
|
16
20
|
@@app_id = nil
|
17
21
|
@@secret_key = nil
|
18
22
|
|
19
23
|
# Tests settings
|
24
|
+
@@proxy_yml = nil
|
20
25
|
@@test_env = nil
|
21
|
-
@@
|
26
|
+
@@debug = nil
|
27
|
+
|
28
|
+
def self.proxy_yml
|
29
|
+
@@proxy_yml = Rents.get_proxy_from_yml if @@proxy_yml.nil?
|
30
|
+
@@proxy_yml
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.proxy
|
34
|
+
return nil if Rents.proxy_yml.nil? || Rents.proxy_yml.empty?
|
35
|
+
"http://#{Rents.proxy_yml[:login]}:#{Rents.proxy_yml[:password]}@#{Rents.proxy_yml[:host]}:#{Rents.proxy_yml[:port]}/"
|
36
|
+
end
|
22
37
|
|
23
38
|
def self.app_id=(app_id)
|
24
39
|
@@app_id = app_id
|
@@ -44,11 +59,34 @@ module Rents
|
|
44
59
|
@@test_env = test_env
|
45
60
|
end
|
46
61
|
|
47
|
-
def self.
|
48
|
-
@@
|
62
|
+
def self.debug
|
63
|
+
@@debug
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.debug=(debug)
|
67
|
+
@@debug = debug
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.get_proxy_from_yml
|
71
|
+
yml = YAML::load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'rents/config/proxy.yml'))
|
72
|
+
!yml.nil? || yml.is_a?(Hash) ? yml.it_keys_to_sym : {} if yml
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.enum
|
76
|
+
return @@enum unless @@enum.nil?
|
77
|
+
enum = {}
|
78
|
+
|
79
|
+
enum = enum.merge load_yml('brands.yml')
|
80
|
+
enum = enum.merge load_yml('currencies.yml')
|
81
|
+
enum = enum.merge load_yml('payment_methods.yml')
|
82
|
+
enum = enum.merge load_yml('recurrence_periods.yml')
|
83
|
+
enum = enum.merge load_yml('transaction_codes.yml')
|
84
|
+
|
85
|
+
enum = enum.it_keys_to_sym
|
86
|
+
@@enum = enum
|
49
87
|
end
|
50
88
|
|
51
|
-
def self.
|
52
|
-
|
89
|
+
def self.load_yml file_name
|
90
|
+
YAML::load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'rents/config/enums/' + file_name))
|
53
91
|
end
|
54
92
|
end
|
Binary file
|
data/rents.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
#================== GEMs to build it GEM, so its improve the development ==============================
|
22
22
|
# Base GEMs to build it gem
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.3", '>= 10.3.2'
|
25
25
|
|
26
26
|
# RSpec for tests
|
data/spec/file_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Helpers
|
2
|
+
def comment_proxy_yml
|
3
|
+
process_file :comment
|
4
|
+
end
|
5
|
+
|
6
|
+
def uncomment_proxy_yml
|
7
|
+
process_file :uncomment
|
8
|
+
end
|
9
|
+
|
10
|
+
def process_file action
|
11
|
+
file_path = './lib/rents/config/proxy.yml'
|
12
|
+
file = File.open(file_path, 'r+')
|
13
|
+
old_lines = file.readlines
|
14
|
+
new_lines = []
|
15
|
+
|
16
|
+
# Create the new lines
|
17
|
+
if action == :comment
|
18
|
+
old_lines.each do |old_line|
|
19
|
+
unless old_line[0] == '#'
|
20
|
+
old_line = '#' + old_line
|
21
|
+
end
|
22
|
+
|
23
|
+
new_lines << old_line
|
24
|
+
end
|
25
|
+
elsif action == :uncomment
|
26
|
+
old_lines.each do |old_line|
|
27
|
+
new_lines << old_line.remove('#')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
write_lines file_path, new_lines
|
32
|
+
end
|
33
|
+
|
34
|
+
# Write the new lines
|
35
|
+
def write_lines file_path, new_lines
|
36
|
+
File.open(file_path, 'w') do |file|
|
37
|
+
new_lines.each do |new_line|
|
38
|
+
file.puts new_line
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/helpers.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
require 'file_helper'
|
1
2
|
module Helpers
|
3
|
+
def http_success
|
4
|
+
200
|
5
|
+
end
|
6
|
+
|
2
7
|
def accessible? url
|
8
|
+
RestClient.proxy = Rents.proxy
|
3
9
|
resp = RestClient.get url
|
10
|
+
RestClient.proxy = nil
|
4
11
|
resp.code == 200 ? true : false
|
5
12
|
end
|
6
13
|
|
@@ -22,4 +29,9 @@ module Helpers
|
|
22
29
|
|
23
30
|
return sold_items
|
24
31
|
end
|
32
|
+
|
33
|
+
def get_json url
|
34
|
+
resp = RestClient.get url
|
35
|
+
JSON.parse(resp).it_keys_to_sym
|
36
|
+
end
|
25
37
|
end
|
data/spec/rents/status_spec.rb
CHANGED