Skip to content

Commit

Permalink
Merge pull request #1 from Yleisradio/fix_bundler
Browse files Browse the repository at this point in the history
Fix Bundler plugin loading errors
  • Loading branch information
tmatilai authored Aug 31, 2017
2 parents 6fc8fc3 + 9deb634 commit bea94fd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Metrics/BlockLength:
Exclude:
- '*.gemspec'
- 'spec/**/*'

Metrics/ClassLength:
Expand Down
2 changes: 1 addition & 1 deletion bin/tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby

require 'bundler/setup' if File.exist? File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(File.expand_path('../../Gemfile', __FILE__))
require 'yle_tf/cli'

cli = YleTf::CLI.new(ARGV)
Expand Down
12 changes: 8 additions & 4 deletions lib/yle_tf/plugin/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def self.load_core_plugins
end

def self.load_bundler_plugins
if defined?(Bundler)
print_bundler_plugin_list if Logger.debug?
Bundler.require(BUNDLER_PLUGIN_GROUP)
end
return if !bundler_set_up?

Logger.debug { print_bundler_plugin_list }
Bundler.require(BUNDLER_PLUGIN_GROUP)
end

def self.load_user_plugins
Expand All @@ -47,6 +47,10 @@ def self.user_plugins
ENV.fetch('TF_PLUGINS', '').split(/[ ,]+/)
end

def self.bundler_set_up?
defined?(Bundler) && Bundler.respond_to?(:require)
end

def self.print_bundler_plugin_list
plugins = bundler_plugins
if !plugins.empty?
Expand Down
6 changes: 3 additions & 3 deletions yle_tf.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Gem::Specification.new do |spec|
'[email protected]',
]

spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.files = Dir['bin/**/*'] +
Dir['lib/**/*.rb'] +
Dir['vendor/**/*']

spec.bindir = 'bin'
spec.executables = ['tf']
Expand Down

0 comments on commit bea94fd

Please sign in to comment.