rake_tasks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -0
- data/Gemfile.lock +10 -0
- data/README +45 -0
- data/lib/rake_tasks/gem.rb +70 -0
- data/lib/rake_tasks/rdoc.rb +41 -0
- data/lib/rake_tasks/test.rb +44 -0
- data/lib/rake_tasks.rb +18 -0
- data/rake_tasks.gemspec +26 -0
- data/rakefile +4 -0
- metadata +87 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
== Welcome to RakeTasks
|
2
|
+
|
3
|
+
RakeTasks provides basic rake tasks, such as rdoc generation,
|
4
|
+
building and installing gems, and running tests. It will also load additional
|
5
|
+
rake tasks if they are found.
|
6
|
+
|
7
|
+
The following assumptions are currently made:
|
8
|
+
|
9
|
+
1. There is a valid .gemspec file in the root folder that is named the same
|
10
|
+
as the root folder.
|
11
|
+
|
12
|
+
2. Tests reside in a folder named 'test' and test files are named *_test.rb.
|
13
|
+
|
14
|
+
3. Additional rake tasks are named *.rb and reside in a folder named 'tasks'.
|
15
|
+
|
16
|
+
The default task will be set in the following order:
|
17
|
+
|
18
|
+
1. If tests are found, rake will run test:all.
|
19
|
+
|
20
|
+
2. If tests are not found, but an appropriately named .gemspec file is,
|
21
|
+
gem:build will be run.
|
22
|
+
|
23
|
+
3. If no tests or .gemspec are found, rdoc:app will be run.
|
24
|
+
|
25
|
+
== Getting Started
|
26
|
+
|
27
|
+
1. Install RakeTasks at the command prompt if you haven't yet:
|
28
|
+
|
29
|
+
gem install rake_tasks
|
30
|
+
|
31
|
+
2. Require the gem in your gemfile:
|
32
|
+
|
33
|
+
gem 'rake_tasks', '~> 0.0.1'
|
34
|
+
|
35
|
+
3. Require the gem wherever you need state management:
|
36
|
+
|
37
|
+
require 'rake_tasks'
|
38
|
+
|
39
|
+
== Additional Documentation
|
40
|
+
|
41
|
+
rake rdoc:app
|
42
|
+
|
43
|
+
== License
|
44
|
+
|
45
|
+
RakeTasks is released under the GPLv3 license.
|
@@ -0,0 +1,70 @@
|
|
1
|
+
gem_spec_file = "#{File.basename(Dir.getwd)}.gemspec"
|
2
|
+
|
3
|
+
if File.file?(gem_spec_file)
|
4
|
+
############################################################################
|
5
|
+
namespace :gem do
|
6
|
+
############################################################################
|
7
|
+
|
8
|
+
gem_spec = Gem::Specification.load(gem_spec_file)
|
9
|
+
|
10
|
+
file gem_spec.file_name => [gem_spec_file, *Dir['lib/**/*.rb']] do |t|
|
11
|
+
puts `gem build #{gem_spec_file}`
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Build #{gem_spec.name} gem version #{gem_spec.version}."
|
15
|
+
task :build => gem_spec.file_name
|
16
|
+
|
17
|
+
desc "Install the #{gem_spec.name} gem."
|
18
|
+
task :install => [gem_spec.file_name] do |t|
|
19
|
+
puts `gem install #{gem_spec.file_name} --no-rdoc --no-ri`
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Removes files associated with building and installing #{gem_spec.name}."
|
23
|
+
task :clobber do |t|
|
24
|
+
rm_f gem_spec.file_name
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Removes the gem file, builds, and installs."
|
28
|
+
task :generate => ['gem:clobber', gem_spec.file_name, 'gem:install']
|
29
|
+
|
30
|
+
desc "Show/Set the version number."
|
31
|
+
task :version, [:number] do |t, args|
|
32
|
+
if args[:number].nil?
|
33
|
+
puts "#{gem_spec.name} version #{gem_spec.version}"
|
34
|
+
else
|
35
|
+
temp_file = Tempfile.new("#{gem_spec.name}_gemspec")
|
36
|
+
|
37
|
+
begin
|
38
|
+
File.open(gem_spec_file, 'r') do |file|
|
39
|
+
while line = file.gets
|
40
|
+
if line =~ /version *= *['"]#{gem_spec.version}['"]/
|
41
|
+
temp_file.puts line.sub(
|
42
|
+
/['"]#{gem_spec.version}['"]/, "'#{args[:number]}'")
|
43
|
+
else
|
44
|
+
temp_file.puts line
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
temp_file.flush
|
50
|
+
|
51
|
+
mv temp_file.path, gem_spec_file
|
52
|
+
|
53
|
+
rescue Exception => ex
|
54
|
+
raise ex
|
55
|
+
ensure
|
56
|
+
temp_file.close
|
57
|
+
temp_file.unlink
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
############################################################################
|
63
|
+
end # :gem
|
64
|
+
############################################################################
|
65
|
+
|
66
|
+
Rake::Task[:default].prerequisites.clear
|
67
|
+
task :default => 'gem:build'
|
68
|
+
|
69
|
+
task :clobber => 'gem:clobber'
|
70
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
################################################################################
|
2
|
+
namespace :rdoc do
|
3
|
+
################################################################################
|
4
|
+
|
5
|
+
# Set the paths used by each of the rdoc options.
|
6
|
+
rdoc_files = {
|
7
|
+
:all => [File.join('**', '*.rb')],
|
8
|
+
:test => [File.join('test', 'lib', '**', '*.rb')],
|
9
|
+
:app => [
|
10
|
+
'*.rb',
|
11
|
+
File.join('lib', '**', '*.rb'),
|
12
|
+
],
|
13
|
+
}
|
14
|
+
|
15
|
+
# Base path for the output.
|
16
|
+
base_path = 'doc'
|
17
|
+
|
18
|
+
# Loop through the typs of rdoc files to generate an rdoc task for each one.
|
19
|
+
rdoc_files.keys.each do |rdoc_task|
|
20
|
+
unless Dir[*rdoc_files[rdoc_task]].length == 0
|
21
|
+
Rake::RDocTask.new(
|
22
|
+
:rdoc => rdoc_task,
|
23
|
+
:clobber_rdoc => "#{rdoc_task}:clobber",
|
24
|
+
:rerdoc => "#{rdoc_task}:force") do |rdtask|
|
25
|
+
rdtask.rdoc_dir = File.join(base_path, rdoc_task.to_s)
|
26
|
+
rdtask.options << '--charset' << 'utf8'
|
27
|
+
rdtask.rdoc_files.include(rdoc_files[rdoc_task], 'README')
|
28
|
+
rdtask.main = 'README'
|
29
|
+
end
|
30
|
+
|
31
|
+
Rake::Task[rdoc_task].comment =
|
32
|
+
"Generate #{rdoc_task} RDoc documentation."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
CLOBBER.include(base_path)
|
37
|
+
################################################################################
|
38
|
+
end # :rdoc
|
39
|
+
################################################################################
|
40
|
+
|
41
|
+
task :default => ["rdoc:app"]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
test_dir = 'test'
|
2
|
+
|
3
|
+
if File.directory?(test_dir)
|
4
|
+
############################################################################
|
5
|
+
namespace :test do
|
6
|
+
############################################################################
|
7
|
+
# Add a task to run all tests.
|
8
|
+
Rake::TestTask.new('all') do |task|
|
9
|
+
task.pattern = "#{test_dir}/*_test.rb"
|
10
|
+
task.verbose = true
|
11
|
+
task.warning = true
|
12
|
+
end
|
13
|
+
Rake::Task[:all].comment = 'Run all tests'
|
14
|
+
|
15
|
+
file_list = Dir["#{test_dir}/*_test.rb"]
|
16
|
+
|
17
|
+
# Add a distinct test task for each test file.
|
18
|
+
file_list.each do |item|
|
19
|
+
# Get the name to use for the task by removing '_test.rb' from the name.
|
20
|
+
task_name = File.basename(item, '.rb').gsub(/_test$/, '')
|
21
|
+
|
22
|
+
# Add each test.
|
23
|
+
Rake::TestTask.new(task_name) do |task|
|
24
|
+
task.pattern = item
|
25
|
+
task.verbose = true
|
26
|
+
task.warning = true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
file_name = File.basename(Dir.getwd) + '_test.rb'
|
31
|
+
|
32
|
+
if File.file?("#{test_dir}/#{file_name}")
|
33
|
+
desc "Run a single method in #{file_name}."
|
34
|
+
task :method, [:method_name] do |t, args|
|
35
|
+
puts `ruby ./#{test_dir}/#{file_name} --name #{args[:method_name]}`
|
36
|
+
end
|
37
|
+
end
|
38
|
+
############################################################################
|
39
|
+
end # :test
|
40
|
+
############################################################################
|
41
|
+
|
42
|
+
Rake::Task[:default].prerequisites.clear
|
43
|
+
task :default => 'test:all'
|
44
|
+
end
|
data/lib/rake_tasks.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'tempfile'
|
6
|
+
|
7
|
+
gem_name = File.basename(__FILE__, '.rb')
|
8
|
+
|
9
|
+
require_relative File.join(gem_name, 'rdoc')
|
10
|
+
require_relative File.join(gem_name, 'gem')
|
11
|
+
require_relative File.join(gem_name, 'test')
|
12
|
+
|
13
|
+
# Include any ruby files in the tasks folder.
|
14
|
+
task_files = Dir[File.join(Dir.getwd, 'tasks', '*.rb')]
|
15
|
+
|
16
|
+
task_files.each do |rake_file|
|
17
|
+
require rake_file
|
18
|
+
end
|
data/rake_tasks.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'rake_tasks'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
|
5
|
+
s.summary = 'Basic rake tasks.'
|
6
|
+
s.description = 'RakeTasks contains basic rake tasks ' +
|
7
|
+
'for generating documentation, building gems, and running tests. ' +
|
8
|
+
'It will also find additional rake files if they are included in a ' +
|
9
|
+
'folder named tasks.'
|
10
|
+
|
11
|
+
s.author = 'Travis Herrick'
|
12
|
+
s.email = 'tthetoad@gmail.com'
|
13
|
+
s.homepage = 'http://www.bitbucket.org/ToadJamb/gems_rake_tasks'
|
14
|
+
|
15
|
+
s.license = 'GPLV3'
|
16
|
+
|
17
|
+
s.extra_rdoc_files << 'README'
|
18
|
+
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
s.files = Dir['lib/**/*.rb', '*']
|
21
|
+
s.test_files = Dir['test/**/*.rb']
|
22
|
+
|
23
|
+
s.add_dependency 'rake', '~> 0.8.7'
|
24
|
+
|
25
|
+
s.has_rdoc = true
|
26
|
+
end
|
data/rakefile
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake_tasks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Travis Herrick
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-08-07 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 8
|
30
|
+
- 7
|
31
|
+
version: 0.8.7
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
description: RakeTasks contains basic rake tasks for generating documentation, building gems, and running tests. It will also find additional rake files if they are included in a folder named tasks.
|
36
|
+
email: tthetoad@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
43
|
+
files:
|
44
|
+
- lib/rake_tasks/rdoc.rb
|
45
|
+
- lib/rake_tasks/gem.rb
|
46
|
+
- lib/rake_tasks/test.rb
|
47
|
+
- lib/rake_tasks.rb
|
48
|
+
- Gemfile.lock
|
49
|
+
- Gemfile
|
50
|
+
- rakefile
|
51
|
+
- README
|
52
|
+
- rake_tasks.gemspec
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://www.bitbucket.org/ToadJamb/gems_rake_tasks
|
55
|
+
licenses:
|
56
|
+
- GPLV3
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: -4200384229647405180
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.3.7
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Basic rake tasks.
|
86
|
+
test_files: []
|
87
|
+
|