Class: DepsGrapher::Graphile::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/deps_grapher/graphile/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Generator

Returns a new instance of Generator.



6
7
8
# File 'lib/deps_grapher/graphile/generator.rb', line 6

def initialize(config)
  @config = config
end

Instance Method Details

#call(dest) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/deps_grapher/graphile/generator.rb', line 10

def call(dest)
  if dest
    File.write dest, read_template(temp: false)
    return dest
  end

  path = nil

  # unlink this temp file by GC
  Tempfile.open("graphile_generator", config.cache_dir) do |f|
    f.write read_template(temp: true)
    path = f.path
  end

  path
end