jcompiler 0.1.28 → 0.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jcompiler.rb +9 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d2c5ebcb50bf4f93d7b0dcf18382f377299f84c
4
- data.tar.gz: 4f6c155d5e4612c39f37706eb0a538e177fd6a1d
3
+ metadata.gz: 623d7c0474bc337b0a47c6f58f1b6a31e7a2658f
4
+ data.tar.gz: 43d5915fa5a961274c44a6e090d39f1ea89492a3
5
5
  SHA512:
6
- metadata.gz: 87e14ffb66503365bba9ebe0d89de2d034b89effe3a69bec531b891aabea382d2f18db4ab9e13beb9459711350f05c5336c331a34c2c6827312d64f2f78d8a6b
7
- data.tar.gz: 255ef8f1fcad38ee476a1b498cdfe17412791a2a85ff43756559d7a019c4cad0bb055cc93f95de2e3d44361217cbfa205438bcc062fc4e76015b3272f3f2bcb1
6
+ metadata.gz: 131dbc9353ee4938fa73114567bf0f61ac893b8a71a561b52882a157807a94d5d55734903a146198c4dd39c47d23491535aa6556dd35a27272492ce84c269512
7
+ data.tar.gz: 45a6827dc3032e45887ceed4a6c435e4397ebb27d784c45d5072348360dfcb61629eb8fe10604044e5caa60171018f6abd3172227166409c8b9ba58722c74474
data/lib/jcompiler.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  class Jcompiler
2
- def self.b(brand)
2
+ def self.b(brand, bind)
3
+ bind.local_variable_set(:brand, brand)
3
4
  {
4
5
  id: 'brand.id',
5
6
  name: 'brand.name',
@@ -12,19 +13,20 @@ class Jcompiler
12
13
  # url: brand_
13
14
  #labels: '"#{brand.new_arrival? ? \'["NEW"]\' : \'[]\'}"'
14
15
  }.map do |key, code|
15
- v = eval(code)
16
+ v = eval(code, bind)
16
17
  "\"#{key}\":#{v.is_a?(String) ? ActiveSupport::JSON.encode(v) : v ? v.to_s : 'null'}"
17
18
  end
18
19
  end
19
20
 
20
- def self.a(brands)
21
+ def self.a(brands, bind)
21
22
  brands.map do |brand|
22
- "{#{b(brand).join(',')}}"
23
+ "{#{b(brand, bind).join(',')}}"
23
24
  end
24
25
  end
25
26
 
26
- def self.code(brands)
27
- "[#{a(brands).join(',')}]"
27
+ def self.code(brands, bind)
28
+ bind.local_variable_set(:brands, brands)
29
+ "[#{a(brands, bind).join(',')}]"
28
30
  end
29
31
  end
30
32
 
@@ -33,7 +35,7 @@ class JcompilerHandler
33
35
  self.default_format = Mime::JSON
34
36
 
35
37
  def self.call(template)
36
- "Jcompiler.code(@brands)"
38
+ "Jcompiler.code(@brands, binding)"
37
39
  end
38
40
  end
39
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcompiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tetsuri Moriya