Module: FunWith::Gems::RakeClassMethods

Included in:
Rakefile
Defined in:
lib/fun_with/gems/rake_class_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gemObject

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

#get_gemObject



20
21
22
# File 'lib/fun_with/gems/rake_class_methods.rb', line 20

def get_gem
  @gem
end

#jeweler_requirementsObject



76
77
78
79
# File 'lib/fun_with/gems/rake_class_methods.rb', line 76

def jeweler_requirements
  require 'rake'
  require 'jeweler'
end

#rake_requirementsObject



81
82
83
84
# File 'lib/fun_with/gems/rake_class_methods.rb', line 81

def rake_requirements
  require 'rdoc/task'
  require 'rake/testtask'
end

#run_bundler_setupObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fun_with/gems/rake_class_methods.rb', line 28

def run_bundler_setup
  jeweler_requirements
  rake_requirements
  
  begin
    Bundler.setup(:default, :development)
  rescue Bundler::BundlerError => e
    $stderr.puts e.message
    $stderr.puts "Run `bundle install` to install missing gems"
    exit e.status_code
  end
end

#run_in_rakefile(&block) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/fun_with/gems/rake_class_methods.rb', line 86

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_boilerplateObject



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
74
# File 'lib/fun_with/gems/rake_class_methods.rb', line 47

def setup_gem_boilerplate
  run_in_rakefile do
    Jeweler::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



41
42
43
44
45
# File 'lib/fun_with/gems/rake_class_methods.rb', line 41

def specification &block
  Jeweler::Tasks.new do |gem|
    yield gem
  end
end