|
1 |
| -# Copyright 2008 Scott Barron ([email protected]) |
2 |
| -# All rights reserved |
3 |
| - |
4 |
| -# This file may be distributed under an MIT style license. |
5 |
| -# See MIT-LICENSE for details. |
| 1 | +require 'rubygems' |
| 2 | +require 'rake' |
6 | 3 |
|
7 | 4 | begin
|
8 |
| - require 'rubygems' |
9 |
| - require 'rake/gempackagetask' |
10 |
| - require 'rake/testtask' |
11 |
| - require 'rake/rdoctask' |
12 |
| - require 'spec/rake/spectask' |
13 |
| -rescue Exception |
14 |
| - nil |
| 5 | + require 'jeweler' |
| 6 | + Jeweler::Tasks.new do |gem| |
| 7 | + gem.name = "ttilley-aasm" |
| 8 | + gem.summary = %Q{State machine mixin for Ruby objects} |
| 9 | + gem.description = %Q{AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects.} |
| 10 | + gem.homepage = "https://github.com/ttilley/aasm" |
| 11 | + gem.authors = ["Scott Barron", "Scott Petersen", "Travis Tilley"] |
| 12 | + |
| 13 | + gem.add_development_dependency "rspec" |
| 14 | + # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings |
| 15 | + end |
| 16 | + Jeweler::GemcutterTasks.new |
| 17 | +rescue LoadError |
| 18 | + puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler" |
15 | 19 | end
|
16 | 20 |
|
17 |
| -if `ruby -Ilib -raasm -e "print AASM.Version"` =~ /([0-9.]+)$/ |
18 |
| - CURRENT_VERSION = $1 |
19 |
| -else |
20 |
| - CURRENT_VERSION = '0.0.0' |
| 21 | +require 'spec/rake/spectask' |
| 22 | +Spec::Rake::SpecTask.new(:spec) do |spec| |
| 23 | + spec.libs << 'lib' << 'spec' |
| 24 | + spec.spec_files = FileList['spec/**/*_spec.rb'] |
| 25 | + spec.spec_opts = ['-cfs'] |
21 | 26 | end
|
22 |
| -$package_version = CURRENT_VERSION |
23 | 27 |
|
24 |
| -PKG_FILES = FileList['[A-Z]*', |
25 |
| - 'lib/**/*.rb', |
26 |
| - 'doc/**/*' |
27 |
| -] |
28 |
| - |
29 |
| -desc 'Generate documentation for the acts as state machine plugin.' |
30 |
| -rd = Rake::RDocTask.new(:rdoc) do |rdoc| |
31 |
| - rdoc.rdoc_dir = 'html' |
32 |
| - rdoc.template = 'doc/jamis.rb' |
33 |
| - rdoc.rdoc_dir = 'rdoc' |
34 |
| - rdoc.title = 'AASM' |
35 |
| - rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc' << '--title' << 'AASM' |
36 |
| - rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGELOG') |
37 |
| - rdoc.rdoc_files.include('lib/*.rb', 'lib/**/*.rb', 'doc/**/*.rdoc') |
| 28 | +Spec::Rake::SpecTask.new(:rcov) do |spec| |
| 29 | + spec.libs << 'lib' << 'spec' |
| 30 | + spec.pattern = 'spec/**/*_spec.rb' |
| 31 | + spec.rcov = true |
38 | 32 | end
|
39 | 33 |
|
40 |
| -if !defined?(Gem) |
41 |
| - puts "Package target requires RubyGEMs" |
42 |
| -else |
43 |
| - spec = Gem::Specification.new do |s| |
44 |
| - s.name = 'aasm' |
45 |
| - s.version = $package_version |
46 |
| - s.summary = 'State machine mixin for Ruby objects' |
47 |
| - s.description = <<EOF |
48 |
| -AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects. |
49 |
| -EOF |
| 34 | +task :spec => :check_dependencies |
50 | 35 |
|
51 |
| - s.files = PKG_FILES.to_a |
52 |
| - s.require_path = 'lib' |
53 |
| - s.has_rdoc = true |
54 |
| - s.extra_rdoc_files = rd.rdoc_files.reject {|fn| fn =~ /\.rb$/}.to_a |
55 |
| - s.rdoc_options = rd.options |
56 |
| - |
57 |
| - s.authors = ['Scott Barron', 'Scott Petersen', 'Travis Tilley'] |
58 |
| - |
59 |
| - s.homepage = 'https://github.com/ttilley/aasm' |
| 36 | +begin |
| 37 | + require 'reek/rake_task' |
| 38 | + Reek::RakeTask.new do |t| |
| 39 | + t.fail_on_error = true |
| 40 | + t.verbose = false |
| 41 | + t.source_files = 'lib/**/*.rb' |
60 | 42 | end
|
61 |
| - |
62 |
| - package_task = Rake::GemPackageTask.new(spec) do |pkg| |
63 |
| - pkg.need_zip = true |
64 |
| - pkg.need_tar = true |
| 43 | +rescue LoadError |
| 44 | + task :reek do |
| 45 | + abort "Reek is not available. In order to run reek, you must: sudo gem install reek" |
65 | 46 | end
|
66 | 47 | end
|
67 | 48 |
|
68 |
| -if !defined?(Spec) |
69 |
| - puts "spec and cruise targets require RSpec" |
70 |
| -else |
71 |
| - desc "Run all examples with RCov" |
72 |
| - Spec::Rake::SpecTask.new('cruise') do |t| |
73 |
| - t.spec_files = FileList['spec/**/*.rb'] |
74 |
| - t.rcov = true |
75 |
| - t.rcov_opts = ['--exclude', 'spec', '--exclude', 'Library', '--exclude', 'rcov.rb'] |
| 49 | +begin |
| 50 | + require 'roodi' |
| 51 | + require 'roodi_task' |
| 52 | + RoodiTask.new do |t| |
| 53 | + t.verbose = false |
76 | 54 | end
|
77 |
| - |
78 |
| - desc "Run all examples" |
79 |
| - Spec::Rake::SpecTask.new('spec') do |t| |
80 |
| - t.spec_files = FileList['spec/**/*.rb'] |
81 |
| - t.rcov = false |
82 |
| - t.spec_opts = ['-cfs'] |
| 55 | +rescue LoadError |
| 56 | + task :roodi do |
| 57 | + abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi" |
83 | 58 | end
|
84 | 59 | end
|
85 | 60 |
|
86 |
| -if !defined?(Gem) |
87 |
| - puts "Package target requires RubyGEMs" |
88 |
| -else |
89 |
| - desc "sudo gem uninstall aasm && rake gem && sudo gem install pkg/aasm-3.0.0.gem" |
90 |
| - task :reinstall do |
91 |
| - puts `sudo gem uninstall aasm && rake gem && sudo gem install pkg/aasm-3.0.0.gem` |
| 61 | +task :default => :spec |
| 62 | + |
| 63 | +require 'rake/rdoctask' |
| 64 | +Rake::RDocTask.new do |rdoc| |
| 65 | + if File.exist?('VERSION') |
| 66 | + version = File.read('VERSION') |
| 67 | + else |
| 68 | + version = "" |
92 | 69 | end
|
93 |
| -end |
94 | 70 |
|
95 |
| -task :default => [:spec] |
| 71 | + rdoc.rdoc_dir = 'rdoc' |
| 72 | + rdoc.title = "ttilley-aasm #{version}" |
| 73 | + rdoc.rdoc_files.include('README*') |
| 74 | + rdoc.rdoc_files.include('lib/**/*.rb') |
| 75 | +end |
0 commit comments