jcompiler 0.1.28 → 0.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jcompiler.rb +9 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 623d7c0474bc337b0a47c6f58f1b6a31e7a2658f
|
4
|
+
data.tar.gz: 43d5915fa5a961274c44a6e090d39f1ea89492a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|