Class: Jarbs::FunctionDefinition
- Inherits:
-
Object
- Object
- Jarbs::FunctionDefinition
- Extended by:
- Forwardable
- Defined in:
- lib/jarbs/function_definition.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
- #basename(filename) ⇒ Object
- #build_path ⇒ Object
- #each_file(&block) ⇒ Object
- #env_name ⇒ Object
- #exists? ⇒ Boolean
- #files ⇒ Object
-
#initialize(name, env = 'dev') ⇒ FunctionDefinition
constructor
A new instance of FunctionDefinition.
- #manifest ⇒ Object
- #manifest_file ⇒ Object
- #remove! ⇒ Object
- #source_path ⇒ Object
Constructor Details
#initialize(name, env = 'dev') ⇒ FunctionDefinition
Returns a new instance of FunctionDefinition.
10 11 12 13 14 |
# File 'lib/jarbs/function_definition.rb', line 10 def initialize(name, env='dev') @env = env @name = name @root_path = File.join('lambdas', name) end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
7 8 9 |
# File 'lib/jarbs/function_definition.rb', line 7 def env @env end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/jarbs/function_definition.rb', line 7 def name @name end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
7 8 9 |
# File 'lib/jarbs/function_definition.rb', line 7 def root_path @root_path end |
Instance Method Details
#basename(filename) ⇒ Object
54 55 56 |
# File 'lib/jarbs/function_definition.rb', line 54 def basename(filename) filename.gsub(build_path + '/', '') end |
#build_path ⇒ Object
46 47 48 |
# File 'lib/jarbs/function_definition.rb', line 46 def build_path File.join(root_path, 'dest') end |
#each_file(&block) ⇒ Object
42 43 44 |
# File 'lib/jarbs/function_definition.rb', line 42 def each_file(&block) files.each {|file| yield basename(file), File.read(file) } end |
#env_name ⇒ Object
32 33 34 |
# File 'lib/jarbs/function_definition.rb', line 32 def env_name "#{env}-#{name}" end |
#exists? ⇒ Boolean
16 17 18 |
# File 'lib/jarbs/function_definition.rb', line 16 def exists? Dir.exists? root_path end |
#files ⇒ Object
36 37 38 39 40 |
# File 'lib/jarbs/function_definition.rb', line 36 def files path = File.join build_path, "**", "*" Dir.glob(path, File::FNM_DOTMATCH) .reject {|f| File.directory? f } end |
#manifest ⇒ Object
24 25 26 |
# File 'lib/jarbs/function_definition.rb', line 24 def manifest @manifest ||= OpenStruct.new JSON.parse(File.read(manifest_file)) end |
#manifest_file ⇒ Object
28 29 30 |
# File 'lib/jarbs/function_definition.rb', line 28 def manifest_file File.join(source_path, 'package.json') end |
#remove! ⇒ Object
20 21 22 |
# File 'lib/jarbs/function_definition.rb', line 20 def remove! FileUtils.rm_r root_path end |
#source_path ⇒ Object
50 51 52 |
# File 'lib/jarbs/function_definition.rb', line 50 def source_path File.join(root_path, 'src') end |