Module: ImageCompressorPack

Defined in:
lib/image_compressor_pack.rb,
lib/image_compressor_pack/recipes.rb,
lib/image_compressor_pack/version.rb

Constant Summary collapse

VERSION =
"1.0.0.0"

Class Method Summary collapse

Class Method Details

.activateObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/image_compressor_pack.rb', line 11

def self.activate
  paths.each do |path|
    path.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR

    old_value = ENV['PATH'] || ''

    unless old_value.include?(path)
      ENV['PATH'] = "#{path}#{File::PATH_SEPARATOR}#{old_value}"
    end
  end
end

.dynamically_linked_recipesObject



18
19
20
# File 'lib/image_compressor_pack/recipes.rb', line 18

def self.dynamically_linked_recipes
  parse_recipes File.expand_path('../dynamically_linked_recipes.yml', __FILE__)
end

.parse_recipes(file) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/image_compressor_pack/recipes.rb', line 22

def self.parse_recipes(file)
  recipes = YAML.load_file(file)

  recipes.map do |name, parameters|
    MiniPortile.new(name, parameters['version']).tap do |recipe|
      recipe.files = parameters['files']
      recipe.target = if parameters['target'].nil?
                        File.expand_path('../../../ports', __FILE__)
                      else
                        parameters['target']
                      end
      unless parameters['patch_files'].nil?
        recipe.patch_files = parameters['patch_files'].map do |patch|
          File.expand_path("../../../ports/patches/#{name}/#{patch}", __FILE__)
        end
      end
      recipe.configure_options = parameters['configure_options'] unless parameters['configure_options'].nil?
    end
  end
end

.pathsObject



5
6
7
8
9
# File 'lib/image_compressor_pack.rb', line 5

def self.paths
  root = File.expand_path("../../", __FILE__)
  relative_paths = YAML.load_file File.expand_path('../.paths.yml', __FILE__)
  relative_paths.map { |path| File.join root, path }
end

.recipesObject



6
7
8
9
10
11
12
# File 'lib/image_compressor_pack/recipes.rb', line 6

def self.recipes
  unless RbConfig::CONFIG['target_os'] =~ /darwin/
    statically_linked_recipes
  else
    dynamically_linked_recipes
  end
end

.statically_linked_recipesObject



14
15
16
# File 'lib/image_compressor_pack/recipes.rb', line 14

def self.statically_linked_recipes
  parse_recipes File.expand_path('../statically_linked_recipes.yml', __FILE__)
end