import_js 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/import-js +13 -3
- data/lib/import_js/command_line_editor.rb +9 -4
- data/lib/import_js/emacs_editor.rb +1 -2
- data/lib/import_js/importer.rb +1 -1
- 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: 53d73ab047c34814c2f19d3a1663e1d5c27982ef
|
4
|
+
data.tar.gz: 6c6950232e2ba053f22bf3aa044e544f0d531cad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ec581d957a679f3f917c56bbcf7aa25bceb15a9f952245691b038ec12d82f656bc1bc6c811078f87677270056ecfd6039efb4a8bd71543da6ab5f7bb3f58bb4
|
7
|
+
data.tar.gz: 08b20e7ca102e69de948d88cab3cbed2bb9d4e2e8662da0cd3fe91de79c02790d471c91676b6381e28b4fc0958f622c5d55d939683a04a2b0845f7b5dd016017
|
data/bin/import-js
CHANGED
@@ -6,7 +6,10 @@ require 'json'
|
|
6
6
|
|
7
7
|
opts = Slop.parse do |o|
|
8
8
|
o.string '-w', '--word', 'a word/variable to import'
|
9
|
+
o.bool '--goto', 'instead of importing, just print the path to a module'
|
9
10
|
o.array '--selections', 'a list of resolved selections, e.g. Foo:0,Bar:1'
|
11
|
+
o.string '--filename',
|
12
|
+
'a path to the file which contents are being passed in as stdin'
|
10
13
|
o.on '-v', '--version', 'print the current version' do
|
11
14
|
puts ImportJS::VERSION
|
12
15
|
exit
|
@@ -29,14 +32,21 @@ end
|
|
29
32
|
|
30
33
|
editor = ImportJS::CommandLineEditor.new(file_contents, opts)
|
31
34
|
importer = ImportJS::Importer.new(editor)
|
32
|
-
if opts
|
35
|
+
if opts.goto?
|
36
|
+
importer.goto
|
37
|
+
elsif opts[:word]
|
33
38
|
importer.import
|
34
39
|
else
|
35
40
|
importer.import_all
|
36
41
|
end
|
37
42
|
|
38
|
-
|
39
|
-
|
43
|
+
if opts.goto?
|
44
|
+
# Print the path to the module to go to
|
45
|
+
puts editor.goto
|
46
|
+
else
|
47
|
+
# Print resulting file to stdout
|
48
|
+
puts editor.current_file_content
|
49
|
+
end
|
40
50
|
|
41
51
|
# Print messages to stderr
|
42
52
|
meta = {
|
@@ -6,6 +6,7 @@ module ImportJS
|
|
6
6
|
@ask_for_selections = []
|
7
7
|
@selections = opts[:selections] unless opts[:selections].empty?
|
8
8
|
@word = opts[:word]
|
9
|
+
@filename = opts[:filename]
|
9
10
|
end
|
10
11
|
|
11
12
|
# @return [String]
|
@@ -15,13 +16,17 @@ module ImportJS
|
|
15
16
|
|
16
17
|
# @return [String?]
|
17
18
|
def path_to_current_file
|
18
|
-
|
19
|
-
nil
|
19
|
+
@filename
|
20
20
|
end
|
21
21
|
|
22
22
|
# @param file_path [String]
|
23
|
-
def open_file(
|
24
|
-
|
23
|
+
def open_file(file_path)
|
24
|
+
@goto = file_path
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [String]
|
28
|
+
def goto
|
29
|
+
@goto
|
25
30
|
end
|
26
31
|
|
27
32
|
# @param str [String]
|
data/lib/import_js/importer.rb
CHANGED
@@ -44,7 +44,7 @@ module ImportJS
|
|
44
44
|
@timing[:end] = Time.now
|
45
45
|
return if js_modules.empty?
|
46
46
|
js_module = resolve_one_js_module(js_modules, variable_name)
|
47
|
-
@editor.open_file(js_module.file_path)
|
47
|
+
@editor.open_file(js_module.file_path) if js_module
|
48
48
|
end
|
49
49
|
|
50
50
|
def fix_imports
|
data/lib/import_js/version.rb
CHANGED