import_js 0.1.0 → 0.1.1

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: b70c1d5fa29773c4f00513bb4826ec35b4e5cbae
4
- data.tar.gz: 235340096abac84c1e4b8d80cd15bb29522bb928
3
+ metadata.gz: 53d73ab047c34814c2f19d3a1663e1d5c27982ef
4
+ data.tar.gz: 6c6950232e2ba053f22bf3aa044e544f0d531cad
5
5
  SHA512:
6
- metadata.gz: 029f4a067d7e9e924842aa047f4308113ee8309a01871ad797585da2dd658f3a9b4093fbc3a82df3ab64e96a2746945ed3ac968f9149c0e8e1e20a20864d51ac
7
- data.tar.gz: 58f4f6b597977e7712a2755f5b7753144727228ddae6b92e01ade3380aa9887df2f688aed993fab7b77d11892deca84816e0f13cec03b4b3a8656f0e1e29dc83
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[:word]
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
- # Print resulting file to stdout
39
- puts editor.current_file_content
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
- # Not yet implemented.
19
- nil
19
+ @filename
20
20
  end
21
21
 
22
22
  # @param file_path [String]
23
- def open_file(_file_path)
24
- fail 'not supported'
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]
@@ -47,8 +47,7 @@ class ImportJS::EmacsEditor
47
47
  #
48
48
  # @return [String?]
49
49
  def path_to_current_file
50
- # Not yet implemented for Emacs
51
- nil
50
+ @path
52
51
  end
53
52
 
54
53
  # Display a message to the user.
@@ -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
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module ImportJS
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: import_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henric Trotzig