boa_vista 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +13 -5
  2. data/lib/boa_vista/line.rb +4 -4
  3. data/lib/boa_vista/response/layout/condition_validator.rb +15 -0
  4. data/lib/boa_vista/response/layout/default.rb +45 -0
  5. data/lib/boa_vista/response/layout/layout_138.rb +2 -1
  6. data/lib/boa_vista/response/layout/layout_221.rb +2 -1
  7. data/lib/boa_vista/response/layout/layout_249.rb +16 -1
  8. data/lib/boa_vista/response/layout/layout_282.rb +2 -1
  9. data/lib/boa_vista/response/layout/layout_283.rb +2 -1
  10. data/lib/boa_vista/response/layout/layout_285.rb +2 -1
  11. data/lib/boa_vista/response/layout/layout_353.rb +14 -1
  12. data/lib/boa_vista/response/layout/layout_354.rb +2 -1
  13. data/lib/boa_vista/response/layout/layout_901.rb +2 -1
  14. data/lib/boa_vista/response/layout/layout_999.rb +2 -1
  15. data/lib/boa_vista/response/layout.rb +1 -23
  16. data/lib/boa_vista/response/parser.rb +2 -2
  17. data/lib/boa_vista/version.rb +1 -1
  18. data/lib/boa_vista.rb +2 -0
  19. data/spec/fixtures/layout_353.txt +1 -1
  20. data/spec/fixtures/layout_invalid_353.txt +1 -1
  21. data/spec/fixtures/response_with_html.txt +3 -1
  22. data/spec/lib/boa_vista/client_spec.rb +3 -3
  23. data/spec/lib/boa_vista/line_spec.rb +1 -3
  24. data/spec/lib/boa_vista/response/layout/condition_validator_spec.rb +25 -0
  25. data/spec/lib/boa_vista/response/layout/default_spec.rb +2 -0
  26. data/spec/lib/boa_vista/response/layout/layout_138_spec.rb +6 -1
  27. data/spec/lib/boa_vista/response/layout/layout_221_spec.rb +0 -1
  28. data/spec/lib/boa_vista/response/layout/layout_282_spec.rb +0 -1
  29. data/spec/lib/boa_vista/response/layout/layout_283_spec.rb +0 -1
  30. data/spec/lib/boa_vista/response/layout/layout_285_spec.rb +0 -1
  31. data/spec/lib/boa_vista/response/layout/layout_353_spec.rb +3 -2
  32. data/spec/lib/boa_vista/response/layout/layout_354_spec.rb +0 -1
  33. data/spec/lib/boa_vista/response/layout/layout_901_spec.rb +0 -1
  34. data/spec/lib/boa_vista/version_spec.rb +1 -1
  35. metadata +36 -17
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 886a46d623b2bc56ae20f9f98ef31574b57719e6
4
- data.tar.gz: e60184293581b8910692a3a631c838cdcb43ef30
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTYyM2M0NDhiYTgzY2RjNzA5YmIyYzE5NGM0M2ZmM2U5NTc2Y2FlMA==
5
+ data.tar.gz: !binary |-
6
+ NTA0MTJhZDlkMTM1YWI1ZTA2ZTg4ZTBiMzgwZDRkMWE4NGVjMDQ5Ng==
5
7
  SHA512:
6
- metadata.gz: 6edb8b8c0aa843c2536e6344830376f7eb89f0ceec0d69d7e355aabf0a0cb43d065c5b0ef800bf66b3fb9bc414e345f55be4bf2512263da87e280a8d6e2b6dc3
7
- data.tar.gz: dca51e4c37384fabc726d26a244c469123b6f6e2f3333067bf53442cf36b42fa4b2fd919327beac141e5587c14ace2c119044a702990d64833d1cf35bb6a8175
8
+ metadata.gz: !binary |-
9
+ MWJmZmIxOTk0OGI3OWI1ZTNjYjhjZjVmYTc0NzlhNTJmYmEyN2E3OWM3M2My
10
+ Mjk1MDZjODY0OGY2YjhiYzY2N2QyYzA5ZmY3ZmM2NTc1NzE3YTcwZGZlOTAy
11
+ ZWU5NGU3MDBhNGI2MTRkNDc0YTkwNjcxNDc2NTQ3NGYwZGExZTA=
12
+ data.tar.gz: !binary |-
13
+ OTcwYjZlMjgzNTFlN2M2NGMyNTQ2YTViYjg1YzE2MGEwMGFiNTM4NTk1NDI5
14
+ NTkxMWEwYjg5M2E1ODNlNTNjYTFkY2QzZWMwOWZhZDgwODQ0MTc1NGZkZDEy
15
+ YjdmODEyODY1MGJlZGY2MjhmYTdjNTcxYTA0OTYzMTU1Yzc0Mzc=
@@ -41,12 +41,12 @@ module BoaVista
41
41
  self
42
42
  end
43
43
 
44
- def create_method_to_field(name)
45
- define_singleton_method(name) { @fields[name].value }
44
+ def to_hash
45
+ Hash[@fields.map { |k, v| [v.name, v.value]}]
46
46
  end
47
47
 
48
- def valid_record?
49
- record == 'S'.freeze
48
+ def create_method_to_field(name)
49
+ define_singleton_method(name) { @fields[name].value }
50
50
  end
51
51
 
52
52
  private
@@ -0,0 +1,15 @@
1
+ module BoaVista
2
+ class Response
3
+ module Layout
4
+ class ConditionValidator
5
+ def initialize(valids)
6
+ @valids = valids
7
+ end
8
+
9
+ def call(condition)
10
+ @valids.include?(condition)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,45 @@
1
+ module BoaVista
2
+ class Response
3
+ module Layout::Default
4
+
5
+ DEFAULT_ATTRIBUTES = {
6
+ transaction: { range: 0..7 },
7
+ version: { range: 8..9 },
8
+ reserved_requester: { range: 10..19 },
9
+ reserved_boa_vista: { range: 20..39 },
10
+ code: { range: 40..47 },
11
+ query: { range: 48..55 },
12
+ query_version: { range: 56..57 },
13
+ response_type: { range: 58..58 },
14
+ response_code: { range: 59..59 },
15
+ query_number: { range: 60..66 },
16
+ text_size: { range: 67..70 },
17
+ record_size: { range: 71..73 },
18
+ record_type: { range: 74..76 }
19
+ }
20
+
21
+ def default_attributes
22
+ DEFAULT_ATTRIBUTES
23
+ end
24
+
25
+ def layout_with_conditions
26
+ [
27
+ BoaVista::Response::Layout::Layout353,
28
+ BoaVista::Response::Layout::Layout249
29
+ ]
30
+ end
31
+
32
+ def has_conditions?
33
+ layout_with_conditions.include?(self)
34
+ end
35
+
36
+ module_function
37
+ def range_of(attribute)
38
+ DEFAULT_ATTRIBUTES[attribute][:range]
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+
45
+
@@ -1,6 +1,7 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  module Layout::Layout138
4
+ extend Layout::Default
4
5
  module_function
5
6
 
6
7
  def initialize(fields)
@@ -8,7 +9,7 @@ module BoaVista
8
9
  end
9
10
 
10
11
  def attributes
11
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..77 },
12
+ default_attributes.merge(record: { range: 77..77 },
12
13
  document_number: { range: 78..91 },
13
14
  company_name: { range: 92..206 },
14
15
  city: { range: 207..246 },
@@ -1,10 +1,11 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  module Layout::Layout221
4
+ extend Layout::Default
4
5
  module_function
5
6
 
6
7
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..77 },
8
+ default_attributes.merge(record: { range: 77..77 },
8
9
  name: { range: 78..127 },
9
10
  document: { range: 128..138 },
10
11
  birthday_date: { range: 139..146 },
@@ -1,10 +1,12 @@
1
+ # encoding: UTF-8
1
2
  module BoaVista
2
3
  class Response
3
4
  module Layout::Layout249
5
+ extend Layout::Default
4
6
  module_function
5
7
 
6
8
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(query_online: { range: 77..77 },
9
+ default_attributes.merge(query_online: { range: 77..77 },
8
10
  name: { range: 78..127 },
9
11
  document: { range: 128..138 },
10
12
  birthday_date: { range: 139..146 },
@@ -15,6 +17,19 @@ module BoaVista
15
17
  query_time: { range: 221..226 },
16
18
  protocol: { range: 227..246 })
17
19
  end
20
+
21
+ def condition_options
22
+ {
23
+ 1 => 'Regular',
24
+ 2 => 'Cancelado',
25
+ 3 => 'Pendente',
26
+ 4 => 'Suspenso',
27
+ 5 => 'Inexistente',
28
+ 6 => 'Dados incompletos',
29
+ 7 => 'Nula',
30
+ 8 => 'Não especificado'
31
+ }
32
+ end
18
33
  end
19
34
  end
20
35
  end
@@ -1,10 +1,11 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  module Layout::Layout282
4
+ extend Layout::Default
4
5
  module_function
5
6
 
6
7
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..77 },
8
+ default_attributes.merge(record: { range: 77..77 },
8
9
  sequence_number: { range: 78..79 },
9
10
  company_name: { range: 80..129 },
10
11
  document_type: { range: 130..130 },
@@ -1,10 +1,11 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  module Layout::Layout283
4
+ extend Layout::Default
4
5
  module_function
5
6
 
6
7
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..77 },
8
+ default_attributes.merge(record: { range: 77..77 },
8
9
  sequence_number: { range: 78..82 },
9
10
  company_name: { range: 83..132 },
10
11
  document_type: { range: 133..133 },
@@ -1,10 +1,11 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  module Layout::Layout285
4
+ extend Layout::Default
4
5
  module_function
5
6
 
6
7
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..77 },
8
+ default_attributes.merge(record: { range: 77..77 },
8
9
  hive_activity_code: { range: 78..85 },
9
10
  hive_activity_description: { range: 86..140 })
10
11
  end
@@ -1,10 +1,12 @@
1
+ # encoding: UTF-8
1
2
  module BoaVista
2
3
  class Response
3
4
  module Layout::Layout353
5
+ extend Layout::Default
4
6
  module_function
5
7
 
6
8
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..77 },
9
+ default_attributes.merge(record: { range: 77..77 },
8
10
  document_number: { range: 78..91 },
9
11
  nire: { range: 92..102 },
10
12
  company_name: { range: 103..217 },
@@ -27,6 +29,17 @@ module BoaVista
27
29
  hive_activity_code: { range: 582..589 },
28
30
  hive_activity_description: { range: 590..644 })
29
31
  end
32
+
33
+ def condition_options
34
+ {
35
+ 0 => 'Ativo',
36
+ 1 => 'Inapto',
37
+ 2 => 'Suspenso',
38
+ 6 => 'Baixado',
39
+ 7 => 'Nulo',
40
+ 8 => 'Cancelado'
41
+ }
42
+ end
30
43
  end
31
44
  end
32
45
  end
@@ -1,10 +1,11 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  module Layout::Layout354
4
+ extend Layout::Default
4
5
  module_function
5
6
 
6
7
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..77 },
8
+ default_attributes.merge(record: { range: 77..77 },
8
9
  document_number: { range: 78..91 },
9
10
  currency_social_capital: { range: 92..95 },
10
11
  value_social_capital: { range: 96..110 },
@@ -1,10 +1,11 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  module Layout::Layout901
4
+ extend Layout::Default
4
5
  module_function
5
6
 
6
7
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..77 },
8
+ default_attributes.merge(record: { range: 77..77 },
8
9
  message_type: { range: 78..78 },
9
10
  message: { range: 79..208 })
10
11
  end
@@ -1,10 +1,11 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  module Layout::Layout999
4
+ extend Layout::Default
4
5
  module_function
5
6
 
6
7
  def attributes
7
- BoaVista::Response::Layout.attributes.merge(record: { range: 77..171 })
8
+ default_attributes.merge(record: { range: 77..171 })
8
9
  end
9
10
  end
10
11
  end
@@ -3,36 +3,14 @@ module BoaVista
3
3
  module Layout
4
4
  module_function
5
5
 
6
- def attributes
7
- {
8
- transaction: { range: 0..7 },
9
- version: { range: 8..9 },
10
- reserved_requester: { range: 10..19 },
11
- reserved_boa_vista: { range: 20..39 },
12
- code: { range: 40..47 },
13
- query: { range: 48..55 },
14
- query_version: { range: 56..57 },
15
- response_type: { range: 58..58 },
16
- response_code: { range: 59..59 },
17
- query_number: { range: 60..66 },
18
- text_size: { range: 67..70 },
19
- record_size: { range: 71..73 },
20
- record_type: { range: 74..76 }
21
- }
22
- end
23
-
24
6
  def detect(value)
25
7
  begin
26
- layout = value.slice(BoaVista::Response::Layout.range_of(:record_type))
8
+ layout = value.slice(BoaVista::Response::Layout::Default.range_of(:record_type))
27
9
  eval "BoaVista::Response::Layout::Layout#{layout}"
28
10
  rescue NameError
29
11
  fail Errors::InvalidLayout.new("Layout of response invalid, layout_code: #{layout}")
30
12
  end
31
13
  end
32
-
33
- def range_of(attribute)
34
- attributes[attribute][:range]
35
- end
36
14
  end
37
15
  end
38
16
  end
@@ -1,7 +1,7 @@
1
1
  module BoaVista
2
2
  class Response
3
3
  class Parser
4
- INVALID_STRING = "\\n"
4
+ INVALID_STRING = "<PRE>"
5
5
  BLANK_SPACE = ''
6
6
 
7
7
  def initialize(response, base_tag = '//pre')
@@ -21,7 +21,7 @@ module BoaVista
21
21
  end
22
22
 
23
23
  def sanitize(response)
24
- response.gsub(INVALID_STRING, BLANK_SPACE)
24
+ response.gsub("\n", BLANK_SPACE)
25
25
  end
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module BoaVista
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
data/lib/boa_vista.rb CHANGED
@@ -23,6 +23,8 @@ require 'boa_vista/response'
23
23
  require 'boa_vista/response/layout'
24
24
  require 'boa_vista/response/parser'
25
25
 
26
+ require 'boa_vista/response/layout/default'
27
+ require 'boa_vista/response/layout/condition_validator'
26
28
  require 'boa_vista/response/layout/layout_138'
27
29
  require 'boa_vista/response/layout/layout_282'
28
30
  require 'boa_vista/response/layout/layout_283'
@@ -1 +1 @@
1
- TTTTTTTTVVRRRRRRRRRRBBBBBBBBBBBBBBBBBBBBCCCCCCCCQQQQQQQQQVYCNNNNNNNTTTTZZZ353SDDDDDDDDDDDDDDNNNNNNNNNNNCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCTFFFFFFFFRRRRRRRRRRRRRRSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBPPPPPPPPCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCUUPPPPPPPPPPPPPPPPPPPPHHHHHHHHHHHHHHHFFFFFFFFFFFFFFFGGGGGGGGNNNNNNNNDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD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RRRRRRRRDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
@@ -1 +1,3 @@
1
- \n\n\t\n\t\t\n\t\t\n \n \n \t \n \n \n \t \n\t\n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<PRE>\nCSR61 01 00000045 2900000000101098999* IDENTIFICADOR COM RESTRICAO DE ACESSO \n</PRE>\n\n
1
+ \n\n\t\n\t\t\n\t\t\n \n \n \t \n \n \n \t \n\t\n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<PRE>
2
+ CSR61 01 00000045 2900000000101098999* IDENTIFICADOR COM RESTRICAO DE ACESSO
3
+ </PRE>\n\n
@@ -18,14 +18,14 @@ RSpec.describe BoaVista::Client do
18
18
 
19
19
  its(:transaction) { is_expected.to eq('T' * 8) }
20
20
 
21
- context 'when record is valid' do
22
- its(:valid_record?) { is_expected.to be_truthy }
21
+ context 'when condition is valid' do
22
+ its(:condition) { is_expected.to eq('0') }
23
23
  end
24
24
 
25
25
  context 'when record is invalid' do
26
26
  let(:line) { File.read('./spec/fixtures/layout_invalid_353.txt') }
27
27
 
28
- its(:valid_record?) { is_expected.to be_falsey }
28
+ its(:condition) { is_expected.to eq('4') }
29
29
  end
30
30
 
31
31
  context 'when response has an html and has an invalid response' do
@@ -2,7 +2,7 @@ RSpec.describe BoaVista::Line do
2
2
  let(:line) { File.read('./spec/fixtures/base.txt') }
3
3
 
4
4
  context 'when layout is BoaVista::Response::Layout' do
5
- let(:instance) { described_class.prepare_for_read(line, BoaVista::Response::Layout) }
5
+ let(:instance) { described_class.prepare_for_read(line, BoaVista::Response::Layout::Layout138) }
6
6
 
7
7
  describe '#read' do
8
8
  subject { instance.read }
@@ -55,7 +55,5 @@ RSpec.describe BoaVista::Line do
55
55
  end
56
56
  end
57
57
 
58
- context 'when record is valid' do
59
- end
60
58
  end
61
59
  end
@@ -0,0 +1,25 @@
1
+ RSpec.describe BoaVista::Response::Layout::ConditionValidator do
2
+ let(:instance) { described_class.new(valids) }
3
+
4
+ describe '#call' do
5
+ let(:valids) { ['1', '2', '4'] }
6
+
7
+ context 'when layout is 249' do
8
+ subject { instance.call(condition) }
9
+
10
+ context 'when condition is valid' do
11
+ let(:condition) {'1'}
12
+
13
+ it { is_expected.to eq(true) }
14
+
15
+ end
16
+
17
+ context 'when condition is invalid' do
18
+ let(:condition) {'5'}
19
+
20
+ it { is_expected.to eq(false) }
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,2 @@
1
+ RSpec.describe BoaVista::Response::Layout::Layout138 do
2
+ end
@@ -14,6 +14,11 @@ RSpec.describe BoaVista::Response::Layout::Layout138 do
14
14
  its(:uf) { is_expected.to eq('U' * 2) }
15
15
 
16
16
  its(:record_type) { is_expected.to eq('138') }
17
- its(:valid_record?) { is_expected.to eq(true)}
17
+ end
18
+
19
+ describe '.has_conditions?' do
20
+ subject { described_class.has_conditions? }
21
+
22
+ it { is_expected.to eq(false) }
18
23
  end
19
24
  end
@@ -14,6 +14,5 @@ RSpec.describe BoaVista::Response::Layout::Layout221 do
14
14
  its(:voter_registration) { is_expected.to eq('V' * 13) }
15
15
 
16
16
  its(:record_type) { is_expected.to eq('221') }
17
- its(:valid_record?) { is_expected.to eq(true) }
18
17
  end
19
18
  end
@@ -14,6 +14,5 @@ RSpec.describe BoaVista::Response::Layout::Layout282 do
14
14
  its(:document_number) { is_expected.to eq('57487067000110') }
15
15
 
16
16
  its(:record_type) { is_expected.to eq('282') }
17
- its(:valid_record?) { is_expected.to eq(true) }
18
17
  end
19
18
  end
@@ -20,6 +20,5 @@ RSpec.describe BoaVista::Response::Layout::Layout283 do
20
20
  its(:percentage) { is_expected.to eq('G' * 5) }
21
21
 
22
22
  its(:record_type) { is_expected.to eq('283') }
23
- its(:valid_record?) { is_expected.to eq(true) }
24
23
  end
25
24
  end
@@ -13,6 +13,5 @@ RSpec.describe BoaVista::Response::Layout::Layout285 do
13
13
 
14
14
 
15
15
  its(:record_type) { is_expected.to eq('285') }
16
- its(:valid_record?) { is_expected.to eq(true) }
17
16
  end
18
17
  end
@@ -10,7 +10,7 @@ RSpec.describe BoaVista::Response::Layout::Layout353 do
10
10
  its(:document_number) { is_expected.to eq('D' * 14) }
11
11
  its(:nire) { is_expected.to eq('N' * 11) }
12
12
  its(:company_name) { is_expected.to eq('C' * 115) }
13
- its(:condition) { is_expected.to eq('T') }
13
+ its(:condition) { is_expected.to eq('0') }
14
14
  its(:foundation_date) { is_expected.to eq('F' * 8) }
15
15
  its(:registration) { is_expected.to eq('R' * 14) }
16
16
  its(:registration_status) { is_expected.to eq('S') }
@@ -30,6 +30,7 @@ RSpec.describe BoaVista::Response::Layout::Layout353 do
30
30
  its(:hive_activity_description) { is_expected.to eq('D' * 55) }
31
31
 
32
32
  its(:record_type) { is_expected.to eq('353') }
33
- its(:valid_record?) { is_expected.to eq(true) }
33
+
34
+ its(:'layout.has_conditions?') { is_expected.to eq(true) }
34
35
  end
35
36
  end
@@ -19,6 +19,5 @@ RSpec.describe BoaVista::Response::Layout::Layout354 do
19
19
  its(:change_date) { is_expected.to eq('D' * 8) }
20
20
 
21
21
  its(:record_type) { is_expected.to eq('354') }
22
- its(:valid_record?) { is_expected.to eq(true) }
23
22
  end
24
23
  end
@@ -13,6 +13,5 @@ RSpec.describe BoaVista::Response::Layout::Layout901 do
13
13
 
14
14
 
15
15
  its(:record_type) { is_expected.to eq('901') }
16
- its(:valid_record?) { is_expected.to eq(true) }
17
16
  end
18
17
  end
@@ -1,3 +1,3 @@
1
1
  RSpec.describe BoaVista::VERSION do
2
- specify { expect(BoaVista::VERSION).to eq '0.0.4' }
2
+ specify { expect(BoaVista::VERSION).to eq '0.0.5' }
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boa_vista
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Souza
@@ -15,84 +15,98 @@ dependencies:
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - ! '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - ! '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: codeclimate-test-reporter
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - ! '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - ! '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: webmock
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - ! '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - ! '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: pry
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
68
82
  - !ruby/object:Gem::Version
69
83
  version: '0'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: rspec-its
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
- - - ">="
88
+ - - ! '>='
75
89
  - !ruby/object:Gem::Version
76
90
  version: '0'
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
- - - ">="
95
+ - - ! '>='
82
96
  - !ruby/object:Gem::Version
83
97
  version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: rake
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
- - - ">="
102
+ - - ! '>='
89
103
  - !ruby/object:Gem::Version
90
104
  version: '0'
91
105
  type: :development
92
106
  prerelease: false
93
107
  version_requirements: !ruby/object:Gem::Requirement
94
108
  requirements:
95
- - - ">="
109
+ - - ! '>='
96
110
  - !ruby/object:Gem::Version
97
111
  version: '0'
98
112
  description: Client for Boa Vista
@@ -121,6 +135,8 @@ files:
121
135
  - lib/boa_vista/request/layout/cpf.rb
122
136
  - lib/boa_vista/response.rb
123
137
  - lib/boa_vista/response/layout.rb
138
+ - lib/boa_vista/response/layout/condition_validator.rb
139
+ - lib/boa_vista/response/layout/default.rb
124
140
  - lib/boa_vista/response/layout/layout_138.rb
125
141
  - lib/boa_vista/response/layout/layout_221.rb
126
142
  - lib/boa_vista/response/layout/layout_249.rb
@@ -160,6 +176,8 @@ files:
160
176
  - spec/lib/boa_vista/request/layout/cpf_spec.rb
161
177
  - spec/lib/boa_vista/request/layout_spec.rb
162
178
  - spec/lib/boa_vista/request_spec.rb
179
+ - spec/lib/boa_vista/response/layout/condition_validator_spec.rb
180
+ - spec/lib/boa_vista/response/layout/default_spec.rb
163
181
  - spec/lib/boa_vista/response/layout/layout_138_spec.rb
164
182
  - spec/lib/boa_vista/response/layout/layout_221_spec.rb
165
183
  - spec/lib/boa_vista/response/layout/layout_249_spec.rb
@@ -184,17 +202,17 @@ require_paths:
184
202
  - lib
185
203
  required_ruby_version: !ruby/object:Gem::Requirement
186
204
  requirements:
187
- - - ">="
205
+ - - ! '>='
188
206
  - !ruby/object:Gem::Version
189
207
  version: '0'
190
208
  required_rubygems_version: !ruby/object:Gem::Requirement
191
209
  requirements:
192
- - - ">="
210
+ - - ! '>='
193
211
  - !ruby/object:Gem::Version
194
212
  version: '0'
195
213
  requirements: []
196
214
  rubyforge_project:
197
- rubygems_version: 2.4.6
215
+ rubygems_version: 2.4.8
198
216
  signing_key:
199
217
  specification_version: 4
200
218
  summary: Client for Boa Vista
@@ -226,6 +244,8 @@ test_files:
226
244
  - spec/lib/boa_vista/request/layout/cpf_spec.rb
227
245
  - spec/lib/boa_vista/request/layout_spec.rb
228
246
  - spec/lib/boa_vista/request_spec.rb
247
+ - spec/lib/boa_vista/response/layout/condition_validator_spec.rb
248
+ - spec/lib/boa_vista/response/layout/default_spec.rb
229
249
  - spec/lib/boa_vista/response/layout/layout_138_spec.rb
230
250
  - spec/lib/boa_vista/response/layout/layout_221_spec.rb
231
251
  - spec/lib/boa_vista/response/layout/layout_249_spec.rb
@@ -241,4 +261,3 @@ test_files:
241
261
  - spec/lib/boa_vista/response_spec.rb
242
262
  - spec/lib/boa_vista/version_spec.rb
243
263
  - spec/spec_helper.rb
244
- has_rdoc: