clearsale 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  *.sw*
2
+ tags
2
3
  *.gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearsale (0.1.2)
4
+ clearsale (0.1.3)
5
5
  builder
6
6
  savon
7
7
 
@@ -15,7 +15,7 @@ GEM
15
15
  akami (1.2.0)
16
16
  gyoku (>= 0.4.0)
17
17
  nokogiri (>= 1.4.0)
18
- builder (3.0.0)
18
+ builder (3.0.3)
19
19
  columnize (0.3.6)
20
20
  crack (0.3.1)
21
21
  curb (0.8.1)
@@ -74,7 +74,7 @@ GEM
74
74
  thor (0.15.4)
75
75
  timecop (0.4.1)
76
76
  vcr (1.11.3)
77
- wasabi (2.5.0)
77
+ wasabi (2.5.1)
78
78
  httpi (~> 1.0)
79
79
  nokogiri (>= 1.4.0)
80
80
  webmock (1.7.10)
@@ -8,4 +8,5 @@ module Clearsale
8
8
  autoload :OrderResponse, 'clearsale/order_response'
9
9
  autoload :Connector, 'clearsale/connector'
10
10
  autoload :Analysis, 'clearsale/analysis'
11
+ autoload :LoggerFormatterFilter, 'clearsale/logger_formatter_filter'
11
12
  end
@@ -0,0 +1,30 @@
1
+ module Clearsale::LoggerFormatterFilter
2
+
3
+ mattr_accessor :tags_to_filter
4
+
5
+ OPEN_TAG = lambda{ |tag_name| "<#{tag_name}>" }
6
+ CLOSE_TAG = lambda{ |tag_name| "<\/#{tag_name}>" }
7
+ TAG_REGEXP = lambda{ |tag_name, content| "#{OPEN_TAG.call(tag_name)}#{content}#{CLOSE_TAG.call(tag_name)}" }
8
+
9
+ def self.filter(msg)
10
+ return msg if !msg.respond_to?(:gsub) || tags_to_filter.nil?
11
+
12
+ tags_to_filter.each do |tag|
13
+ msg = msg.gsub(%r{#{TAG_REGEXP.call(tag,'.*')}}, TAG_REGEXP.call(tag,"[FILTERED]"))
14
+ end
15
+ msg
16
+ end
17
+
18
+ def self.new_instance(&block)
19
+ if block_given?
20
+ lambda do |severity, datetime, progname, msg|
21
+ block.call(severity, datetime, progname, filter(msg))
22
+ end
23
+ else
24
+ lambda do |severity, datetime, progname, msg|
25
+ "#{severity} #{datetime} --#{progname}: #{filter(msg)}"
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -1,3 +1,3 @@
1
1
  module Clearsale
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.clearsale.com.br/integration" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
3
+ <soap:Body>
4
+ <int:SendOrders>
5
+ <int:xml>&lt;ClearSale&gt;&lt;Orders&gt;&lt;Order&gt;&lt;ID&gt;83F027&lt;/ID&gt;&lt;Date&gt;2012-09-13T13:54:53&lt;/Date&gt;&lt;Email&gt;dkonishi@gmail.com&lt;/Email&gt;&lt;TotalItens&gt;10.9&lt;/TotalItens&gt;&lt;TotalOrder&gt;10.9&lt;/TotalOrder&gt;&lt;QtyInstallments&gt;1&lt;/QtyInstallments&gt;&lt;QtyItems&gt;1&lt;/QtyItems&gt;&lt;IP&gt;127.0.0.1&lt;/IP&gt;&lt;CollectionData&gt;&lt;ID&gt;14&lt;/ID&gt;&lt;Type&gt;1&lt;/Type&gt;&lt;LegalDocument1&gt;27836038882&lt;/LegalDocument1&gt;&lt;Name&gt;Daniel Konishi&lt;/Name&gt;&lt;BirthDate&gt;1990-10-10T00:00:00&lt;/BirthDate&gt;&lt;Email&gt;dkonishi@gmail.com&lt;/Email&gt;&lt;Genre&gt;m&lt;/Genre&gt;&lt;Address&gt;&lt;Street&gt;Rua Carlos Del Prete&lt;/Street&gt;&lt;Number&gt;212&lt;/Number&gt;&lt;Comp&gt;&lt;/Comp&gt;&lt;County&gt;Centro&lt;/County&gt;&lt;City&gt;São Bernardo do Campo&lt;/City&gt;&lt;State&gt;SP&lt;/State&gt;&lt;ZipCode&gt;09710-230&lt;/ZipCode&gt;&lt;/Address&gt;&lt;Phones&gt;&lt;Phone&gt;&lt;Type&gt;0&lt;/Type&gt;&lt;DDD&gt;11&lt;/DDD&gt;&lt;Number&gt;345678977&lt;/Number&gt;&lt;/Phone&gt;&lt;/Phones&gt;&lt;/CollectionData&gt;&lt;ShippingData&gt;&lt;ID&gt;14&lt;/ID&gt;&lt;Type&gt;1&lt;/Type&gt;&lt;LegalDocument1&gt;27836038882&lt;/LegalDocument1&gt;&lt;Name&gt;Daniel Konishi&lt;/Name&gt;&lt;BirthDate&gt;1990-10-10T00:00:00&lt;/BirthDate&gt;&lt;Email&gt;dkonishi@gmail.com&lt;/Email&gt;&lt;Genre&gt;m&lt;/Genre&gt;&lt;Address&gt;&lt;Street&gt;Rua Carlos Del Prete&lt;/Street&gt;&lt;Number&gt;212&lt;/Number&gt;&lt;Comp&gt;&lt;/Comp&gt;&lt;County&gt;Centro&lt;/County&gt;&lt;City&gt;São Bernardo do Campo&lt;/City&gt;&lt;State&gt;SP&lt;/State&gt;&lt;ZipCode&gt;09710-230&lt;/ZipCode&gt;&lt;/Address&gt;&lt;Phones&gt;&lt;Phone&gt;&lt;Type&gt;0&lt;/Type&gt;&lt;DDD&gt;11&lt;/DDD&gt;&lt;Number&gt;345678977&lt;/Number&gt;&lt;/Phone&gt;&lt;/Phones&gt;&lt;/ShippingData&gt;&lt;Payments&gt;&lt;Payment&gt;&lt;Date&gt;2012-09-13T13:54:53&lt;/Date&gt;&lt;Amount&gt;10.9&lt;/Amount&gt;&lt;PaymentTypeID&gt;1&lt;/PaymentTypeID&gt;&lt;QtyInstallments&gt;1&lt;/QtyInstallments&gt;&lt;CardNumber&gt;4000000000000002&lt;/CardNumber&gt;&lt;CardBin&gt;1234&lt;/CardBin&gt;&lt;CardType&gt;5&lt;/CardType&gt;&lt;CardExpirationDate&gt;02/13&lt;/CardExpirationDate&gt;&lt;Name&gt;McKay Thomas&lt;/Name&gt;&lt;LegalDocument&gt;27836038882&lt;/LegalDocument&gt;&lt;Address&gt;&lt;Street&gt;Rua Carlos Del Prete&lt;/Street&gt;&lt;Number&gt;212&lt;/Number&gt;&lt;Comp&gt;&lt;/Comp&gt;&lt;County&gt;Centro&lt;/County&gt;&lt;City&gt;São Bernardo do Campo&lt;/City&gt;&lt;State&gt;SP&lt;/State&gt;&lt;ZipCode&gt;09710-230&lt;/ZipCode&gt;&lt;/Address&gt;&lt;/Payment&gt;&lt;/Payments&gt;&lt;Items&gt;&lt;Item&gt;&lt;ID&gt;123&lt;/ID&gt;&lt;Name&gt;Produto 2&lt;/Name&gt;&lt;ItemValue&gt;1.0&lt;/ItemValue&gt;&lt;Qty&gt;1&lt;/Qty&gt;&lt;/Item&gt;&lt;/Items&gt;&lt;/Order&gt;&lt;/Orders&gt;&lt;/ClearSale&gt;</int:xml>
6
+ <int:entityCode>0E6F0C82-FC05-4AA7-86D4-EBBFC0FDC41A</int:entityCode>
7
+ </int:SendOrders>
8
+ </soap:Body>
9
+ </soap:Envelope>
10
+
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.clearsale.com.br/integration" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
3
+ <soap:Body>
4
+ <int:SendOrders>
5
+ <int:xml>&lt;ClearSale&gt;&lt;Orders&gt;&lt;Order&gt;&lt;ID&gt;83F027&lt;/ID&gt;&lt;Date&gt;2012-09-13T13:54:53&lt;/Date&gt;&lt;Email&gt;dkonishi@gmail.com&lt;/Email&gt;&lt;TotalItens&gt;10.9&lt;/TotalItens&gt;&lt;TotalOrder&gt;10.9&lt;/TotalOrder&gt;&lt;QtyInstallments&gt;1&lt;/QtyInstallments&gt;&lt;QtyItems&gt;1&lt;/QtyItems&gt;&lt;IP&gt;127.0.0.1&lt;/IP&gt;&lt;CollectionData&gt;&lt;ID&gt;14&lt;/ID&gt;&lt;Type&gt;1&lt;/Type&gt;&lt;LegalDocument1&gt;27836038882&lt;/LegalDocument1&gt;&lt;Name&gt;Daniel Konishi&lt;/Name&gt;&lt;BirthDate&gt;1990-10-10T00:00:00&lt;/BirthDate&gt;&lt;Email&gt;dkonishi@gmail.com&lt;/Email&gt;&lt;Genre&gt;m&lt;/Genre&gt;&lt;Address&gt;&lt;Street&gt;Rua Carlos Del Prete&lt;/Street&gt;&lt;Number&gt;212&lt;/Number&gt;&lt;Comp&gt;&lt;/Comp&gt;&lt;County&gt;Centro&lt;/County&gt;&lt;City&gt;São Bernardo do Campo&lt;/City&gt;&lt;State&gt;SP&lt;/State&gt;&lt;ZipCode&gt;09710-230&lt;/ZipCode&gt;&lt;/Address&gt;&lt;Phones&gt;&lt;Phone&gt;&lt;Type&gt;0&lt;/Type&gt;&lt;DDD&gt;11&lt;/DDD&gt;&lt;Number&gt;345678977&lt;/Number&gt;&lt;/Phone&gt;&lt;/Phones&gt;&lt;/CollectionData&gt;&lt;ShippingData&gt;&lt;ID&gt;14&lt;/ID&gt;&lt;Type&gt;1&lt;/Type&gt;&lt;LegalDocument1&gt;27836038882&lt;/LegalDocument1&gt;&lt;Name&gt;Daniel Konishi&lt;/Name&gt;&lt;BirthDate&gt;1990-10-10T00:00:00&lt;/BirthDate&gt;&lt;Email&gt;dkonishi@gmail.com&lt;/Email&gt;&lt;Genre&gt;m&lt;/Genre&gt;&lt;Address&gt;&lt;Street&gt;Rua Carlos Del Prete&lt;/Street&gt;&lt;Number&gt;212&lt;/Number&gt;&lt;Comp&gt;&lt;/Comp&gt;&lt;County&gt;Centro&lt;/County&gt;&lt;City&gt;São Bernardo do Campo&lt;/City&gt;&lt;State&gt;SP&lt;/State&gt;&lt;ZipCode&gt;09710-230&lt;/ZipCode&gt;&lt;/Address&gt;&lt;Phones&gt;&lt;Phone&gt;&lt;Type&gt;0&lt;/Type&gt;&lt;DDD&gt;11&lt;/DDD&gt;&lt;Number&gt;345678977&lt;/Number&gt;&lt;/Phone&gt;&lt;/Phones&gt;&lt;/ShippingData&gt;&lt;Payments&gt;&lt;Payment&gt;&lt;Date&gt;2012-09-13T13:54:53&lt;/Date&gt;&lt;Amount&gt;10.9&lt;/Amount&gt;&lt;PaymentTypeID&gt;1&lt;/PaymentTypeID&gt;&lt;QtyInstallments&gt;1&lt;/QtyInstallments&gt;&lt;CardNumber&gt;[FILTERED]&lt;/CardNumber&gt;&lt;CardBin&gt;[FILTERED]&lt;/CardBin&gt;&lt;CardType&gt;5&lt;/CardType&gt;&lt;CardExpirationDate&gt;02/13&lt;/CardExpirationDate&gt;&lt;Name&gt;McKay Thomas&lt;/Name&gt;&lt;LegalDocument&gt;27836038882&lt;/LegalDocument&gt;&lt;Address&gt;&lt;Street&gt;Rua Carlos Del Prete&lt;/Street&gt;&lt;Number&gt;212&lt;/Number&gt;&lt;Comp&gt;&lt;/Comp&gt;&lt;County&gt;Centro&lt;/County&gt;&lt;City&gt;São Bernardo do Campo&lt;/City&gt;&lt;State&gt;SP&lt;/State&gt;&lt;ZipCode&gt;09710-230&lt;/ZipCode&gt;&lt;/Address&gt;&lt;/Payment&gt;&lt;/Payments&gt;&lt;Items&gt;&lt;Item&gt;&lt;ID&gt;123&lt;/ID&gt;&lt;Name&gt;Produto 2&lt;/Name&gt;&lt;ItemValue&gt;1.0&lt;/ItemValue&gt;&lt;Qty&gt;1&lt;/Qty&gt;&lt;/Item&gt;&lt;/Items&gt;&lt;/Order&gt;&lt;/Orders&gt;&lt;/ClearSale&gt;</int:xml>
6
+ <int:entityCode>0E6F0C82-FC05-4AA7-86D4-EBBFC0FDC41A</int:entityCode>
7
+ </int:SendOrders>
8
+ </soap:Body>
9
+ </soap:Envelope>
10
+
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'logger'
3
+ require 'tempfile'
4
+
5
+ describe Clearsale::LoggerFormatterFilter do
6
+ let(:tmp_file) { Tempfile.new('tagfilter') }
7
+ let(:logger) { Logger.new tmp_file }
8
+
9
+ let(:order_xml) { File.read('./spec/fixtures/clearsale.xml').chomp }
10
+ let(:filtered_order_xml) { File.read('./spec/fixtures/filtered_clearsale.xml').chomp }
11
+
12
+ before do
13
+ described_class.tags_to_filter = %w(CardNumber CardBin)
14
+ logger.formatter = described_class.new_instance do |severity, datetime, progname, filtered_msg|
15
+ "#{severity} #{filtered_msg}"
16
+ end
17
+ end
18
+
19
+ after do
20
+ tmp_file.close
21
+ end
22
+
23
+ it "filters the configured tag names" do
24
+ logger.info(order_xml)
25
+ tmp_file.rewind
26
+ tmp_file.read.should == "INFO #{filtered_order_xml}"
27
+ end
28
+ end
29
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearsale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-08 00:00:00.000000000 Z
12
+ date: 2012-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -253,14 +253,18 @@ files:
253
253
  - lib/clearsale.rb
254
254
  - lib/clearsale/analysis.rb
255
255
  - lib/clearsale/connector.rb
256
+ - lib/clearsale/logger_formatter_filter.rb
256
257
  - lib/clearsale/object.rb
257
258
  - lib/clearsale/order.rb
258
259
  - lib/clearsale/order_response.rb
259
260
  - lib/clearsale/version.rb
261
+ - spec/fixtures/clearsale.xml
262
+ - spec/fixtures/filtered_clearsale.xml
260
263
  - spec/fixtures/vcr_cassettes/clearsale_get_order_status.yml
261
264
  - spec/fixtures/vcr_cassettes/clearsale_get_order_status_missing.yml
262
265
  - spec/fixtures/vcr_cassettes/clearsale_get_order_status_production.yml
263
266
  - spec/fixtures/vcr_cassettes/clearsale_send_orders.yml
267
+ - spec/logger_formatter_spec.rb
264
268
  - spec/object_spec.rb
265
269
  - spec/order_response_spec.rb
266
270
  - spec/order_spec.rb
@@ -281,7 +285,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
285
  version: '0'
282
286
  segments:
283
287
  - 0
284
- hash: 4472313349934867165
288
+ hash: -3140110756555446380
285
289
  required_rubygems_version: !ruby/object:Gem::Requirement
286
290
  none: false
287
291
  requirements:
@@ -290,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
294
  version: '0'
291
295
  segments:
292
296
  - 0
293
- hash: 4472313349934867165
297
+ hash: -3140110756555446380
294
298
  requirements: []
295
299
  rubyforge_project: clearsale
296
300
  rubygems_version: 1.8.24
@@ -298,10 +302,13 @@ signing_key:
298
302
  specification_version: 3
299
303
  summary: clearsale gem to use Clearsale service
300
304
  test_files:
305
+ - spec/fixtures/clearsale.xml
306
+ - spec/fixtures/filtered_clearsale.xml
301
307
  - spec/fixtures/vcr_cassettes/clearsale_get_order_status.yml
302
308
  - spec/fixtures/vcr_cassettes/clearsale_get_order_status_missing.yml
303
309
  - spec/fixtures/vcr_cassettes/clearsale_get_order_status_production.yml
304
310
  - spec/fixtures/vcr_cassettes/clearsale_send_orders.yml
311
+ - spec/logger_formatter_spec.rb
305
312
  - spec/object_spec.rb
306
313
  - spec/order_response_spec.rb
307
314
  - spec/order_spec.rb