lib/shoes/package/configuration.rb in shoes-package-4.0.0.pre6 vs lib/shoes/package/configuration.rb in shoes-package-4.0.0.pre7

- old
+ new

@@ -14,21 +14,22 @@ # config = Shoes::Package::Configuration.load(config_file) # module Configuration extend ::Furoshiki::Util - JAR_APP_TEMPLATE_URL = 'https://s3.amazonaws.com/net.wasnotrice.shoes/wrappers/shoes-app-template-0.0.2.zip' + JAR_APP_TEMPLATE_URL = 'https://s3.amazonaws.com/net.wasnotrice.shoes/wrappers/shoes-app-template-0.0.2.zip'.freeze # Convenience method for loading config from a file. Note that you # can pass four kinds of paths to the loader. Given the following # file structure: # - # ├── a - # │   ├── app.yaml - # │   └── shoes-app-a.rb - # └── b - # └── shoes-app-b.rb + # |-- a + # | |-- app.yaml + # | |-- shoes-app-a.rb + # | + # |-- b + # |-- shoes-app-b.rb # # To package an app that has an `app.yaml`, like `shoes-app-a.rb`, # you can call the loader with any of: # # - a/app.yaml @@ -55,15 +56,18 @@ def self.load(path, base_config = {}) pathname = Pathname.new(path) app_yaml = Pathname.new('app.yaml') if pathname.basename == app_yaml - file, dir = pathname, pathname.dirname + file = pathname + dir = pathname.dirname elsif pathname.directory? - file, dir = pathname.join(app_yaml), pathname - elsif pathname.file? && pathname.parent.children.include?(pathname.parent.join app_yaml) - file, dir = pathname.parent.join(app_yaml), pathname.parent + file = pathname.join(app_yaml) + dir = pathname + elsif pathname.file? && pathname.parent.children.include?(pathname.parent.join(app_yaml)) + file = pathname.parent.join(app_yaml) + dir = pathname.parent else file, dir = config_for_single_file_app(pathname) end config = YAML.load(file.read) @@ -80,18 +84,18 @@ release: 'Rookie', run: nil, ignore: 'pkg', # TODO: Add actual paths. Keep these keys for compatibility with Shoes 3 icons: { - #osx: 'path/to/default/App.icns', - #gtk: 'path/to/default/app.png', - #win32: 'path/to/default/App.ico', + # osx: 'path/to/default/App.icns', + # gtk: 'path/to/default/app.png', + # win32: 'path/to/default/App.ico', }, # TODO: Add actual paths. Keep these keys for compatibility with Shoes 3 dmg: { - #ds_store: 'path/to/default/.DS_Store', - #background: 'path/to/default/background.png' + # ds_store: 'path/to/default/.DS_Store', + # background: 'path/to/default/background.png' }, working_dir: Dir.pwd, gems: ['shoes-core'], validator: Validator, warbler_extensions: WarblerExtensions @@ -100,12 +104,10 @@ symbolized_config = deep_symbolize_keys(config) symbolized_config[:gems] = merge_gems(defaults, symbolized_config) Furoshiki::Configuration.new defaults.merge(symbolized_config) end - private - # If it exists, load default options. If not, let the filesystem raise an # error. def self.config_for_single_file_app(pathname) default_options = { run: pathname.basename.to_s, @@ -118,11 +120,19 @@ # We want to retain all of the gems, but simply merging the hash will # replace the whole array, so we handle the gems separately. Note that # keys may not have been symbolized yet def self.merge_gems(base, additional) - base_gems = base.fetch(:gems) rescue base['gems'] - additional_gems = additional.fetch(:gems) rescue additional['gems'] + base_gems = begin + base.fetch(:gems) + rescue + base['gems'] + end + additional_gems = begin + additional.fetch(:gems) + rescue + additional['gems'] + end Array(base_gems).concat(Array(additional_gems)).uniq end end class Validator < Furoshiki::Validator