Module: Sourcery

Defined in:
lib/sourcery.rb,
lib/sourcery/cli.rb,
lib/sourcery/caster.rb,
lib/sourcery/context.rb,
lib/sourcery/metadata.rb

Defined Under Namespace

Classes: Caster, Context, Metadata

Class Method Summary collapse

Class Method Details

.cli(*argv) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sourcery/cli.rb', line 7

def self.cli(*argv)
  options = {}

  usage = OptionParser.new do |use|
    use.banner = 'Usage: sourcery [OPTIONS] [FILE1 FILE2 ...]'

    #use.on('--delete', 'delete templates when finished') do
    #  options[:delete] = true
    #end

    use.on('-a', '--ask', 'prompt user before overwrites') do
      options[:ask] = true
    end

    use.on('-s', '--skip', 'automatically skip overwrites') do
      options[:skip] = true
    end

    use.on('-o', '--stdout', 'dump output to stdout instead of saving') do
      options[:stdout] = true
    end

    use.on('-t', '--trial', 'run in trial mode (no actual disk write)') do
      $TRIAL = true
    end

    use.on('--debug', 'run in debug mode') do
      $DEBUG = true
    end

    use.on_tail('-h', '--help', 'display this help information') do
      puts use
      exit
    end

    #use['<DIR>',       'directory to till; default is working directory']
  end

  usage.parse!(argv)

  if !argv.empty?
    options[:files] = argv
  end

  caster = Caster.new(options)

  caster.call
end

.const_missing(name) ⇒ Object



10
11
12
# File 'lib/sourcery.rb', line 10

def self.const_missing(name)
  [name.to_s.downcase] || super(name)
end

.metadataObject



3
4
5
6
7
8
# File 'lib/sourcery.rb', line 3

def self.
  @metadata ||= (
    require 'yaml'
    YAML.load_file(File.dirname(__FILE__) + '/sourcery.yml')
  )
end