Module: Starter::Shared::BaseFile
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_file_path ⇒ Object
-
#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
7 8 9 |
# File 'lib/starter/shared/base_file.rb', line 7 def add_mount_point FileOps.call!(base_file_path) { |content| add_to_base(content) } end |
#add_to_base(file) ⇒ Object
adding mount point to base class
12 13 14 15 16 17 18 |
# File 'lib/starter/shared/base_file.rb', line 12 def add_to_base(file) occurence = file.scan(/(\s+mount\s.*?\n)/).map(&:first).join return if occurence.include?(@naming.mount_point.strip) replacement = occurence + @naming.mount_point file.sub!(occurence, replacement) end |
#base_file ⇒ Object
get api base file as string
43 44 45 |
# File 'lib/starter/shared/base_file.rb', line 43 def base_file FileOps.read_file(base_file_path) end |
#base_file_path ⇒ Object
47 48 49 |
# File 'lib/starter/shared/base_file.rb', line 47 def base_file_path File.join(Dir.getwd, 'api', 'base.rb') end |
#base_prefix ⇒ Object
parses out the prefix from base api file
31 32 33 |
# File 'lib/starter/shared/base_file.rb', line 31 def base_prefix Starter::Config.read[:prefix] end |
#base_version ⇒ Object
parses out the version from base api file
36 37 38 39 40 |
# File 'lib/starter/shared/base_file.rb', line 36 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
26 27 28 |
# File 'lib/starter/shared/base_file.rb', line 26 def remove_from_base(file) file.sub!(@naming.mount_point, '') end |