Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) fix load order for gettext-setup tasks #183

Merged
merged 1 commit into from
Mar 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions lib/puppetlabs_spec_helper/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@

pattern = 'spec/{aliases,classes,defines,unit,functions,hosts,integration,type_aliases,types}/**/*_spec.rb'

begin
spec = Gem::Specification.find_by_name 'gettext-setup'
load "#{spec.gem_dir}/lib/tasks/gettext.rake"
locales_dir = File.absolute_path('locales', Dir.pwd )
# Initialization requires a valid locales directory
if File.exist? locales_dir
GettextSetup.initialize(locales_dir)
else
puts "No 'locales' directory found in #{ Dir.pwd }, skipping gettext initialization" if Rake.verbose == true
end
rescue Gem::LoadError
puts "No gettext-setup gem found, skipping gettext initialization" if Rake.verbose == true
end

desc "Run spec tests on an existing fixtures directory"
RSpec::Core::RakeTask.new(:spec_standalone) do |t|
Expand Down Expand Up @@ -593,3 +580,19 @@ def max_thread_limit
fail "rubocop is not available in this installation"
end
end

module_dir = Dir.pwd
locales_dir = File.absolute_path('locales', module_dir )
# if the task is allowed to run when the module does not have a locales directory,
# the task is run in the puppet gem instead and creates a POT there.
puts "gettext-setup tasks will only be loaded if the locales/ directory is present" if Rake.verbose == true
if File.exist? locales_dir
begin
spec = Gem::Specification.find_by_name 'gettext-setup'
load "#{spec.gem_dir}/lib/tasks/gettext.rake"
# Initialization requires a valid locales directory
GettextSetup.initialize(locales_dir)
rescue Gem::LoadError
puts "No gettext-setup gem found, skipping gettext initialization" if Rake.verbose == true
end
end