Module: Starter::Shared::BaseFile

Included in:
Build, Import
Defined in:
lib/starter/shared/base_file.rb

Instance Method Summary collapse

Instance Method Details

#add_mount_pointObject

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_fileObject

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_pathObject



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_prefixObject

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_versionObject

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

#remove_mount_pointObject

removes in api base



21
22
23
# File 'lib/starter/shared/base_file.rb', line 21

def remove_mount_point
  FileOps.call!(base_file_path) { |content| remove_from_base(content) }
end