Top Level Namespace

Defined Under Namespace

Modules: Hotdocs Classes: MarkdownHandler

Instance Method Summary collapse

Instance Method Details

#gem?(name) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/install/install.rb', line 5

def gem?(name)
  gemfile_path = Pathname(destination_root).join("Gemfile")

  regex = /gem ["']#{name}["']/
  if File.readlines(gemfile_path).grep(regex).any?
    say "#{name} already bundled"
    false
  else
    run("bundle add #{name}") || abort("Failed to add #{name} to the bundle")
    true
  end
end

#pin(name) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/install/install.rb', line 18

def pin(name)
  importmap_path = Pathname(destination_root).join("config/importmap.rb")

  regex = /pin ["']#{name}["']/
  if File.readlines(importmap_path).grep(regex).any?
    say "#{name} already pinned"
  else
    run("bin/importmap pin #{name}") || abort("Failed to pin #{name} to the importmap")
    gsub_file importmap_path, /(pin ["']#{name}["'])(.*)/, '\1, preload: "hotdocs"\2'
  end
end

#source_pathsObject

used by copy_file()



1
2
3
# File 'lib/install/install.rb', line 1

def source_paths # used by copy_file()
  [ File.expand_path("../..", __dir__) ]
end