gemdev 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +73 -100
- data/lib/gemdev.rb +41 -46
- data/lib/test/unit/subsets.rb +259 -256
- data/test/gemdev/gem_with_folder_require/gemspecs/some.gemspec +9 -0
- data/test/gemdev/rakefile_with_multiple_specs/gemspecs/1.gemspec +9 -0
- data/test/gemdev/rakefile_with_multiple_specs/gemspecs/2.gemspec +9 -0
- data/test/gemdev/rakefile_with_multiple_specs/gemspecs/3.gemspec +9 -0
- metadata +13 -9
- data/test/gemdev/gem_with_folder_require/Rakefile +0 -15
- data/test/gemdev/rakefile_with_multiple_specs/Rakefile +0 -29
data/README
CHANGED
@@ -1,100 +1,73 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
# end
|
75
|
-
#
|
76
|
-
# #
|
77
|
-
# # Gem specification
|
78
|
-
# #
|
79
|
-
# Gem::manage_gems
|
80
|
-
# spec = Gem::Specification.new do |s|
|
81
|
-
# s.name = "ioutils"
|
82
|
-
# s.version = "0.1.0"
|
83
|
-
# s.author = "Simon Chiang"
|
84
|
-
# s.email = "simon.chiang@uchsc.edu"
|
85
|
-
# s.homepage = "http://rubyforge.org/projects/ioutils/"
|
86
|
-
# s.platform = Gem::Platform::RUBY
|
87
|
-
# s.files = Dir.glob("{test,lib,docs}/**/*")
|
88
|
-
# s.require_path = "lib"
|
89
|
-
# s.autorequire = "ioutils"
|
90
|
-
# s.test_file = "test/ioutils_test_suite.rb"
|
91
|
-
#
|
92
|
-
# s.has_rdoc = true
|
93
|
-
# s.extra_rdoc_files = ["README"]
|
94
|
-
# s.add_dependency("gemdev", ">= 0.1.1")
|
95
|
-
# s.add_dependency("activesupport", ">= 1.4.2")
|
96
|
-
# end
|
97
|
-
#
|
98
|
-
# Rake::GemPackageTask.new(spec) do |pkg|
|
99
|
-
# pkg.need_tar = true
|
100
|
-
# end
|
1
|
+
= GemDev
|
2
|
+
Utilities simplifying gem development.
|
3
|
+
|
4
|
+
== Introduction
|
5
|
+
GemDev provides some extensions to make it easy to develop multiple,
|
6
|
+
interrelated gems at once by allowing you to specify your gem
|
7
|
+
development folders in the RubyGems configuration file (.gemrc).
|
8
|
+
|
9
|
+
Additionally, test extensions are provided to permit test subsetting.
|
10
|
+
|
11
|
+
Copyright (c) 2006-2007, Regents of the University of Colorado.
|
12
|
+
Developer:: Simon Chiang, Biomolecular Structure Program
|
13
|
+
Support:: UCHSC School of Medicine Deans Academic Enrichment Fund
|
14
|
+
Licence:: MIT-Style
|
15
|
+
|
16
|
+
== GemDev Usage
|
17
|
+
Specify development folders using one big glob or an array of globs
|
18
|
+
keyed by 'development' in the '.gemrc' file. GemDev will load each
|
19
|
+
'gemspecs/*.gemspec' file along every path specified, and set the
|
20
|
+
gem path so you can require the gems as if they were already installed.
|
21
|
+
|
22
|
+
Say you were developing 'ioutils' with the following:
|
23
|
+
/path/to/ioutils # => your development folder
|
24
|
+
/path/to/ioutils/gemspecs/0.7.0.gemspec # => a released gemspec
|
25
|
+
/path/to/ioutils/gemspecs/0.8.0.gemspec # => the lastest, unreleased gemspec
|
26
|
+
|
27
|
+
To specify this gem, you add to '.gemrc':
|
28
|
+
|
29
|
+
development: /path/to/ioutils
|
30
|
+
|
31
|
+
or if you have a bunch of other gems:
|
32
|
+
|
33
|
+
development:
|
34
|
+
- /path/to/{ioutils,another_gem}
|
35
|
+
- /path/to/yet_another_gem
|
36
|
+
|
37
|
+
In your scripts:
|
38
|
+
|
39
|
+
require 'gemdev'
|
40
|
+
require 'ioutils' # => now works without installing ioutils
|
41
|
+
|
42
|
+
Requiring ioutils as above will load the latest version (0.8.0) by default, but
|
43
|
+
nothing prevents you from requiring a different version if you need to.
|
44
|
+
|
45
|
+
== Working with Rakefiles
|
46
|
+
Splitting gemspecs out of a Rakefile while preserving a GemPackageTask is easy:
|
47
|
+
|
48
|
+
# Normally here you'd have your definition
|
49
|
+
# Gem::Specification.new ...
|
50
|
+
#
|
51
|
+
# Just replace with the path to the gemspec you want to package
|
52
|
+
spec = Gem::SourceIndex.load_specification("./gemspecs/0.8.0.gemspec")
|
53
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
54
|
+
pkg.need_tar = true
|
55
|
+
end
|
56
|
+
|
57
|
+
== Subsets Usage
|
58
|
+
Subsets are provided to make unit testing more convenient.
|
59
|
+
|
60
|
+
Example:
|
61
|
+
|
62
|
+
require 'gemdev'
|
63
|
+
require 'test/unit/subsets'
|
64
|
+
|
65
|
+
class YourTest < Test::Unit::TestCase
|
66
|
+
# only runs if ENV['benchmark']=true
|
67
|
+
def test_benchmark_some_method
|
68
|
+
benchmark_test do |x|
|
69
|
+
x.report("speed") {...}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
data/lib/gemdev.rb
CHANGED
@@ -1,69 +1,63 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'yaml'
|
3
|
-
require 'strscan'
|
4
3
|
|
5
|
-
module Gem
|
6
|
-
class Specification
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
module Gem # :nodoc:
|
5
|
+
class Specification
|
6
|
+
# The full path to the gem (install path + full name).
|
7
|
+
#
|
8
|
+
# return:: [String] the full gem path
|
9
|
+
#
|
10
|
+
def full_gem_path
|
11
|
+
@full_gem_path || File.join(installation_path, "gems", full_name)
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def full_gem_path=(input)
|
15
|
+
@full_gem_path = input
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
def self.load_devel(path)
|
19
|
+
gemspecs = []
|
20
|
+
fail "NESTED Specification.load calls not allowed!" if @@gather
|
21
|
+
@@gather = proc do |gs|
|
22
|
+
gs.full_gem_path = path
|
23
|
+
gemspecs << gs
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
eval(specs.join("\n"))
|
39
|
-
gemspecs
|
40
|
-
ensure
|
41
|
-
@@gather = nil
|
42
|
-
end
|
26
|
+
# load any gemspecs
|
27
|
+
specs = Dir.glob( File.expand_path(File.join(path, "gemspecs/*.gemspec")) ).collect do |spec|
|
28
|
+
File.read(spec)
|
29
|
+
end
|
30
|
+
|
31
|
+
eval(specs.join("\n"))
|
32
|
+
gemspecs
|
33
|
+
ensure
|
34
|
+
@@gather = nil
|
35
|
+
end
|
43
36
|
end
|
44
37
|
|
45
|
-
class GemPathSearcher
|
46
|
-
|
38
|
+
class GemPathSearcher
|
39
|
+
def refresh!
|
47
40
|
# cut and paste of the initialize routine
|
48
41
|
@gemspecs = init_gemspecs
|
49
42
|
@lib_dirs = {}
|
50
43
|
@gemspecs.each do |spec|
|
51
|
-
|
44
|
+
@lib_dirs[spec.object_id] = lib_dirs(spec)
|
52
45
|
end
|
53
|
-
|
46
|
+
end
|
54
47
|
end
|
55
48
|
end
|
56
49
|
|
57
50
|
if File.exists?(Gem.config_file)
|
58
51
|
config = YAML.load_file(Gem.config_file)
|
59
|
-
|
52
|
+
devel_paths = config['development']
|
60
53
|
|
61
54
|
# File.expand_path required to change windows filepaths to unix filepaths
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
55
|
+
devel_paths = [devel_paths] unless devel_paths.kind_of?(Array)
|
56
|
+
paths = devel_paths.collect do |path|
|
57
|
+
Dir.glob(File.expand_path(path))
|
58
|
+
end
|
59
|
+
|
60
|
+
paths = paths.flatten.collect {|path| File.expand_path(path)}
|
67
61
|
paths.each do |path|
|
68
62
|
next if File.file?(path)
|
69
63
|
Gem::Specification.load_devel(path).each do |spec|
|
@@ -72,4 +66,5 @@ if File.exists?(Gem.config_file)
|
|
72
66
|
end
|
73
67
|
end
|
74
68
|
|
69
|
+
raise "RubyGems version is too old for GemDev.\nUpdate with 'gem update --server' or download the latest One-Click installer for Windows, then try again." unless Gem.respond_to?(:searcher)
|
75
70
|
Gem.searcher.refresh!
|
data/lib/test/unit/subsets.rb
CHANGED
@@ -2,264 +2,267 @@ require 'test/unit'
|
|
2
2
|
require 'benchmark'
|
3
3
|
require 'pp'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
|
5
|
+
module Test # :nodoc:
|
6
|
+
module Unit # :nodoc:
|
7
|
+
|
8
|
+
# These subsets facilitate testing by using the ENV variables specified on the command line
|
9
|
+
# to indicate which tests to run. The ENV variables are set by rake, so this code implicitly
|
10
|
+
# assumes that you're running your tests through rake.
|
11
|
+
class TestCase
|
12
|
+
class << self
|
13
|
+
# Access to the case-insensitive ENV variables
|
14
|
+
def env(type, reset=false)
|
15
|
+
if @env_vars.nil? || reset
|
16
|
+
@env_vars = {}
|
17
|
+
ENV.each_pair do |key, value|
|
18
|
+
@env_vars[key.downcase] = value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@env_vars[type.downcase]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Causes a whole test suite to require one of the listed platforms
|
25
|
+
# in order to run. See match_platform? for details.
|
26
|
+
#
|
27
|
+
# Simply declare like:
|
28
|
+
#
|
29
|
+
# class Test::Unit::TestCase
|
30
|
+
# require_platform 'mswin'
|
31
|
+
# end
|
32
|
+
def require_platform(*platforms)
|
33
|
+
@platforms = platforms
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns true if RUBY_PLATFORM matches one of the specfied
|
37
|
+
# platforms. Use the prefix 'non_' to specify any plaform but the
|
38
|
+
# specified platform (ex: 'non_mswin')
|
39
|
+
#
|
40
|
+
# Some common platforms:
|
41
|
+
# - mswin:: Windows
|
42
|
+
def match_platform?(*platforms)
|
43
|
+
platforms.each do |platform|
|
44
|
+
platform.to_s =~ /^(non_)?(.*)/
|
45
|
+
|
46
|
+
non = true if $1
|
47
|
+
match_platform = !RUBY_PLATFORM.index($2).nil?
|
48
|
+
return false unless (non && !match_platform) || (!non && match_platform)
|
49
|
+
end
|
50
|
+
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
alias :original_suite :suite
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.suite
|
58
|
+
if match_platform?(*@platforms)
|
59
|
+
original_suite
|
60
|
+
else
|
61
|
+
# if platforms are specfied for the tests and the platform does NOT
|
62
|
+
# match, remake the suite to skip all tests.
|
63
|
+
method_names = public_instance_methods(true)
|
64
|
+
suite = Test::Unit::TestSuite.new(name)
|
65
|
+
method_names.each do |method_name|
|
66
|
+
catch(:invalid_test) do
|
67
|
+
suite << new('on_test_skipped') if method_name =~ /^test/
|
68
|
+
end
|
69
|
+
end
|
70
|
+
suite
|
71
|
+
end
|
72
|
+
end
|
10
73
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
# Some common platforms:
|
40
|
-
# - mswin:: Windows
|
41
|
-
def match_platform?(*platforms)
|
42
|
-
platforms.each do |platform|
|
43
|
-
platform.to_s =~ /^(non_)?(.*)/
|
44
|
-
|
45
|
-
non = true if $1
|
46
|
-
match_platform = !RUBY_PLATFORM.index($2).nil?
|
47
|
-
return false unless (non && !match_platform) || (!non && match_platform)
|
48
|
-
end
|
49
|
-
|
50
|
-
true
|
51
|
-
end
|
52
|
-
|
53
|
-
alias :original_suite :suite
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.suite
|
57
|
-
if match_platform?(*@platforms)
|
58
|
-
original_suite
|
59
|
-
else
|
60
|
-
# if platforms are specfied for the tests and the platform does NOT
|
61
|
-
# match, remake the suite to skip all tests.
|
62
|
-
method_names = public_instance_methods(true)
|
63
|
-
suite = Test::Unit::TestSuite.new(name)
|
64
|
-
method_names.each do |method_name|
|
65
|
-
catch(:invalid_test) do
|
66
|
-
suite << new('on_test_skipped') if method_name =~ /^test/
|
67
|
-
end
|
68
|
-
end
|
69
|
-
suite
|
70
|
-
end
|
71
|
-
end
|
74
|
+
# Platform-specific test. Useful for specifying test that should only be run on,
|
75
|
+
# for instance, windows. See match_platform? for details.
|
76
|
+
def platform_test(*platforms, &block)
|
77
|
+
if self.class.match_platform?(*platforms)
|
78
|
+
yield
|
79
|
+
else
|
80
|
+
print ' '
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Subset test declaration for extended tests -- type: EXTENDED
|
85
|
+
# Prints 'x' unless run.
|
86
|
+
def extended_test(&block)
|
87
|
+
subset_test("EXTENDED", "x", &block)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Subset test declaration for benchmark tests -- type: BENCHMARK
|
91
|
+
# Prints 'b' unless run.
|
92
|
+
def benchmark_test(length=10, &block)
|
93
|
+
subset_test("BENCHMARK") do
|
94
|
+
puts
|
95
|
+
puts calling_method
|
96
|
+
bm(length) do |x|
|
97
|
+
yield(x)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
72
101
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
102
|
+
# Case tests take a hash of testcases and expected values. Each pair in the hash will
|
103
|
+
# be passed to the block if type CASE_TEST is specified. Individual cases tests can be
|
104
|
+
# specified by providing a regexp in CASE; the testcase will run if the pretty-print of
|
105
|
+
# the testcase matches the provided regexp. Example:
|
106
|
+
#
|
107
|
+
# case_test(
|
108
|
+
# [1,2,3] => 'an array testcase',
|
109
|
+
# '[1, 2, 3]' => 'the pretty print of the array',
|
110
|
+
# 'another testcase' => 'some third testcase'
|
111
|
+
# ).do |testcase, expected|
|
112
|
+
# ...your test code...
|
113
|
+
# end
|
114
|
+
#
|
115
|
+
# ENV['CASE_TEST']=true => all tests run
|
116
|
+
# ENV['CASE']='1, 2, 3' => first two tests run
|
117
|
+
# ENV['CASE']='another' => only last test runs
|
118
|
+
def case_test(hash, &block)
|
119
|
+
if match_regexp?("CASE_TEST", calling_method)
|
120
|
+
hash.each_pair do |testcase, expected|
|
121
|
+
yield(testcase, expected) if match_regexp?("CASE", testcase)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Acase tests take an array of testcases. Each testcase in the array will
|
127
|
+
# be passed to the block if type CASE_TEST is specified. Individual cases tests can be
|
128
|
+
# specified by providing a regexp in CASE; the testcase will run if the pretty-print of
|
129
|
+
# the testcase matches the provided regexp. Example:
|
130
|
+
#
|
131
|
+
# case_test(
|
132
|
+
# [1,2,3] ,
|
133
|
+
# '[1, 2, 3]',
|
134
|
+
# 'another testcase'
|
135
|
+
# ).do |testcase|
|
136
|
+
# ...your test code...
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
# ENV['CASE_TEST']=true => all tests run
|
140
|
+
# ENV['CASE']='1, 2, 3' => first two tests run
|
141
|
+
# ENV['CASE']='another' => only last test runs
|
142
|
+
def acase_test(*array)
|
143
|
+
if match_regexp?("CASE_TEST", calling_method)
|
144
|
+
array.each do |testcase|
|
145
|
+
yield(testcase) if match_regexp?("CASE", testcase)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
100
149
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
150
|
+
|
151
|
+
# Subset test declaration for prompt tests -- type: PROMPT
|
152
|
+
# Prints 'p' unless run.
|
153
|
+
#
|
154
|
+
# Useful for tests that require user input. If run, then this test will
|
155
|
+
# prompt the user for an input for each item in the array. The results
|
156
|
+
# are collected in a hash and passed to the block.
|
157
|
+
#
|
158
|
+
# Example:
|
159
|
+
#
|
160
|
+
# def test_something_important
|
161
|
+
# prompt_test(:a, :b, :c).do |config|
|
162
|
+
# ...your test code...
|
163
|
+
# end
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
# (if run, prompts print to $stdout the following:)
|
167
|
+
# test_something_important: Enter values or 'skip'
|
168
|
+
# a: # => enter 'avalue'
|
169
|
+
# b: # => enter 'bvalue'
|
170
|
+
# c: # => enter 'cvalue'
|
171
|
+
#
|
172
|
+
# # config => {:a => 'avalue', :b => 'bvalue', :c => 'cvalue'}
|
173
|
+
def prompt_test(*array, &block)
|
174
|
+
subset_test("PROMPT", "p") do
|
175
|
+
puts "\n#{calling_method} -- Enter values or 'skip'."
|
176
|
+
|
177
|
+
config = {}
|
178
|
+
array.each do |key|
|
179
|
+
print "#{key}: "
|
180
|
+
value = gets.strip
|
181
|
+
flunk "skipped test" if value =~ /skip/i
|
182
|
+
|
183
|
+
config[key] = value
|
184
|
+
end
|
185
|
+
|
186
|
+
yield(config)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
protected
|
191
|
+
|
192
|
+
# Formats the input by using singleline_pp
|
193
|
+
def spp(input, str='')
|
194
|
+
PP.singleline_pp(input, str)
|
195
|
+
end
|
196
|
+
|
197
|
+
# Required for platform tests
|
198
|
+
def on_test_skipped
|
199
|
+
print ' '
|
200
|
+
end
|
201
|
+
|
202
|
+
# Access to the case-insensitive ENV variables
|
203
|
+
def env(type)
|
204
|
+
self.class.env(type)
|
205
|
+
end
|
206
|
+
|
207
|
+
# Returns true if the env_var(var) is set and matches /^true%/i
|
208
|
+
def env_true?(var)
|
209
|
+
env(var) && env(var) =~ /^true$/i
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns true if the subset type or 'ALL' is specified in ENV
|
213
|
+
def run_subset?(type)
|
214
|
+
env_true?(type) || env_true?("ALL") ? true : false
|
215
|
+
end
|
148
216
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
# Access to the case-insensitive ENV variables
|
202
|
-
def env(type)
|
203
|
-
self.class.env(type)
|
204
|
-
end
|
205
|
-
|
206
|
-
# Returns true if the env_var(var) is set and matches /^true%/i
|
207
|
-
def env_true?(var)
|
208
|
-
env(var) && env(var) =~ /^true$/i
|
209
|
-
end
|
210
|
-
|
211
|
-
# Returns true if the subset type or 'ALL' is specified in ENV
|
212
|
-
def run_subset?(type)
|
213
|
-
env_true?(type) || env_true?("ALL") ? true : false
|
214
|
-
end
|
215
|
-
|
216
|
-
# Returns true if the pretty-print string for obj matches the regexp specified in env_var(type).
|
217
|
-
# Returns the default value if 'ALL' is specified in ENV or type is not specified in ENV.
|
218
|
-
def match_regexp?(type, obj, default=true)
|
219
|
-
return true if env_true?("ALL")
|
220
|
-
return default unless env(type)
|
221
|
-
|
222
|
-
spp(obj) =~ Regexp.new(env(type)) ? true : false
|
223
|
-
end
|
224
|
-
|
225
|
-
# Calling method iterates over the call stack, and returns the first calling
|
226
|
-
# method name that matches the input pattern (by default /^test/)
|
227
|
-
def calling_method(pattern=/^test/)
|
228
|
-
0.upto(caller.length) do |i|
|
229
|
-
caller[i] =~ /:in `(.*)'$/
|
230
|
-
method_name = $1
|
231
|
-
return method_name if method_name =~ pattern
|
232
|
-
end
|
233
|
-
|
234
|
-
''
|
235
|
-
end
|
236
|
-
|
237
|
-
# Basic method for a subset test. The provided block will run if:
|
238
|
-
# - The subset type or 'ALL' is specified in ENV
|
239
|
-
# - The calling method matches the regexp provided in the "TYPE_TEST" ENV variable
|
240
|
-
#
|
241
|
-
# Otherwise the block will be skipped and +skip+ will be printed. By default skip
|
242
|
-
# is the first letter of +type+.
|
243
|
-
def subset_test(type, skip=type[0..0].downcase, &block)
|
244
|
-
type = type.upcase
|
245
|
-
type_test = "#{type}_TEST"
|
246
|
-
if run_subset?(type) || env(type_test)
|
247
|
-
if match_regexp?(type_test, calling_method)
|
248
|
-
yield
|
249
|
-
else
|
250
|
-
print skip
|
251
|
-
end
|
252
|
-
else
|
253
|
-
print skip
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
# Runs only if the first argument causes an 'if' statement to return true.
|
258
|
-
def switch_test(run_test, skip="!", &block)
|
259
|
-
if run_test
|
260
|
-
yield
|
261
|
-
else
|
262
|
-
print skip
|
263
|
-
end
|
264
|
-
end
|
217
|
+
# Returns true if the pretty-print string for obj matches the regexp specified in env_var(type).
|
218
|
+
# Returns the default value if 'ALL' is specified in ENV or type is not specified in ENV.
|
219
|
+
def match_regexp?(type, obj, default=true)
|
220
|
+
return true if env_true?("ALL")
|
221
|
+
return default unless env(type)
|
222
|
+
|
223
|
+
spp(obj) =~ Regexp.new(env(type)) ? true : false
|
224
|
+
end
|
225
|
+
|
226
|
+
# Calling method iterates over the call stack, and returns the first calling
|
227
|
+
# method name that matches the input pattern (by default /^test/)
|
228
|
+
def calling_method(pattern=/^test/)
|
229
|
+
0.upto(caller.length) do |i|
|
230
|
+
caller[i] =~ /:in `(.*)'$/
|
231
|
+
method_name = $1
|
232
|
+
return method_name if method_name =~ pattern
|
233
|
+
end
|
234
|
+
|
235
|
+
''
|
236
|
+
end
|
237
|
+
|
238
|
+
# Basic method for a subset test. The provided block will run if:
|
239
|
+
# - The subset type or 'ALL' is specified in ENV
|
240
|
+
# - The calling method matches the regexp provided in the "TYPE_TEST" ENV variable
|
241
|
+
#
|
242
|
+
# Otherwise the block will be skipped and +skip+ will be printed. By default skip
|
243
|
+
# is the first letter of +type+.
|
244
|
+
def subset_test(type, skip=type[0..0].downcase, &block)
|
245
|
+
type = type.upcase
|
246
|
+
type_test = "#{type}_TEST"
|
247
|
+
if run_subset?(type) || env(type_test)
|
248
|
+
if match_regexp?(type_test, calling_method)
|
249
|
+
yield
|
250
|
+
else
|
251
|
+
print skip
|
252
|
+
end
|
253
|
+
else
|
254
|
+
print skip
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
# Runs only if the first argument causes an 'if' statement to return true.
|
259
|
+
def switch_test(run_test, skip="!", &block)
|
260
|
+
if run_test
|
261
|
+
yield
|
262
|
+
else
|
263
|
+
print skip
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
265
268
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: gemdev
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-05-
|
6
|
+
version: 0.1.3
|
7
|
+
date: 2007-05-29 00:00:00 -06:00
|
8
8
|
summary: Making gem development a bit easier.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -30,20 +30,24 @@ authors:
|
|
30
30
|
- Simon Chiang
|
31
31
|
files:
|
32
32
|
- test/gemdev
|
33
|
-
- test/gemdev_test.rb
|
34
|
-
- test/gemdev_test_helper.rb
|
35
|
-
- test/gemdev_test_suite.rb
|
36
|
-
- test/subsets_test.rb
|
37
33
|
- test/gemdev/gemrc
|
38
34
|
- test/gemdev/gem_with_folder_require
|
39
|
-
- test/gemdev/
|
35
|
+
- test/gemdev/gem_with_folder_require/gemspecs
|
36
|
+
- test/gemdev/gem_with_folder_require/gemspecs/some.gemspec
|
40
37
|
- test/gemdev/gem_with_folder_require/lib
|
41
|
-
- test/gemdev/gem_with_folder_require/Rakefile
|
42
38
|
- test/gemdev/gem_with_folder_require/lib/folder_require.rb
|
39
|
+
- test/gemdev/rakefile_with_multiple_specs
|
40
|
+
- test/gemdev/rakefile_with_multiple_specs/gemspecs
|
41
|
+
- test/gemdev/rakefile_with_multiple_specs/gemspecs/1.gemspec
|
42
|
+
- test/gemdev/rakefile_with_multiple_specs/gemspecs/2.gemspec
|
43
|
+
- test/gemdev/rakefile_with_multiple_specs/gemspecs/3.gemspec
|
43
44
|
- test/gemdev/rakefile_with_multiple_specs/lib
|
44
|
-
- test/gemdev/rakefile_with_multiple_specs/Rakefile
|
45
45
|
- test/gemdev/rakefile_with_multiple_specs/lib/multiple_spec_require.rb
|
46
46
|
- test/gemdev/rakefile_with_multiple_specs/lib/unrequired.rb
|
47
|
+
- test/gemdev_test.rb
|
48
|
+
- test/gemdev_test_helper.rb
|
49
|
+
- test/gemdev_test_suite.rb
|
50
|
+
- test/subsets_test.rb
|
47
51
|
- lib/gemdev.rb
|
48
52
|
- lib/test
|
49
53
|
- lib/test/unit
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
require 'rake/gempackagetask'
|
5
|
-
|
6
|
-
#
|
7
|
-
# Gem specification
|
8
|
-
#
|
9
|
-
Gem::manage_gems
|
10
|
-
spec = Gem::Specification.new do |s|
|
11
|
-
s.name = "gem_with_folder_require"
|
12
|
-
s.version = "0.1.1"
|
13
|
-
s.require_path = "lib"
|
14
|
-
s.autorequire = "folder_require"
|
15
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
require 'rake/gempackagetask'
|
5
|
-
|
6
|
-
#
|
7
|
-
# Gem specification
|
8
|
-
#
|
9
|
-
spec = Gem::Specification.new do |s|
|
10
|
-
s.name = "rakefile_with_multiple_specs"
|
11
|
-
s.version = "0.1.2"
|
12
|
-
s.require_path = "lib"
|
13
|
-
s.autorequire = "unrequired"
|
14
|
-
end
|
15
|
-
|
16
|
-
spec = Gem::Specification.new { |s|
|
17
|
-
s.name = "rakefile_with_multiple_specs"
|
18
|
-
s.version = "0.1.3"
|
19
|
-
s.require_path = "lib"
|
20
|
-
s.autorequire = "multiple_spec_require"
|
21
|
-
}
|
22
|
-
|
23
|
-
# out of order
|
24
|
-
spec = Gem::Specification.new do |s|
|
25
|
-
s.name = "rakefile_with_multiple_specs"
|
26
|
-
s.version = "0.1.1"
|
27
|
-
s.require_path = "lib"
|
28
|
-
s.autorequire = "unrequired"
|
29
|
-
end
|