Module: FunWith::Gems::Rakefile

Defined in:
lib/fun_with/gems/rakefile.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/rakefile.rb', line 4

def gem
  @gem
end

Instance Method Details

#add_specification_files(gem_specification, *args) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fun_with/gems/rakefile.rb', line 87

def add_specification_files( gem_specification, *args )
  root = "".fwf_filepath
  
  for arg in args
    case arg
    when :default
      files = []
      files += root.join( :bin ).glob
      files += root.join( :config ).glob
      files += root.join( :examples ).glob
      files += [ "Gemfile", "Rakefile", "VERSION" ]
      files += root.join( :lib ).glob( :all, :ext => :rb )
      files += root.join( :lib ).glob( :all, :ext => :rake )
      files += root.join( :test ).glob
      files += root.entries.select{|p| p.path =~ /^LICENSE\./ }
      files += root.entries.select{|p| p.path =~ /^CHANGELOG\./ }
      files += root.entries.select{|p| p.path =~ /^README\./ }
      files += root.entries.select{|p| p.path =~ /^CODE_OF_CONDUCT\./ }
      
      gem_specification.files += files.flatten.compact
    else
      gem_specification.files += root.glob( arg )
    end
  end
end

#all_requirementsObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fun_with/gems/rakefile.rb', line 69

def all_requirements
  # run_in_rakefile do
    require 'rake'
    require 'juwelier'
    
    begin
      require 'rdoc/task'
    rescue ArgumentError
      # warn( "what's up with this error when loading RDoc?" )
      require 'rdoc'
      require 'rdoc/task'
    end
    
    require 'rake/testtask'
    require 'bundler'
end

#gem_specification(&block) ⇒ Object



33
34
35
36
37
# File 'lib/fun_with/gems/rakefile.rb', line 33

def gem_specification &block
  Juwelier::Tasks.new do |gem|
    yield gem
  end
end

#rakefile_setup(this_gem) ⇒ Object

, rake_main



6
7
8
9
10
11
12
13
14
15
# File 'lib/fun_with/gems/rakefile.rb', line 6

def rakefile_setup this_gem   # , rake_main
  self.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.
  self.gem.load_internal_tasks     
end

#run_bundler_setupObject

def set_rake_main m @rake_main = m end



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fun_with/gems/rakefile.rb', line 21

def run_bundler_setup
  all_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

#setup_gem_boilerplateObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fun_with/gems/rakefile.rb', line 40

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