Module: Starter::BaseFile

Included in:
Builder
Defined in:
lib/starter/builder/base_file.rb

Instance Method Summary collapse

Instance Method Details

#add_mount_pointObject

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_fileObject

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_prefixObject

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_versionObject

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

#remove_mount_pointObject

removes in api base



18
19
20
# File 'lib/starter/builder/base_file.rb', line 18

def remove_mount_point
  FileFoo.call!(api_base_file_name) { |content| remove_from_base(content) }
end