Module: NewlineHw::ChromeManifest

Defined in:
lib/newline_hw/chrome_manifest.rb

Constant Summary collapse

NAME =
"com.theironyard.newlinecli.hw".freeze

Class Method Summary collapse

Class Method Details

.binary_pathObject



8
9
10
# File 'lib/newline_hw/chrome_manifest.rb', line 8

def binary_path
  File.expand_path File.join(NewlineHw.root_path, "exe", "newline_hw_stream_shim")
end

.generateObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/newline_hw/chrome_manifest.rb', line 16

def generate
  {
    name: NAME,
    description: "Quickly Clone and setup basic ruby and JS projects.",
    path: binary_path,
    type: "stdio",
    allowed_origins: [
      "chrome-extension://fnhanbdccpjnnoohoppkeejljjljihcc/",
      "chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/"
    ]
  }
end

.native_messaging_manifest_pathObject



12
13
14
# File 'lib/newline_hw/chrome_manifest.rb', line 12

def native_messaging_manifest_path
  File.expand_path("~/Library/Application Support/Google/Chrome/NativeMessagingHosts/#{NAME}.json")
end

.removeObject



37
38
39
40
# File 'lib/newline_hw/chrome_manifest.rb', line 37

def remove
  return unless File.file?(native_messaging_manifest_path)
  FileUtils.rm native_messaging_manifest_path
end

.writeObject



29
30
31
32
33
34
35
# File 'lib/newline_hw/chrome_manifest.rb', line 29

def write
  create_native_messaging_manifest_directory

  File.open(native_messaging_manifest_path, "w+") do |f|
    f.write(JSON.pretty_generate(generate))
  end
end