Class: Packtory::Config
- Inherits:
-
Object
- Object
- Packtory::Config
- Defined in:
- lib/packtory/config.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{ :path => nil, :pkg_path => nil, :gemspec => nil, :gemfile => nil, :binstub => nil, :bin_path => nil, :install_prefix_as_code => nil, :setup_reset_gem_paths => true, :packages => nil, :architecture => 'all', # maybe specified, if wanting to override as set in gemspec file :package_name => nil, :working_path => nil, :dependencies => { }, :bundle_working_path => nil, :fpm_use_ruby_path => nil, :fpm_exec_path => nil, :fpm_exec_verbose => false, :fpm_exec_log => nil, :bundler_silent => false, :bundler_local => false, :bundler_include => false }
- DEFAULT_PACKAGES =
[ :deb ]
- PACKTORY_PACKFILE =
'Packfile'
Class Method Summary collapse
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
- .load_packfile ⇒ Object
- .load_patch ⇒ Object
- .reset_config! ⇒ Object
- .search_up(*names) ⇒ Object
- .setup ⇒ Object
- .setup_defaults ⇒ Object
Class Method Details
.config ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/packtory/config.rb', line 35 def self.config if defined?(@@global_config) @@global_config else reset_config! end end |
.configure {|config| ... } ⇒ Object
43 44 45 |
# File 'lib/packtory/config.rb', line 43 def self.configure yield config end |
.load_packfile ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/packtory/config.rb', line 90 def self.load_packfile packfile_path = nil if ENV.include?('PACKTORY_PACKFILE') packfile_path = File.(ENV['PACKTORY_PACKFILE']) else packfile_path = search_up(PACKTORY_PACKFILE) end unless packfile_path.nil? load packfile_path end packfile_path end |
.load_patch ⇒ Object
106 107 108 |
# File 'lib/packtory/config.rb', line 106 def self.load_patch PatchBundlerNoMetadataDeps.patch! end |
.reset_config! ⇒ Object
47 48 49 |
# File 'lib/packtory/config.rb', line 47 def self.reset_config! @@global_config = DEFAULT_CONFIG.merge({ }) end |
.search_up(*names) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/packtory/config.rb', line 67 def self.search_up(*names) previous = nil current = File.(config[:path] || Dir.pwd).untaint found_path = nil until !File.directory?(current) || current == previous || !found_path.nil? names.each do |name| path = File.join(current, name) if File.exists?(path) found_path = path break end end if found_path.nil? previous = current current = File.("..", current) end end found_path end |
.setup ⇒ Object
110 111 112 113 114 |
# File 'lib/packtory/config.rb', line 110 def self.setup load_patch load_packfile setup_defaults end |
.setup_defaults ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/packtory/config.rb', line 51 def self.setup_defaults if ENV.include?('PACKTORY_PACKAGES') && !ENV['PACKTORY_PACKAGES'].empty? config[:packages] = ENV['PACKTORY_PACKAGES'].split(',').collect { |p| p.to_sym } elsif config[:packages].nil? config[:packages] = DEFAULT_PACKAGES end if ENV.include?('PACKTORY_BUNDLE_WORKING_PATH') config[:bundle_working_path] = File.(ENV['PACKTORY_BUNDLE_WORKING_PATH']) end unless config[:dependencies].include?('ruby') config[:dependencies]['ruby'] = nil end end |