Module: Brutal

Defined in:
lib/brutal.rb,
lib/brutal/file.rb,
lib/brutal/yaml.rb,
lib/brutal/scaffold.rb,
lib/brutal/file/read.rb,
lib/brutal/file/write.rb,
lib/brutal/configuration.rb

Overview

The Brutal namespace.

Defined Under Namespace

Modules: File, Yaml Classes: Configuration, Scaffold

Class Method Summary collapse

Class Method Details

.generate!(filename) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/brutal.rb', line 12

def self.generate!(filename)
  file = File::Read.new(filename).call

  hash = if Yaml.parse?(filename)
           Yaml.parse(file)
         else
           raise ::ArgumentError, "Unrecognized extension.  " \
                                  "Impossible to parse #{filename.inspect}."
         end

  conf = Configuration.load(hash)

  ruby = Scaffold.new(conf.header,
                      conf.subject,
                      *conf.actuals,
                      **conf.contexts)

  new_filename = File.generated_filename(filename)

  File::Write.new(new_filename).call(ruby)
end