import_js 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/import_js/import_statement.rb +23 -3
- data/lib/import_js/importer.rb +1 -10
- data/lib/import_js/version.rb +1 -1
- 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: 8482eba183609eed41a5a8a9564c4d81f8047875
|
4
|
+
data.tar.gz: 4c4b4d506a28dcbeab5ee3f29b21be24afa67750
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73dd6ae7d9b26f4c03aa2cb37160bcb3eb48f1f7d27aa2642a830a7e83a5081290ea62bbda3865ea9ac99ab2561efcde9125182e53b699dfadd1592a827f4746
|
7
|
+
data.tar.gz: a991d45c0496e466fb36a13abfdfb006157e444a835b872b44373a5bda1a5a9fbecaecda4ebb754a78054358a3f7361677f293a1f3cf51f13c45fc0aee0cf752
|
@@ -71,7 +71,7 @@ module ImportJS
|
|
71
71
|
# @param value [String]
|
72
72
|
def set_default_variable(value)
|
73
73
|
@default_variable = value
|
74
|
-
|
74
|
+
clear_import_string_cache
|
75
75
|
end
|
76
76
|
|
77
77
|
# Injects a new variable into an already existing set of destructured
|
@@ -82,7 +82,7 @@ module ImportJS
|
|
82
82
|
destructured_variables << variable_name
|
83
83
|
destructured_variables.sort!.uniq!
|
84
84
|
|
85
|
-
|
85
|
+
clear_import_string_cache
|
86
86
|
end
|
87
87
|
|
88
88
|
# Deletes a variable from an already existing default variable or set of
|
@@ -92,7 +92,7 @@ module ImportJS
|
|
92
92
|
@default_variable = nil if default_variable == variable_name
|
93
93
|
@destructured_variables.delete(variable_name) unless destructured_variables.nil?
|
94
94
|
|
95
|
-
|
95
|
+
clear_import_string_cache
|
96
96
|
end
|
97
97
|
|
98
98
|
# @return [Boolean] true if there are destructured variables
|
@@ -156,6 +156,22 @@ module ImportJS
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
# Merge another ImportStatement into this one.
|
160
|
+
# @param import_statement [ImportJS::ImportStatement]
|
161
|
+
def merge(import_statement)
|
162
|
+
unless import_statement.default_variable.nil?
|
163
|
+
@default_variable = import_statement.default_variable
|
164
|
+
clear_import_string_cache
|
165
|
+
end
|
166
|
+
|
167
|
+
if import_statement.destructured?
|
168
|
+
@destructured_variables ||= []
|
169
|
+
@destructured_variables.concat(import_statement.destructured_variables)
|
170
|
+
@destructured_variables.sort!.uniq!
|
171
|
+
clear_import_string_cache
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
159
175
|
private
|
160
176
|
|
161
177
|
# @return [String]
|
@@ -176,5 +192,9 @@ module ImportJS
|
|
176
192
|
"#{declaration} #{value}"
|
177
193
|
end
|
178
194
|
end
|
195
|
+
|
196
|
+
def clear_import_string_cache
|
197
|
+
@original_import_string = nil
|
198
|
+
end
|
179
199
|
end
|
180
200
|
end
|
data/lib/import_js/importer.rb
CHANGED
@@ -212,16 +212,7 @@ module ImportJS
|
|
212
212
|
if imports[import_statement.path]
|
213
213
|
# Import already exists, so this line is likely one of a destructuring
|
214
214
|
# pair. Combine it into the same ImportStatement.
|
215
|
-
|
216
|
-
imports[import_statement.path].default_variable =
|
217
|
-
import_statement.default_variable
|
218
|
-
end
|
219
|
-
|
220
|
-
if import_statement.destructured?
|
221
|
-
imports[import_statement.path].destructured_variables ||= []
|
222
|
-
imports[import_statement.path].destructured_variables
|
223
|
-
.concat(import_statement.destructured_variables)
|
224
|
-
end
|
215
|
+
imports[import_statement.path].merge(import_statement)
|
225
216
|
else
|
226
217
|
# This is a new import, so we just add it to the hash.
|
227
218
|
imports[import_statement.path] = import_statement
|
data/lib/import_js/version.rb
CHANGED