Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 136 lines (113 sloc) 3.856 kb
bd1f409a »
2011-01-02 Rake task to run specs
1 require 'rspec/core/rake_task'
b3f171cb »
2011-01-02 Rake task to generate docs, and ignore the generated gumpf
2 require 'yard'
538b6b9e »
2011-01-04 gemspec, and 'rake package' to build it. Bless this as 0.0.1
3 require 'rake/gempackagetask'
bd1f409a »
2011-01-02 Rake task to run specs
4
420dcd92 »
2011-01-02 Rake task to pretty-print specs as documentation
5 namespace :spec do
6 RSpec::Core::RakeTask.new(:default)
7
8 desc 'Describe behaviour by running RSpec code examples'
9 RSpec::Core::RakeTask.new(:doc) do |t|
10 t.rspec_opts = '--format documentation'
11 end
ce0a2a83 »
2011-03-25 Add rake spec:ci for Jenkins integration
12
13 # support for continuous integration
14 begin
6fe69212 »
2011-03-25 Don't depend on an unreleased gem version
15 gem 'ci_reporter', :version => '>= 1.6.4'
ce0a2a83 »
2011-03-25 Add rake spec:ci for Jenkins integration
16 require 'ci/reporter/rake/rspec'
17
18 task :setup_ci_report_dir do
19 ENV['CI_REPORTS'] = 'doc/spec/reports'
20 end
21
22 desc 'Run all specs in spec directory outputting CI-friendly XML reports'
23 task :ci => [:setup_ci_report_dir, 'ci:setup:rspec', :default]
24 rescue LoadError => le
25 desc '(DISABLED) Run all specs in spec directory outputting CI-friendly XML reports'
26 task :ci do raise le end
27 end
420dcd92 »
2011-01-02 Rake task to pretty-print specs as documentation
28 end
e1dcbb4a »
2011-01-10 Add Rake task to generate HTML-formatted RSpec, and housekeeping
29 desc 'Run RSpec code examples'
420dcd92 »
2011-01-02 Rake task to pretty-print specs as documentation
30 task :spec => 'spec:default'
bd1f409a »
2011-01-02 Rake task to run specs
31
e1dcbb4a »
2011-01-10 Add Rake task to generate HTML-formatted RSpec, and housekeeping
32 namespace :doc do
33 doc_dir = File.join(File.dirname(__FILE__), 'doc')
34
2f68340d »
2011-01-18 Allow hiding internal classes, constants etc with @private tag
35 namespace :api do
36 desc 'Generate HTML documentation for the public API'
37 YARD::Rake::YardocTask.new(:public) do |t|
38 t.options = ['--no-private']
39 end
40
41 desc 'Generate HTML documentation for implementers, including privates'
42 YARD::Rake::YardocTask.new(:private)
43 end
44 desc 'Generate HTML API documentation'
45 task :api => 'api:public'
e1dcbb4a »
2011-01-10 Add Rake task to generate HTML-formatted RSpec, and housekeeping
46
47 desc 'Generate HTML behaviour documentation from the specs'
48 RSpec::Core::RakeTask.new(:spec) do |t|
49 t.fail_on_error = false # just make the damn docs
50 t.rspec_opts = "--format html --out #{File.join(doc_dir, 'spec', 'index.html')}"
51 end
52
53 desc 'Remove all generated documentation'
54 task :clobber do
6cc7bb26 »
2011-01-10 Cleaner way to run git commands from Rakefile
55 git :clean, '-fdx', doc_dir
e1dcbb4a »
2011-01-10 Add Rake task to generate HTML-formatted RSpec, and housekeeping
56 end
57
58 desc 'Clear out any cruft and regenerate HTML documentation'
59 task :regen => [:clobber, :all]
60
9d58ad6e »
2011-01-10 Rake task to automate publishing docs to gh-pages
61 desc 'Publish docs to Github Pages'
62 task :publish => :regen do
63 current_branch = `git describe --contains --all HEAD`.strip
64 fail "Couldn't determine current branch" if current_branch.empty?
65
66 begin
67 git :stash
68 git :checkout, '--merge', 'gh-pages'
69 git :add, doc_dir
70 git :commit, '-v', doc_dir
71 git :push, :github, 'gh-pages'
72 ensure
73 git :checkout, current_branch
74 git :stash, :pop
75 end
76 end
77
e1dcbb4a »
2011-01-10 Add Rake task to generate HTML-formatted RSpec, and housekeeping
78 desc 'Generate all HTML documentation'
79 task :all => [:api, :spec]
80 end
81 desc 'Generate HTML documentation'
82 task :doc => 'doc:all'
b3f171cb »
2011-01-02 Rake task to generate docs, and ignore the generated gumpf
83
c17f6b1b »
2011-03-25 Add Rake task to push gem to RubyGems.org
84 def shell(cmd)
85 system(cmd) or raise "Command failed: #{cmd}"
86 end
87
d4829901 »
2011-03-25 Rake task to bump version number (yay)
88 def gemspec_file() Dir[File.join(File.dirname(__FILE__), '*.gemspec')].first or raise "Couldn't find gemspec" end
89 def gemspec() Gem::Specification.load(gemspec_file) end
c17f6b1b »
2011-03-25 Add Rake task to push gem to RubyGems.org
90 namespace :package do
91 Rake::GemPackageTask.new(gemspec) do |pkg|
92 pkg.need_zip = true
93 pkg.need_tar = true
94 end
95 end
96 namespace :gem do
97 desc 'Build the gem file'
98 task :build => '^package:gem'
99
100 desc 'Rebuild the gem file cleanly'
101 task :rebuild => ['^package:clobber_package', :build]
102
103 desc 'Publish rebuilt gem to RubyGems.org'
104 task :publish => :rebuild do
105 shell 'gem push pkg/deferrable_gratification*.gem'
106 end
538b6b9e »
2011-01-04 gemspec, and 'rake package' to build it. Bless this as 0.0.1
107 end
c17f6b1b »
2011-03-25 Add Rake task to push gem to RubyGems.org
108 task :gem => 'package:gem'
538b6b9e »
2011-01-04 gemspec, and 'rake package' to build it. Bless this as 0.0.1
109
d4829901 »
2011-03-25 Rake task to bump version number (yay)
110 namespace :version do
111 namespace :bump do
112 SEGMENTS = %w(major minor patch)
113 SEGMENTS.each do |segment|
114 desc "Bump #{segment} version number"
115 task(segment) { bump(segment) }
116 end
117 def bump(segment)
118 segment_index = SEGMENTS.index(segment)
119 raise ArgumentError unless segment_index
120 old_version = gemspec.version.to_s
121 segments = gemspec.version.segments
122 segments[segment_index] += 1
123 new_version = segments.join('.')
124 shell "sed -i '/gem\\.version/s/#{old_version.gsub('.', '\.')}/#{new_version}/' #{gemspec_file}"
125 puts "Bumped version from #{old_version} to #{new_version}"
126 end
127 end
128 end
129
bd1f409a »
2011-01-02 Rake task to run specs
130 task :default => :spec
6cc7bb26 »
2011-01-10 Cleaner way to run git commands from Rakefile
131
132
133 def git(command, *args)
134 system('git', command.to_s, *args.map(&:to_s)) or raise "'git #{command} #{args.join(' ')}' failed!"
135 end
Something went wrong with that request. Please try again.