lib/openstudio/extension/runner.rb in openstudio-extension-0.7.1 vs lib/openstudio/extension/runner.rb in openstudio-extension-0.8.0

- old
+ new

@@ -39,17 +39,18 @@ # had the idea of passing in a Gemfile name/alias and path to Gemfile, then doing the bundle # in ~/OpenStudio/#{alias} or something like that? # if the dirname contains a runner.conf file, then use the config file to specify the parameters - @options = OpenStudio::Extension::RunnerConfig.default_config + @options = OpenStudio::Extension::RunnerConfig.default_config(dirname) # ORDER of PRECEDENCE: default config < runner.conf file < options passed in directly if File.exist?(File.join(dirname, OpenStudio::Extension::RunnerConfig::FILENAME)) puts 'Using runner options from runner.conf file' runner_config = OpenStudio::Extension::RunnerConfig.new(dirname) - # use the default values overriden with runner.conf values - @options = @options.merge(runner_config.options) + # use the default values overriden with runner.conf values where not + # nil nor empty strings + @options = @options.merge(runner_config.options.reject{|k, v| v.nil? || (v.kind_of?(String) && v === '')}) end if !options.empty? puts 'Merging in passed-in options' # use the passed values or defaults overriden by passed options @@ -97,16 +98,16 @@ # TODO: check that ruby version is correct # check existing config needs_config = true - if File.exist?('./.bundle/config') # checking wrt gemfile_dir - puts 'config exists' + if conf_bpath = Bundler.configured_bundle_path.explicit_path + puts 'bundler config exists' needs_config = false - config = YAML.load_file('./.bundle/config') - if config['BUNDLE_PATH'] != @bundle_install_path + if conf_bpath != @bundle_install_path + raise "Detected mistmatch between bundle's configured path #{conf_bpath} and runner configuration #{@bundle_install_path}" needs_config = true end # if config['BUNDLE_WITHOUT'] != @bundle_without_string # needs_config = true @@ -538,15 +539,18 @@ paths = [ { glob: "#{root_dir}/**/*.rb", license: ruby_header_text, regex: ruby_regex }, { glob: "#{root_dir}/**/*.html.erb", license: erb_header_text, regex: erb_regex }, { glob: "#{root_dir}/**/*.js.erb", license: js_header_text, regex: js_regex } ] + # This is the bundle deployment folder + excluded_subfolders = ['vendor'].map{|d| "#{root_dir}/vendor/bundle"} + puts "Encoding.default_external = #{Encoding.default_external}" puts "Encoding.default_internal = #{Encoding.default_internal}" paths.each do |path| - Dir[path[:glob]].each do |dir_file| + Dir[path[:glob]].reject{|f| excluded_subfolders.any?{|d| f[d]} }.each do |dir_file| puts "Updating license in file #{dir_file}" f = File.read(dir_file) if f.match?(path[:regex]) puts ' License found -- updating' File.open(dir_file, 'w') { |write| write << f.gsub(path[:regex], path[:license]) }