newline_hw 1.0.2 → 1.1.0

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: 676110b691c8a3e7aee1989c785a528a4fe695d7
4
- data.tar.gz: e3a9e914796b340c4c382952d52308c1c5a33c9f
3
+ metadata.gz: 47e9a294c46a166978832a4c69eb2799929c3269
4
+ data.tar.gz: 0d8a73542cba16a4c3d87b82d3affa95d272eec0
5
5
  SHA512:
6
- metadata.gz: 3e493ec70edfdce1b89b63a4fc86282cae08c1a7c0b52bd3a72a00017a6b3918dba46d2ecfdf346cdca1fd7915ae6a1bc91d3818162abfd43344c7ac87bae11c
7
- data.tar.gz: d42e8f9824fe1c165607bfe9658328859d480fd3b0b777ff81303f35dd5685d84bc9e75fbfd1da5bdeebf339dc34c87da1a9f8888f6c8bc94641f58c34e0a136
6
+ metadata.gz: 622cdabdaaea06f40f03461dbcca2842d4bb4f234b0e512ac4eed1a53943f4aceeea8bc9a7c69cadaff4c0956528dcee05ea41b49b0cb23d3119e9fbb6b8c9c8
7
+ data.tar.gz: cd7a505d02f64a3e17f5d111fc4ec53fa8d8d79286f2575644e3716d21dcd3c0a4b90569aeacc55c4db5eb0dca3b2570dffafdab48f32c1369e0b998a696c913
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
3
  begin
4
- require 'rspec/core/rake_task'
4
+ require "rspec/core/rake_task"
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- task :default => :spec
7
+ task default: :spec
8
8
  rescue LoadError
9
9
  end
@@ -8,9 +8,12 @@ logger = Logger.new(File.new(File.expand_path(NewlineHw.config.log_file), "a+"))
8
8
 
9
9
  begin
10
10
  NewlineHw::StreamProcessor
11
- .new($stdin, $stdout, logger: logger).on_message do |msg|
12
- send_message(NewlineHw::StreamCommandHandler.new(msg).call)
13
- end
11
+ .new($stdin, $stdout, logger: logger)
12
+ .on_message do |msg|
13
+ Thread.new do
14
+ send_message(NewlineHw::StreamCommandHandler.new(msg).call)
15
+ end
16
+ end
14
17
  rescue StandardError => e
15
18
  logger.error e
16
19
  exit 1
@@ -28,9 +28,9 @@ module NewlineHw
28
28
 
29
29
  def write
30
30
  create_native_messaging_manifest_directory
31
-
31
+
32
32
  File.open(native_messaging_manifest_path, "w+") do |f|
33
- f.write(JSON.pretty_generate(ChromeManifest.generate))
33
+ f.write(JSON.pretty_generate(generate))
34
34
  end
35
35
  end
36
36
 
@@ -12,21 +12,29 @@ module NewlineHw
12
12
  end
13
13
 
14
14
  desc "install newlinehw config file and chrome adapter",
15
- "will setup a logging file and a chrome manifest to allow this app to be communicated to by the newline-assistant chrome extension."
15
+ "will setup a logging file and a chrome manifest to allow this app to be communicated to by the newline-assistant chrome extension."
16
16
  def install
17
17
  NewlineHw.make_log_directory
18
18
  ChromeManifest.write
19
19
  NewlineHw::Config.install_default
20
20
  say "Installed a config file to `#{NewlineHw::Config::CONFIG_PATH}`"
21
- say "Chrome Native Messaging Hook installed for Newline Assistant"
21
+ install_chrome
22
22
  say ""
23
23
  say ("*" * 30) + " YOU MUST!! Add this line to your shell profile " + ("*" * 30), :red
24
24
  say '$ eval "$(newline_hw init)"'
25
25
  say ("*" * 30), :red
26
26
  end
27
27
 
28
+ desc "install chrome adapter",
29
+ "will setup a logging file and a chrome manifest to allow this app to be communicated to by the newline-assistant chrome extension."
30
+ def install_chrome
31
+ NewlineHw.make_log_directory
32
+ ChromeManifest.write
33
+ say "Chrome Native Messaging Hook installed for Newline Assistant", :green
34
+ end
35
+
28
36
  desc "setup SUBMISSION_ID",
29
- "generate a shell command to clone and setup a given SUBMISSION_ID"
37
+ "generate a shell command to clone and setup a given SUBMISSION_ID"
30
38
  option :editor
31
39
  def setup_command(submission_id)
32
40
  puts Shell::Setup.new(submission_id, config).cmd
@@ -19,10 +19,10 @@ module NewlineHw
19
19
 
20
20
  def call
21
21
  applescript = case application
22
- when "iTerm2"
23
- applescript_for_iterm
24
- else
25
- applescript_for_terminal
22
+ when "iTerm2"
23
+ applescript_for_iterm
24
+ else
25
+ applescript_for_terminal
26
26
  end
27
27
 
28
28
  { terminal_output: `osascript -e '#{applescript}'` }
@@ -40,7 +40,7 @@ module NewlineHw
40
40
  end
41
41
 
42
42
  private def applescript_for_iterm
43
- <<-APPLESCRIPT
43
+ <<-APPLESCRIPT
44
44
  tell application \"#{application}\"
45
45
  set newWindow to (create window with default profile)
46
46
 
@@ -1,21 +1,12 @@
1
- # if [[ $# -eq 0 ]] ; then
2
- # echo 'WARNING: You must provide a git url, pull-request url or a Newline Submission ID.'
3
- # exit 0
4
- # fi
5
- # OUTPUT="$(#{path} run_command $PWD $*)"
6
- # eval $OUTPUT
7
-
8
1
  module NewlineHw
9
2
  module Shell
10
3
  ##
11
4
  # Produce a bash / zsh function to be called by a tty compatible shell
12
- #
13
- # WARNING: all bash lines below must be terminated in a semicolon, line
14
- # endings do not survive being passed through the heredoc correctly for the
15
- # shell to interpreter correctly.
16
5
  module Function
17
6
  HW_FUNCTION = "hw".freeze
7
+
18
8
  module_function
9
+
19
10
  def path
20
11
  File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "exe", "newline_hw"))
21
12
  end
@@ -40,7 +40,7 @@ module NewlineHw
40
40
  end
41
41
 
42
42
  def github_project_link?
43
- url.starts_with?("https://github.com") && URI(url).path.split("/").reject{|l| l.empty?}.size == 2
43
+ url.starts_with?("https://github.com") && URI(url).path.split("/").reject(&:empty?).size == 2
44
44
  end
45
45
 
46
46
  def git?
@@ -37,18 +37,20 @@ module NewlineHw
37
37
  version: NewlineHw::VERSION,
38
38
  newline_cli_version: NewlineCli::VERSION,
39
39
  ruby_version: RUBY_VERSION,
40
- config_path: Config::CONFIG_PATH
40
+ config_path: Config::CONFIG_PATH,
41
+ path: NewlineHw.root_path
41
42
  }
42
43
  }
43
44
  end
44
45
 
45
46
  def check_if_cloneable
47
+ setup = Shell::Setup.new(data["id"], Config.new)
46
48
  {
47
49
  status: :ok,
48
50
  message_at: message_at,
49
51
  data: {
50
- cloneable:
51
- Shell::Setup.new(data["id"], Config.new).cloneable?
52
+ cloneable: setup.cloneable?,
53
+ submission_info: setup.submission_info
52
54
  }
53
55
  }
54
56
  end
@@ -1,3 +1,3 @@
1
1
  module NewlineHw
2
- VERSION = "1.0.2".freeze
2
+ VERSION = "1.1.0".freeze
3
3
  end
data/lib/newline_hw.rb CHANGED
@@ -19,6 +19,10 @@ module NewlineHw
19
19
  Config.new
20
20
  end
21
21
 
22
+ def root_path
23
+ File.expand_path("../..", __FILE__)
24
+ end
25
+
22
26
  def logfile
23
27
  File.expand_path config.log_file
24
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newline_hw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Osborne