Class: Tck::Lambdas::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/tck/lambdas/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
# File 'lib/tck/lambdas/cli.rb', line 10

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#listObject



15
16
17
18
19
20
21
22
23
# File 'lib/tck/lambdas/cli.rb', line 15

def list
  if yaml = Tck::Lambdas::AwsFunction.yaml
    yaml.each do |lambda_name, properties|
      puts " - #{properties["function-name"]} (cloned from '#{lambda_name}')"
    end
  else
    puts "No lambdas found in this directory... :("
  end
end

#use(name) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tck/lambdas/cli.rb', line 26

def use(name)
  puts "#{CLI.source_root}/#{name}"
  if File.directory?("#{CLI.source_root}/#{name}")
    @lambda = Tck::Lambdas::AwsFunction.new(name)

    copy_file "Rakefile"
    copy_file "Gemfile.example"
    template "templates/lambdas.yml.erb", ".lambdas.yml"
    template "templates/lambdas.rake.erb", "lib/tasks/lambdas.rake"
    copy_file "test.rb", "lambdas/test.rb"
    directory name, "lambdas/#{name}"
  else
    raise "Sorry, '#{name}' is not a valid lambda name."
  end
end