commission_junction 1.7.2 → 1.7.3

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: e00330e15a7b42cf61330c9aa59685979dbdfd50
4
- data.tar.gz: c56a45455189f9c159b871f70f9fdf22bdfcafb4
3
+ metadata.gz: 75905dfef02eddb83dc1441839a42ab720533b6b
4
+ data.tar.gz: b98a7d4ee12ea22cee9be46d9a3d027793978a90
5
5
  SHA512:
6
- metadata.gz: 41046a5ab67a67afe7efd89461180923740a47de1cf87ac2df6bc05b683be395da0f5a4382de0a4bf46f03c4d1ca39f6742ade2f964b901fa88d71dd46777c2a
7
- data.tar.gz: f5e6df6e63b1007d415288a19def29301729d26e2fb4f922417deb5eceac987e292455df8affda7d09747f752d71b790f133a51aaf70cc9521894b86ddb303ef
6
+ metadata.gz: c300121aac7c08c9f09209100f59bee34a6228cb7d1933779c5812033efe9c65d2f9ff259ad9285fce7b5cb9af12a17d6f7b2c7e2deceda239527e0c559c896b
7
+ data.tar.gz: 283bd1a79bb664846802e503c694453e698b821d6a35e73dff0680d2ec4f0f475614f91b2c2e7b6c8e900fdcdc2735a467a5bfdc38b6fbb49434d5d68ee09c91
@@ -1,3 +1,3 @@
1
1
  class CommissionJunction
2
- VERSION = '1.7.2'
2
+ VERSION = '1.7.3'
3
3
  end
@@ -178,10 +178,15 @@ class CommissionJunction
178
178
  # Credit: http://listlibrary.net/ruby-talk/2004/03/00sGI1cD
179
179
  params.each do |key, val|
180
180
  raise ArgumentError, "key must be a String; got #{key.class} instead" unless key.is_a?(String)
181
- instance_variable_set("@#{key}".intern, val)
182
- instance_eval %Q{ class << self ; attr_reader #{key.intern.inspect} ; end }
181
+ clean_key = clean_key_name(key)
182
+ instance_variable_set("@#{clean_key}".intern, val)
183
+ instance_eval %Q{ class << self ; attr_reader #{clean_key.intern.inspect} ; end }
183
184
  end
184
185
  end
186
+
187
+ def clean_key_name(name)
188
+ name.strip.gsub(/\s/, '_')
189
+ end
185
190
  end
186
191
 
187
192
  class Product < CjObject
@@ -389,11 +389,15 @@ class CommissionJunctionTest < Minitest::Test
389
389
  end
390
390
  end
391
391
 
392
+ def set_up_service
393
+ CommissionJunction.new('developer_key', 123456)
394
+ end
395
+
392
396
  def test_contents_extractor_with_first_level
393
397
  contents = "abc"
394
398
  response = {'cj_api' => {'first' => contents}}
395
399
 
396
- cj = CommissionJunction.new('developer_key', 123456)
400
+ cj = set_up_service
397
401
 
398
402
  assert_equal(contents, cj.extract_contents(response, "first"))
399
403
  end
@@ -402,7 +406,7 @@ class CommissionJunctionTest < Minitest::Test
402
406
  contents = "abc"
403
407
  response = {'cj_api' => {'first' => {'second' => contents}}}
404
408
 
405
- cj = CommissionJunction.new('developer_key', 123456)
409
+ cj = set_up_service
406
410
 
407
411
  assert_equal(contents, cj.extract_contents(response, "first", "second"))
408
412
  end
@@ -411,7 +415,7 @@ class CommissionJunctionTest < Minitest::Test
411
415
  contents = "abc"
412
416
  response = {'cj_api' => {'error_message' => contents}}
413
417
 
414
- cj = CommissionJunction.new('developer_key', 123456)
418
+ cj = set_up_service
415
419
 
416
420
  assert_raises ArgumentError do
417
421
  cj.extract_contents(response, "first")
@@ -421,10 +425,31 @@ class CommissionJunctionTest < Minitest::Test
421
425
  def test_contents_extractor_with_no_cj_api
422
426
  response = {}
423
427
 
424
- cj = CommissionJunction.new('developer_key', 123456)
428
+ cj = set_up_service
425
429
 
426
430
  assert_raises ArgumentError do
427
431
  cj.extract_contents(response, "first")
428
432
  end
429
433
  end
434
+
435
+ def set_up_cj_object
436
+ CommissionJunction::CjObject.new({"a" => "a"})
437
+ end
438
+
439
+ def test_key_conversion_with_spaces
440
+ cjo = set_up_cj_object
441
+
442
+ assert_equal("abc_def", cjo.clean_key_name("abc def"))
443
+ end
444
+
445
+ def test_key_conversion_with_trailing_spaces
446
+ cjo = set_up_cj_object
447
+
448
+ assert_equal("abcdef", cjo.clean_key_name("abcdef "))
449
+ end
450
+
451
+ def test_initializing_product_using_key_with_spaces
452
+ product = CommissionJunction::Product.new("abc def" => "123")
453
+ assert_equal(product.abc_def, "123")
454
+ end
430
455
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commission_junction
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Vernon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-10 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty