Module: FunWith::Gems::RakeClassMethods
- Defined in:
- lib/fun_with/gems/rake_class_methods.rb
Instance Attribute Summary collapse
-
#gem ⇒ Object
Returns the value of attribute gem.
Instance Method Summary collapse
- #all_requirements ⇒ Object
- #gem_files(*args, &block) ⇒ Object
- #get_gem ⇒ Object
- #run_bundler_setup ⇒ Object
- #run_in_rakefile(&block) ⇒ Object
- #set_gem(g) ⇒ Object
- #set_rake_main(m) ⇒ Object
- #setup(this_gem, rake_main) ⇒ Object
- #setup_gem_boilerplate ⇒ Object
- #specification(&block) ⇒ Object
Instance Attribute Details
#gem ⇒ Object
Returns the value of attribute gem.
4 5 6 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 4 def gem @gem end |
Instance Method Details
#all_requirements ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 75 def all_requirements run_in_rakefile do require 'rake' require 'juwelier' require 'rdoc/task' require 'rake/testtask' require 'bundler' end end |
#gem_files(*args, &block) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 95 def gem_files( *args, &block ) Dir.glob( File.join( ".", "lib", "**", "*.rb" ) ) + Dir.glob( File.join( ".", "test", "**", "*.*" ) ) + [ "Gemfile", "Rakefile", "LICENSE.txt", "README.rdoc", "VERSION" ] end |
#get_gem ⇒ Object
20 21 22 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 20 def get_gem @gem end |
#run_bundler_setup ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 28 def run_bundler_setup all_requirements begin Bundler.setup(:default, :development) rescue Bundler::BundlerError => e $stderr.puts e. $stderr.puts "Run `bundle install` to install missing gems" exit e.status_code end end |
#run_in_rakefile(&block) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 85 def run_in_rakefile &block if @rake_main.nil? raise "Did you forget the line FunWith::Gems::Rakefile.set_rake_main by any chance?" elsif ! block_given? raise ArgumentError.new("Block must be given") else @rake_main.instance_eval( &block ) end end |
#set_gem(g) ⇒ Object
16 17 18 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 16 def set_gem g @gem = g end |
#set_rake_main(m) ⇒ Object
24 25 26 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 24 def set_rake_main m @rake_main = m end |
#setup(this_gem, rake_main) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 6 def setup this_gem, rake_main set_gem this_gem set_rake_main rake_main run_bundler_setup # Internal tasks are set up in the Rakefile. # External tasks (visible to the gems that depend on your fungem) are setup during the normal gem setup, if the 'rake' gem is present. get_gem.load_internal_tasks end |
#setup_gem_boilerplate ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 46 def setup_gem_boilerplate run_in_rakefile do Juwelier::RubygemsDotOrgTasks.new Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' test.pattern = 'test/**/test_*.rb' test.verbose = true end desc "Code coverage detail" task :simplecov do ENV['COVERAGE'] = "true" Rake::Task['test'].execute end task :default => :test Rake::RDocTask.new do |rdoc| version = File.exist?('VERSION') ? File.read('VERSION') : "" rdoc.rdoc_dir = 'rdoc' rdoc.title = "fun_with_gems #{version}" rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('lib/**/*.rb') end end end |
#specification(&block) ⇒ Object
40 41 42 43 44 |
# File 'lib/fun_with/gems/rake_class_methods.rb', line 40 def specification &block Juwelier::Tasks.new do |gem| yield gem end end |