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 +1 -0
- data/Gemfile.lock +3 -3
- data/lib/clearsale.rb +1 -0
- data/lib/clearsale/logger_formatter_filter.rb +30 -0
- data/lib/clearsale/version.rb +1 -1
- data/spec/fixtures/clearsale.xml +10 -0
- data/spec/fixtures/filtered_clearsale.xml +10 -0
- data/spec/logger_formatter_spec.rb +29 -0
- metadata +11 -4
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
clearsale (0.1.
|
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.
|
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.
|
77
|
+
wasabi (2.5.1)
|
78
78
|
httpi (~> 1.0)
|
79
79
|
nokogiri (>= 1.4.0)
|
80
80
|
webmock (1.7.10)
|
data/lib/clearsale.rb
CHANGED
@@ -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
|
+
|
data/lib/clearsale/version.rb
CHANGED
@@ -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><ClearSale><Orders><Order><ID>83F027</ID><Date>2012-09-13T13:54:53</Date><Email>dkonishi@gmail.com</Email><TotalItens>10.9</TotalItens><TotalOrder>10.9</TotalOrder><QtyInstallments>1</QtyInstallments><QtyItems>1</QtyItems><IP>127.0.0.1</IP><CollectionData><ID>14</ID><Type>1</Type><LegalDocument1>27836038882</LegalDocument1><Name>Daniel Konishi</Name><BirthDate>1990-10-10T00:00:00</BirthDate><Email>dkonishi@gmail.com</Email><Genre>m</Genre><Address><Street>Rua Carlos Del Prete</Street><Number>212</Number><Comp></Comp><County>Centro</County><City>São Bernardo do Campo</City><State>SP</State><ZipCode>09710-230</ZipCode></Address><Phones><Phone><Type>0</Type><DDD>11</DDD><Number>345678977</Number></Phone></Phones></CollectionData><ShippingData><ID>14</ID><Type>1</Type><LegalDocument1>27836038882</LegalDocument1><Name>Daniel Konishi</Name><BirthDate>1990-10-10T00:00:00</BirthDate><Email>dkonishi@gmail.com</Email><Genre>m</Genre><Address><Street>Rua Carlos Del Prete</Street><Number>212</Number><Comp></Comp><County>Centro</County><City>São Bernardo do Campo</City><State>SP</State><ZipCode>09710-230</ZipCode></Address><Phones><Phone><Type>0</Type><DDD>11</DDD><Number>345678977</Number></Phone></Phones></ShippingData><Payments><Payment><Date>2012-09-13T13:54:53</Date><Amount>10.9</Amount><PaymentTypeID>1</PaymentTypeID><QtyInstallments>1</QtyInstallments><CardNumber>4000000000000002</CardNumber><CardBin>1234</CardBin><CardType>5</CardType><CardExpirationDate>02/13</CardExpirationDate><Name>McKay Thomas</Name><LegalDocument>27836038882</LegalDocument><Address><Street>Rua Carlos Del Prete</Street><Number>212</Number><Comp></Comp><County>Centro</County><City>São Bernardo do Campo</City><State>SP</State><ZipCode>09710-230</ZipCode></Address></Payment></Payments><Items><Item><ID>123</ID><Name>Produto 2</Name><ItemValue>1.0</ItemValue><Qty>1</Qty></Item></Items></Order></Orders></ClearSale></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><ClearSale><Orders><Order><ID>83F027</ID><Date>2012-09-13T13:54:53</Date><Email>dkonishi@gmail.com</Email><TotalItens>10.9</TotalItens><TotalOrder>10.9</TotalOrder><QtyInstallments>1</QtyInstallments><QtyItems>1</QtyItems><IP>127.0.0.1</IP><CollectionData><ID>14</ID><Type>1</Type><LegalDocument1>27836038882</LegalDocument1><Name>Daniel Konishi</Name><BirthDate>1990-10-10T00:00:00</BirthDate><Email>dkonishi@gmail.com</Email><Genre>m</Genre><Address><Street>Rua Carlos Del Prete</Street><Number>212</Number><Comp></Comp><County>Centro</County><City>São Bernardo do Campo</City><State>SP</State><ZipCode>09710-230</ZipCode></Address><Phones><Phone><Type>0</Type><DDD>11</DDD><Number>345678977</Number></Phone></Phones></CollectionData><ShippingData><ID>14</ID><Type>1</Type><LegalDocument1>27836038882</LegalDocument1><Name>Daniel Konishi</Name><BirthDate>1990-10-10T00:00:00</BirthDate><Email>dkonishi@gmail.com</Email><Genre>m</Genre><Address><Street>Rua Carlos Del Prete</Street><Number>212</Number><Comp></Comp><County>Centro</County><City>São Bernardo do Campo</City><State>SP</State><ZipCode>09710-230</ZipCode></Address><Phones><Phone><Type>0</Type><DDD>11</DDD><Number>345678977</Number></Phone></Phones></ShippingData><Payments><Payment><Date>2012-09-13T13:54:53</Date><Amount>10.9</Amount><PaymentTypeID>1</PaymentTypeID><QtyInstallments>1</QtyInstallments><CardNumber>[FILTERED]</CardNumber><CardBin>[FILTERED]</CardBin><CardType>5</CardType><CardExpirationDate>02/13</CardExpirationDate><Name>McKay Thomas</Name><LegalDocument>27836038882</LegalDocument><Address><Street>Rua Carlos Del Prete</Street><Number>212</Number><Comp></Comp><County>Centro</County><City>São Bernardo do Campo</City><State>SP</State><ZipCode>09710-230</ZipCode></Address></Payment></Payments><Items><Item><ID>123</ID><Name>Produto 2</Name><ItemValue>1.0</ItemValue><Qty>1</Qty></Item></Items></Order></Orders></ClearSale></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.
|
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-
|
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:
|
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:
|
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
|