rake_tasks 2.0.6 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -0
- data/Gemfile +5 -3
- data/lib/base/util.rb +39 -0
- data/lib/rake_tasks.rb +12 -25
- data/lib/rake_tasks/doc.rb +69 -21
- data/lib/rake_tasks/gem.rb +71 -37
- data/lib/rake_tasks/{lib/parser.rb → parser.rb} +17 -18
- data/lib/rake_tasks/tasks/cane.rb +27 -0
- data/lib/rake_tasks/tasks/checksum.rb +19 -0
- data/lib/rake_tasks/tasks/doc.rb +59 -0
- data/lib/rake_tasks/{lib/doc.rb → tasks/gem.rb} +77 -110
- data/lib/rake_tasks/{rdoc.rb → tasks/rdoc.rb} +9 -4
- data/lib/rake_tasks/{test.rb → tasks/test.rb} +7 -3
- data/lib/rake_tasks/{lib/tests.rb → tests.rb} +314 -246
- data/license/gplv3.md +0 -0
- data/license/lgplv3.md +0 -0
- data/license/lgplv3.png +0 -0
- data/rake_tasks.gemspec +10 -4
- data/rakefile +29 -1
- data/readme.markdown +131 -0
- data/test/integration/doc_integration_test.rb +81 -77
- data/test/integration/gem_integration_test.rb +2 -11
- data/test/integration/tests_integration_test.rb +22 -7
- data/test/require.rb +1 -2
- data/test/support/rake_tasks_shared.rb +0 -0
- data/test/support/tunit_test_case.rb +0 -0
- data/test/unit/doc_unit_test.rb +119 -119
- data/test/unit/gem_test.rb +5 -79
- data/test/unit/parser_test.rb +15 -10
- data/todo.md +4 -0
- metadata +99 -57
- metadata.gz.sig +0 -0
- data/README.md +0 -106
- data/lib/rake_tasks/lib/bundle_install.sh +0 -17
- data/lib/rake_tasks/lib/gem.rb +0 -95
- data/lib/rake_tasks/lib/rubies.sh +0 -18
- data/test/unit/tests_unit_test.rb +0 -284
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebdca6dc2cdf0c36add2a79641777a56ada03bac
|
4
|
+
data.tar.gz: 293c0d0f25ef09b92ce62f9afa77afdb4beb4b8e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c72429dac0483323866f90b62d46f59807181566a8ff0905910474ec6f65d45e625c778e6a2925c92705b49fd359b9a068777d25fbf572ae61720973b886149
|
7
|
+
data.tar.gz: b96079c97a75e99e1ca5d0e202df1c2e2814672c44f813f096b31c072681b15b919e6da836a43a6e59e28395203c82f6f01d4c7b30a4ae95cfc8ec56e3575aa6
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
data/Gemfile
CHANGED
data/lib/base/util.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
class Util
|
2
|
+
def self.dir_glob(*patterns)
|
3
|
+
Dir.glob(*patterns)
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.open_file(*args, &block)
|
7
|
+
File.open(*args, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.write_file(file_path, array)
|
11
|
+
open_file(file_path, 'w') do |file|
|
12
|
+
array.each do |element|
|
13
|
+
file.puts element
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.file?(*args)
|
19
|
+
File.file?(*args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.directory?(*args)
|
23
|
+
File.directory?(*args)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.rm(*args)
|
27
|
+
FileUtils.rm(*args)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.load_yaml(*args)
|
31
|
+
# Psych must be available on the system,
|
32
|
+
# preferably via installing ruby with libyaml already installed.
|
33
|
+
Psych.load_file(*args)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.load_gemspec(*args)
|
37
|
+
Gem::Specification.load(*args)
|
38
|
+
end
|
39
|
+
end
|
data/lib/rake_tasks.rb
CHANGED
@@ -28,9 +28,6 @@
|
|
28
28
|
################################################################################
|
29
29
|
#++
|
30
30
|
|
31
|
-
require 'rake/testtask'
|
32
|
-
require 'rdoc/task'
|
33
|
-
require 'rake/clean'
|
34
31
|
require 'fileutils'
|
35
32
|
require 'psych'
|
36
33
|
|
@@ -38,36 +35,26 @@ module RakeTasks
|
|
38
35
|
# Contains the full path to the shell script to run tests in other env's.
|
39
36
|
SCRIPTS = {
|
40
37
|
:rubies => File.expand_path(File.join(
|
41
|
-
File.dirname(__FILE__), '
|
38
|
+
File.dirname(__FILE__), '..', 'scripts', 'rubies.sh')),
|
42
39
|
:gemsets => File.expand_path(File.join(
|
43
|
-
File.dirname(__FILE__), '
|
40
|
+
File.dirname(__FILE__), '..', 'scripts', 'bundle_install.sh')),
|
44
41
|
}
|
45
42
|
end
|
46
43
|
|
47
44
|
gem_name = File.basename(__FILE__, '.rb')
|
45
|
+
base_path = File.dirname(__FILE__)
|
48
46
|
|
49
|
-
|
47
|
+
# Require base files.
|
48
|
+
Dir[File.join(base_path, 'base', '*.rb')].each do |base|
|
49
|
+
require base
|
50
|
+
end
|
50
51
|
|
51
|
-
# Require
|
52
|
-
Dir[File.join(
|
52
|
+
# Require files.
|
53
|
+
Dir[File.join(base_path, gem_name, '*.rb')].each do |lib|
|
53
54
|
require lib
|
54
55
|
end
|
55
56
|
|
56
|
-
#
|
57
|
-
|
58
|
-
|
59
|
-
# Using a glob, they were being required in different orders
|
60
|
-
# in different situations.
|
61
|
-
# Specifically, it was different depending on whether it was
|
62
|
-
# consumed as an installed gem or pointing to the source.
|
63
|
-
base = File.dirname(__FILE__)
|
64
|
-
|
65
|
-
require File.join(base, 'rake_tasks/rdoc')
|
66
|
-
require File.join(base, 'rake_tasks/doc')
|
67
|
-
require File.join(base, 'rake_tasks/gem')
|
68
|
-
require File.join(base, 'rake_tasks/test')
|
69
|
-
|
70
|
-
# Include any ruby files in the tasks folder.
|
71
|
-
Dir[File.join(Dir.getwd, 'tasks', '*.rb')].each do |rake_file|
|
72
|
-
require rake_file
|
57
|
+
# Include any rake files in tasks folders.
|
58
|
+
Dir[File.join(Dir.getwd, '**', 'tasks', '**', '*.rake')].each do |rake_file|
|
59
|
+
import rake_file
|
73
60
|
end
|
data/lib/rake_tasks/doc.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# This file holds the class that handles documentation utilities.
|
2
|
+
|
1
3
|
#--
|
2
4
|
################################################################################
|
3
5
|
# Copyright (C) 2011 Travis Herrick #
|
@@ -28,35 +30,81 @@
|
|
28
30
|
################################################################################
|
29
31
|
#++
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# The main module for this gem.
|
34
|
+
module RakeTasks
|
35
|
+
# This class will handle documentation utilities.
|
36
|
+
class Doc
|
37
|
+
# Constructor.
|
38
|
+
def initialize(gem_info = RakeTasks::Gem)
|
39
|
+
@gem_spec = gem_info.gem_spec
|
40
|
+
@gem_title = gem_info.gem_title(@gem_spec)
|
41
|
+
@license_path = 'license'
|
42
|
+
@contents = nil
|
43
|
+
end
|
35
44
|
|
36
|
-
|
45
|
+
# The default contents for a readme file.
|
46
|
+
def readme_contents
|
47
|
+
gem_title = @gem_title
|
48
|
+
gem_spec = @gem_spec
|
37
49
|
|
38
|
-
|
39
|
-
|
50
|
+
@contents ||= %Q{
|
51
|
+
#{header :h1, "Welcome to #{gem_title}"}
|
40
52
|
|
41
|
-
|
42
|
-
doc_obj = RakeTasks::Doc.new
|
53
|
+
#{gem_spec.description}
|
43
54
|
|
44
|
-
|
45
|
-
|
46
|
-
|
55
|
+
#{header :h2, 'Getting Started'}
|
56
|
+
|
57
|
+
Install #{gem_title} at the command prompt if you haven't yet:
|
58
|
+
|
59
|
+
$ gem install #{gem_spec.name}
|
60
|
+
|
61
|
+
Require the gem in your Gemfile:
|
62
|
+
|
63
|
+
gem '#{gem_spec.name}', '~> #{gem_spec.version}'
|
64
|
+
|
65
|
+
Require the gem wherever you need to use it:
|
66
|
+
|
67
|
+
require '#{gem_spec.name}'
|
68
|
+
|
69
|
+
#{header :h2, 'Usage'}
|
70
|
+
|
71
|
+
TODO
|
72
|
+
|
73
|
+
#{header :h2, 'Additional Notes'}
|
74
|
+
|
75
|
+
TODO
|
76
|
+
|
77
|
+
#{header :h2, 'Additional Documentation'}
|
78
|
+
|
79
|
+
$ rake rdoc:app
|
80
|
+
#{license_details}}.strip
|
81
|
+
|
82
|
+
return @contents.split("\n")
|
47
83
|
end
|
48
84
|
|
49
|
-
|
50
|
-
|
85
|
+
########################################################################
|
86
|
+
private
|
87
|
+
########################################################################
|
51
88
|
|
52
|
-
|
53
|
-
|
54
|
-
|
89
|
+
# Returns formatted headers.
|
90
|
+
def header(type, text = nil)
|
91
|
+
case type
|
92
|
+
when :h1
|
93
|
+
"#{text}\n#{'=' * text.length}"
|
94
|
+
when :h2
|
95
|
+
"#{text}\n#{'-' * text.length}"
|
96
|
+
end
|
55
97
|
end
|
56
98
|
|
57
|
-
|
58
|
-
|
59
|
-
|
99
|
+
# Compose the license details.
|
100
|
+
def license_details
|
101
|
+
return if @gem_spec.licenses.empty?
|
60
102
|
|
61
|
-
|
103
|
+
%Q{
|
104
|
+
#{header :h2, 'License'}
|
105
|
+
|
106
|
+
#{@gem_title} is released under the #{@gem_spec.licenses.first} license.
|
107
|
+
}
|
108
|
+
end
|
109
|
+
end
|
62
110
|
end
|
data/lib/rake_tasks/gem.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# This file holds the class that handles gem utilities.
|
2
|
+
|
1
3
|
#--
|
2
4
|
################################################################################
|
3
5
|
# Copyright (C) 2011 Travis Herrick #
|
@@ -28,52 +30,84 @@
|
|
28
30
|
################################################################################
|
29
31
|
#++
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# The main module for this gem.
|
34
|
+
module RakeTasks
|
35
|
+
# This class will handle gem utilities.
|
36
|
+
class Gem
|
37
|
+
class << self
|
38
|
+
# Check whether a gem spec file exists for this project.
|
39
|
+
def gemspec_file?
|
40
|
+
return !gem_spec_file.nil?
|
41
|
+
end
|
35
42
|
|
36
|
-
|
37
|
-
|
43
|
+
def gem_file?
|
44
|
+
return !gem_file.nil?
|
45
|
+
end
|
38
46
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
47
|
+
# Returns the gem title.
|
48
|
+
# This is the gem name with underscores removed.
|
49
|
+
# Wherever an underscore is removed, the next letter is capitalized.
|
50
|
+
def gem_title(spec = gem_spec)
|
51
|
+
return nil unless spec.respond_to?(:name)
|
52
|
+
spec.name.split('_').map { |w| w.capitalize }.join('')
|
53
|
+
end
|
43
54
|
|
44
|
-
|
45
|
-
|
55
|
+
# Get the gem specification.
|
56
|
+
def gem_spec
|
57
|
+
Util.load_gemspec(gem_spec_file) if gemspec_file?
|
58
|
+
end
|
46
59
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
60
|
+
# Check for a gem spec file.
|
61
|
+
def gem_spec_file
|
62
|
+
Util.dir_glob('*.gemspec').first
|
63
|
+
end
|
51
64
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
65
|
+
def gem_file
|
66
|
+
@gem_file ||= Util.dir_glob('*.gem').first
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns the name and version from the specified gem specification.
|
70
|
+
def version(spec = gem_spec)
|
71
|
+
if spec.respond_to?(:name) && spec.respond_to?(:version)
|
72
|
+
"#{spec.name} version #{spec.version}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Updates the version in the gem specification file.
|
77
|
+
def version!(value, spec = gem_spec)
|
78
|
+
return unless gem_spec_file
|
56
79
|
|
57
|
-
|
58
|
-
|
80
|
+
temp = StringIO.new
|
81
|
+
write_temp spec, temp, gem_spec_file, value
|
59
82
|
|
60
|
-
|
61
|
-
|
62
|
-
if args[:number].nil?
|
63
|
-
puts RakeTasks::Gem.version(gem_spec)
|
64
|
-
else
|
65
|
-
RakeTasks::Gem.version! args[:number], gem_spec
|
66
|
-
gem_spec = RakeTasks::Gem.gem_spec
|
67
|
-
puts RakeTasks::Gem.version(gem_spec)
|
83
|
+
temp.rewind
|
84
|
+
write_file gem_spec_file, temp
|
68
85
|
end
|
69
|
-
end
|
70
86
|
|
71
|
-
|
72
|
-
end # :gem
|
73
|
-
############################################################################
|
87
|
+
private
|
74
88
|
|
75
|
-
|
76
|
-
|
89
|
+
# Write the contents of a stream to a file.
|
90
|
+
def write_file(gem_spec_file, stream)
|
91
|
+
Util.open_file(gem_spec_file, 'w') do |file|
|
92
|
+
while line = stream.gets
|
93
|
+
file.puts line
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
77
97
|
|
78
|
-
|
98
|
+
# Write the contents of a file to an in-memory stream object,
|
99
|
+
# changing the version.
|
100
|
+
def write_temp(spec, stream, gem_spec_file, version)
|
101
|
+
Util.open_file(gem_spec_file, 'r') do |file|
|
102
|
+
while line = file.gets
|
103
|
+
if line =~ /version *= *['"]#{spec.version}['"]/
|
104
|
+
stream.puts line.sub(/['"].*['"]/, "'#{version}'")
|
105
|
+
else
|
106
|
+
stream.puts line
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
79
113
|
end
|
@@ -36,7 +36,13 @@ module RakeTasks
|
|
36
36
|
# This class will handle parsing duties.
|
37
37
|
class Parser
|
38
38
|
def initialize
|
39
|
-
@data =
|
39
|
+
@data = {
|
40
|
+
tests: 0,
|
41
|
+
assertions: 0,
|
42
|
+
failures: 0,
|
43
|
+
errors: 0,
|
44
|
+
skips: 0,
|
45
|
+
}
|
40
46
|
end
|
41
47
|
|
42
48
|
# Parse a given line.
|
@@ -48,28 +54,21 @@ module RakeTasks
|
|
48
54
|
puts line.strip #unless line.strip.empty?
|
49
55
|
when /^\d+ tests, \d+ assertions, /
|
50
56
|
puts line.strip
|
51
|
-
|
57
|
+
|
58
|
+
data = line.split(', ').map { |x| x.to_i }
|
59
|
+
|
60
|
+
@data[:tests] += data[0]
|
61
|
+
@data[:assertions] += data[1]
|
62
|
+
@data[:failures] += data[2]
|
63
|
+
@data[:errors] += data[3]
|
64
|
+
@data[:skips] += data[4]
|
52
65
|
end
|
53
66
|
end
|
54
67
|
|
55
68
|
# Calculate the summary and send it to standard out.
|
56
69
|
def summarize
|
57
|
-
tests
|
58
|
-
|
59
|
-
failures = 0
|
60
|
-
errors = 0
|
61
|
-
skips = 0
|
62
|
-
|
63
|
-
@data.each do |status|
|
64
|
-
tests = tests + status[0]
|
65
|
-
assertions = assertions + status[1]
|
66
|
-
failures = failures + status[2]
|
67
|
-
errors = errors + status[3]
|
68
|
-
skips = skips + status[4]
|
69
|
-
end
|
70
|
-
|
71
|
-
puts "%d tests, %d assertions, %d failures, %d errors, %d skips" % [
|
72
|
-
tests, assertions, failures, errors, skips]
|
70
|
+
puts "%d tests, %d assertions, %d failures, %d errors, %d skips" %
|
71
|
+
@data.values
|
73
72
|
end
|
74
73
|
end
|
75
74
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'cane'
|
2
|
+
require 'cane/rake_task'
|
3
|
+
|
4
|
+
namespace :cane do
|
5
|
+
desc ''
|
6
|
+
Cane::RakeTask.new(:quality) do |cane|
|
7
|
+
cane.canefile = '.cane'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Check abc metrics with cane'
|
11
|
+
Cane::RakeTask.new(:warn) do |cane|
|
12
|
+
cane.canefile = '.cane'
|
13
|
+
cane.abc_max = 7
|
14
|
+
cane.no_doc = true
|
15
|
+
cane.no_style = true
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Check code quality metrics with cane for all files'
|
19
|
+
Cane::RakeTask.new(:all) do |cane|
|
20
|
+
cane.canefile = '.cane'
|
21
|
+
cane.style_exclude = []
|
22
|
+
cane.abc_exclude = []
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Run cane to check quality metrics'
|
27
|
+
task :cane => 'cane:quality'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
if RakeTasks::Gem.gem_file?
|
2
|
+
require 'digest/sha2'
|
3
|
+
|
4
|
+
desc 'Generate a checksum for the current gem file'
|
5
|
+
task :checksum do |task|
|
6
|
+
gem_file = RakeTasks::Gem.gem_file
|
7
|
+
checksum = Digest::SHA512.new.hexdigest(File.read(gem_file))
|
8
|
+
checksum_file = File.basename(gem_file)
|
9
|
+
checksum_path = "checksum/#{checksum_file}.sha512"
|
10
|
+
|
11
|
+
puts checksum
|
12
|
+
|
13
|
+
FileUtils.mkdir_p 'checksum' unless File.directory?('checksum')
|
14
|
+
|
15
|
+
File.open(checksum_path, 'w') do |file|
|
16
|
+
file.write checksum
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|