class Propro::Source
Constants
- COMMENT_BEGIN
- EXPORT_BEGIN
- FUNC_PROVISION_BEGIN
- FUNC_PROVISION_NAME_RANGE
- IS_LIBRARY_BEGIN
Attributes
name[R]
provisioner[R]
Public Class Methods
new(name)
click to toggle source
# File lib/propro/source.rb, line 11 def initialize(name) @name = name.to_s @exports = [] @can_provision = false @is_library = name.start_with?(IS_LIBRARY_BEGIN) @src = '' load end
Public Instance Methods
can_provision?()
click to toggle source
# File lib/propro/source.rb, line 34 def can_provision? @can_provision end
exports()
click to toggle source
# File lib/propro/source.rb, line 48 def exports @exports.sort { |a, b| case when b.is_required? then 1 when b.is_specified? then 0 else -1 end } end
file_name()
click to toggle source
# File lib/propro/source.rb, line 20 def file_name "#{@name}.sh" end
file_path()
click to toggle source
# File lib/propro/source.rb, line 24 def file_path File.join(Propro::Package.root, file_name) end
is_library?()
click to toggle source
# File lib/propro/source.rb, line 38 def is_library? @is_library end
load()
click to toggle source
# File lib/propro/source.rb, line 28 def load File.open(file_path) do |file| file.each_line { |line| load_line(line) } end end
specified_exports()
click to toggle source
# File lib/propro/source.rb, line 42 def specified_exports @specified_exports ||= begin exports.select { |e| e.is_required? || e.is_specified? } end end
to_bash()
click to toggle source
# File lib/propro/source.rb, line 58 def to_bash <<-SH # Propro package: #{file_name} #{@src} SH end
Protected Instance Methods
load_line(line)
click to toggle source
# File lib/propro/source.rb, line 67 def load_line(line) case when line.start_with?(EXPORT_BEGIN) # collect exported variables from bash modules @exports << Export.parse(line) @src << line.sub(EXPORT_BEGIN, '') when line.start_with?(FUNC_PROVISION_BEGIN) @can_provision = true path = line.match(FUNC_PROVISION_NAME_RANGE)[1] @provisioner = path.gsub('-', '/') @src << line else # pass-through @src << line end end