Class: Lam::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/lam/build.rb,
lib/lam/build/lambda_deducer.rb,
lib/lam/build/traveling_ruby.rb,
lib/lam/build/handler_generator.rb

Defined Under Namespace

Classes: HandlerGenerator, LambdaDeducer, TravelingRuby

Constant Summary collapse

TRAVELING_RUBY_VERSION =
'http://d6r77u77i8pq3.cloudfront.net/releases/traveling-ruby-20150715-2.2.2-linux-x86_64.tar.gz'.freeze
TEMP_BUILD_DIR =
'/tmp/lam_build'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Build

Returns a new instance of Build.



8
9
10
# File 'lib/lam/build.rb', line 8

def initialize(options)
  @options = options
end

Instance Method Details

#buildObject



17
18
19
20
21
22
23
# File 'lib/lam/build.rb', line 17

def build
  handlers.each do |handler|
    HandlerGenerator.new(handler).generate
  end

  TravelingRuby.new.build unless @options[:noop]
end

#handlersObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lam/build.rb', line 25

def handlers
  handlers = []
  expression = "#{Lam.root}app/controllers/**/*.rb"
  Dir.glob(expression).each do |path|
    next unless File.file?(path)
    next if path.include?("application_controller.rb")

    path = relative_path(path)
    handlers += LambdaDeducer.new(path).deduce.handlers
  end
  # pp handlers
  handlers
end

#relative_path(path) ⇒ Object

Rids of the Lam.root at beginning



40
41
42
# File 'lib/lam/build.rb', line 40

def relative_path(path)
  path.sub(Lam.root, '')
end

#runObject



12
13
14
15
# File 'lib/lam/build.rb', line 12

def run
  puts "Building project for Lambda..."
  build
end