Module: Starter::BaseFile
- Included in:
- Builder
- Defined in:
- lib/starter/builder/base_file.rb
Instance Method Summary collapse
-
#add_mount_point ⇒ Object
add it in api base.
-
#add_to_base(file) ⇒ Object
adding mount point to base class.
-
#base_file ⇒ Object
get api base file as string.
-
#base_prefix ⇒ Object
parses out the prefix from base api file.
-
#base_version ⇒ Object
parses out the version from base api file.
-
#remove_from_base(file) ⇒ Object
removes mount point from base class.
-
#remove_mount_point ⇒ Object
removes in api base.
Instance Method Details
#add_mount_point ⇒ Object
add it in api base
6 7 8 |
# File 'lib/starter/builder/base_file.rb', line 6 def add_mount_point FileFoo.call!(api_base_file_name) { |content| add_to_base(content) } end |
#add_to_base(file) ⇒ Object
adding mount point to base class
11 12 13 14 15 |
# File 'lib/starter/builder/base_file.rb', line 11 def add_to_base(file) occurence = file.scan(/(\s+mount\s.*?\n)/).last.first replacement = occurence + mount_point file.sub!(occurence, replacement) end |
#base_file ⇒ Object
get api base file as string
40 41 42 43 |
# File 'lib/starter/builder/base_file.rb', line 40 def base_file file = File.join(Dir.getwd, 'api', 'base.rb') FileFoo.read_file(file) end |
#base_prefix ⇒ Object
parses out the prefix from base api file
28 29 30 |
# File 'lib/starter/builder/base_file.rb', line 28 def base_prefix Starter::Config.read[:prefix] end |
#base_version ⇒ Object
parses out the version from base api file
33 34 35 36 37 |
# File 'lib/starter/builder/base_file.rb', line 33 def base_version base_file base_file.scan(/version\s+(.+),/).first.first.delete!("'") end |
#remove_from_base(file) ⇒ Object
removes mount point from base class
23 24 25 |
# File 'lib/starter/builder/base_file.rb', line 23 def remove_from_base(file) file.sub!(mount_point, '') end |