Class: Bashly::Library

Inherits:
Object
  • Object
show all
Defined in:
lib/bashly/library.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, config, upgrade_string: nil) ⇒ Library

Returns a new instance of Library.



6
7
8
9
10
# File 'lib/bashly/library.rb', line 6

def initialize(path, config, upgrade_string: nil)
  @path = path.to_s
  @config = config
  @upgrade_string = upgrade_string
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



4
5
6
# File 'lib/bashly/library.rb', line 4

def args
  @args
end

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/bashly/library.rb', line 3

def config
  @config
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/bashly/library.rb', line 3

def path
  @path
end

#upgrade_stringObject (readonly)

Returns the value of attribute upgrade_string.



3
4
5
# File 'lib/bashly/library.rb', line 3

def upgrade_string
  @upgrade_string
end

Instance Method Details

#filesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bashly/library.rb', line 12

def files
  if custom_handler
    custom_handler.files

  else
    config['files'].map do |file|
      {
        path:    file['target'] % target_file_args,
        content: file_contents("#{path}/#{file['source']}"),
      }
    end
  end
end

#find_file(path) ⇒ Object



34
35
36
# File 'lib/bashly/library.rb', line 34

def find_file(path)
  files.find { |f| f[:path] == path }
end

#post_install_messageObject



26
27
28
29
30
31
32
# File 'lib/bashly/library.rb', line 26

def post_install_message
  if custom_handler
    custom_handler.post_install_message
  else
    config['post_install_message']
  end
end