gorp 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +10 -6
- data/gorp.gemspec +1 -1
- data/lib/gorp.rb +0 -45
- data/lib/gorp/commands.rb +35 -10
- data/lib/gorp/env.rb +7 -0
- data/lib/gorp/output.rb +4 -1
- data/lib/gorp/rails.rb +5 -3
- data/lib/gorp/test.rb +37 -3
- data/lib/version.rb +1 -1
- metadata +1 -1
data/README
CHANGED
@@ -16,21 +16,25 @@ Execution instructions:
|
|
16
16
|
This is a library which, among other things, will interpret ARGV. Here's
|
17
17
|
an example based on http://github.com/rubys/awdwr:
|
18
18
|
|
19
|
-
ruby makedepot.rb [VERSION] [restore] [RANGE]... [save]
|
19
|
+
ruby makedepot.rb [VERSION] [bundle] [restore] [RANGE]... [save]
|
20
20
|
|
21
|
-
"
|
22
|
-
|
23
|
-
"VERSION" specifies the Rails version to test. Examples:
|
21
|
+
"VERSION" - specifies the Rails version to test. Examples:
|
24
22
|
edge
|
25
23
|
_2.2.2_
|
26
24
|
~/git
|
27
25
|
|
28
|
-
"
|
26
|
+
"bundle" - bundle this version of rails with each Rails app generated.
|
27
|
+
- if libraries are listed in the RUBYLIB environment variable, they
|
28
|
+
will be added as directories to the Gemfile before making the bundle
|
29
|
+
|
30
|
+
"restore" - restore from snapshot before resuming execution
|
31
|
+
|
32
|
+
"RANGE" - specifies a set of sections to execute. Examples:
|
29
33
|
6.2..6.5
|
30
34
|
7.1-9.5
|
31
35
|
16
|
32
36
|
|
33
|
-
"save"
|
37
|
+
"save" - save snapshot after execution completes
|
34
38
|
|
35
39
|
Tests against the output produced (e.g., makedepot.html) can also be run
|
36
40
|
separately:
|
data/gorp.gemspec
CHANGED
data/lib/gorp.rb
CHANGED
@@ -3,9 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# You have been warned.
|
5
5
|
|
6
|
-
require 'fileutils'
|
7
|
-
require 'builder'
|
8
|
-
|
9
6
|
require 'gorp/env'
|
10
7
|
require 'gorp/commands'
|
11
8
|
require 'gorp/edit'
|
@@ -13,45 +10,3 @@ require 'gorp/output'
|
|
13
10
|
require 'gorp/net'
|
14
11
|
require 'gorp/rails'
|
15
12
|
require 'gorp/xml'
|
16
|
-
|
17
|
-
require 'rbconfig'
|
18
|
-
$ruby = File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])
|
19
|
-
|
20
|
-
# indicate that a given step should be omitted
|
21
|
-
def omit *sections
|
22
|
-
sections.each do |section|
|
23
|
-
section = [section] unless section.respond_to? :include?
|
24
|
-
$omit << Range.new(secsplit(section.first), secsplit(section.last))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Micro DSL for declaring an ordered set of book sections
|
29
|
-
$sections = []
|
30
|
-
def section number, title, &steps
|
31
|
-
number = (sprintf "%f", number).sub(/0+$/,'') if number.kind_of? Float
|
32
|
-
$sections << [number, title, steps]
|
33
|
-
end
|
34
|
-
|
35
|
-
$x = Builder::XmlMarkup.new(:indent => 2)
|
36
|
-
$toc = Builder::XmlMarkup.new(:indent => 2)
|
37
|
-
$todos = Builder::XmlMarkup.new(:indent => 2)
|
38
|
-
$issue = 0
|
39
|
-
$style = Builder::XmlMarkup.new(:indent => 2)
|
40
|
-
$omit = []
|
41
|
-
|
42
|
-
FileUtils.mkdir_p $WORK
|
43
|
-
RUNFILE = File.join($WORK, 'status.run')
|
44
|
-
open(RUNFILE,'w') {|running| running.puts(Process.pid)}
|
45
|
-
at_exit { FileUtils.rm_f RUNFILE }
|
46
|
-
|
47
|
-
def secsplit section
|
48
|
-
section.to_s.split('.').map {|n| n.to_i}
|
49
|
-
end
|
50
|
-
|
51
|
-
def secinclude ranges, section
|
52
|
-
# was (in Ruby 1.8): range.include?(secsplit(section))
|
53
|
-
ranges.any? do |range|
|
54
|
-
ss = secsplit(section)
|
55
|
-
(range.first <=> ss) <= 0 and (range.last <=> ss) >= 0
|
56
|
-
end
|
57
|
-
end
|
data/lib/gorp/commands.rb
CHANGED
@@ -1,9 +1,44 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'builder'
|
2
3
|
require 'open3'
|
3
4
|
require 'time'
|
4
5
|
|
5
6
|
module Gorp
|
6
7
|
module Commands
|
8
|
+
# indicate that a given step should be omitted
|
9
|
+
$omit = []
|
10
|
+
def omit *sections
|
11
|
+
sections.each do |section|
|
12
|
+
section = [section] unless section.respond_to? :include?
|
13
|
+
$omit << Range.new(secsplit(section.first), secsplit(section.last))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Micro DSL for declaring an ordered set of book sections
|
18
|
+
$sections = []
|
19
|
+
def section number, title, &steps
|
20
|
+
number = (sprintf "%f", number).sub(/0+$/,'') if number.kind_of? Float
|
21
|
+
$sections << [number, title, steps]
|
22
|
+
end
|
23
|
+
|
24
|
+
$x = Builder::XmlMarkup.new(:indent => 2)
|
25
|
+
$toc = Builder::XmlMarkup.new(:indent => 2)
|
26
|
+
$todos = Builder::XmlMarkup.new(:indent => 2)
|
27
|
+
$issue = 0
|
28
|
+
$style = Builder::XmlMarkup.new(:indent => 2)
|
29
|
+
|
30
|
+
def secsplit section
|
31
|
+
section.to_s.split('.').map {|n| n.to_i}
|
32
|
+
end
|
33
|
+
|
34
|
+
def secinclude ranges, section
|
35
|
+
# was (in Ruby 1.8): range.include?(secsplit(section))
|
36
|
+
ranges.any? do |range|
|
37
|
+
ss = secsplit(section)
|
38
|
+
(range.first <=> ss) <= 0 and (range.last <=> ss) >= 0
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
7
42
|
def overview message
|
8
43
|
$x.p message.gsub(/(^|\n)\s+/, ' ').strip, :class=>'overview'
|
9
44
|
end
|
@@ -68,9 +103,7 @@ module Gorp
|
|
68
103
|
end
|
69
104
|
|
70
105
|
def cmd args, hilight=[]
|
71
|
-
x = $x
|
72
106
|
log :cmd, args
|
73
|
-
$x = Builder::XmlMarkup.new(:indent => 2) if block_given?
|
74
107
|
$x.pre args, :class=>'stdin'
|
75
108
|
if args == 'rake db:migrate'
|
76
109
|
Dir.chdir 'db/migrate' do
|
@@ -84,14 +117,6 @@ module Gorp
|
|
84
117
|
end
|
85
118
|
args += ' -C' if args == 'ls -p'
|
86
119
|
popen3 args, hilight
|
87
|
-
if block_given?
|
88
|
-
p $x.target!
|
89
|
-
@raw = $x.target!
|
90
|
-
@selected = HTML::Document.new(@raw).root.children
|
91
|
-
yield
|
92
|
-
end
|
93
|
-
ensure
|
94
|
-
$x = x
|
95
120
|
end
|
96
121
|
|
97
122
|
def popen3 args, hilight=[]
|
data/lib/gorp/env.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
# determine port
|
2
4
|
if ARGV.find {|arg| arg =~ /--port=(\d+)/}
|
3
5
|
$PORT=$1.to_i
|
@@ -17,3 +19,8 @@ if (work=ARGV.find {|arg| arg =~ /--work=(.*)/})
|
|
17
19
|
else
|
18
20
|
$WORK = File.join($BASE, ENV['GORP_WORK'] || 'work')
|
19
21
|
end
|
22
|
+
|
23
|
+
require 'rbconfig'
|
24
|
+
$ruby = File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])
|
25
|
+
|
26
|
+
FileUtils.mkdir_p $WORK
|
data/lib/gorp/output.rb
CHANGED
@@ -3,6 +3,9 @@ require 'time'
|
|
3
3
|
|
4
4
|
at_exit do
|
5
5
|
next unless $output
|
6
|
+
RUNFILE = File.join($WORK, 'status.run')
|
7
|
+
open(RUNFILE,'w') {|running| running.puts(Process.pid)}
|
8
|
+
at_exit { FileUtils.rm_f RUNFILE }
|
6
9
|
|
7
10
|
$x.declare! :DOCTYPE, :html
|
8
11
|
$x.html :xmlns => 'http://www.w3.org/1999/xhtml' do
|
@@ -10,7 +13,7 @@ at_exit do
|
|
10
13
|
$x.title $title
|
11
14
|
$x.meta 'http-equiv'=>'text/html; charset=UTF-8'
|
12
15
|
$x.style :type => "text/css" do
|
13
|
-
$x.text! <<-'EOF'.
|
16
|
+
$x.text! <<-'EOF'.gsub(/^ /, '')
|
14
17
|
body {background-color: #F5F5DC}
|
15
18
|
#banner {margin-top: 0}
|
16
19
|
pre {font-weight: bold; margin: 0; padding: 0}
|
data/lib/gorp/rails.rb
CHANGED
@@ -41,6 +41,8 @@ else
|
|
41
41
|
Process.exit!
|
42
42
|
end
|
43
43
|
|
44
|
+
$bundle = ARGV.include? 'bundle'
|
45
|
+
|
44
46
|
module Gorp
|
45
47
|
# determine which version of rails is running
|
46
48
|
def self.which_rails rails
|
@@ -63,7 +65,7 @@ module Gorp
|
|
63
65
|
# determine how to invoke rails
|
64
66
|
rails = Gorp.which_rails $rails
|
65
67
|
|
66
|
-
opt = (
|
68
|
+
opt = ($bundle ? ' --dev' : '')
|
67
69
|
$x.pre "#{rails} #{name}#{opt}", :class=>'stdin'
|
68
70
|
popen3 "#{rails} #{name}#{opt}"
|
69
71
|
|
@@ -83,7 +85,7 @@ module Gorp
|
|
83
85
|
|
84
86
|
if $rails != 'rails' and File.directory?($rails)
|
85
87
|
if File.exist? 'Gemfile'
|
86
|
-
if
|
88
|
+
if $bundle
|
87
89
|
if ENV['RUBYLIB']
|
88
90
|
gem=open('Gemfile') {|file| file.read}
|
89
91
|
|
@@ -106,7 +108,7 @@ module Gorp
|
|
106
108
|
cmd 'gem bundle'
|
107
109
|
else
|
108
110
|
system 'mkdir -p vendor/gems'
|
109
|
-
|
111
|
+
cmd "ln -s #{$rails} vendor/rails"
|
110
112
|
system "cp #{__FILE__.sub(/\.rb$/,'.env')} " +
|
111
113
|
"vendor/gems/environment.rb"
|
112
114
|
end
|
data/lib/gorp/test.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'builder'
|
3
3
|
require 'gorp/env'
|
4
|
+
require 'gorp/rails'
|
5
|
+
require 'gorp/commands'
|
4
6
|
|
5
7
|
$:.unshift "#{$WORK}/rails/activesupport/lib"
|
6
8
|
require 'active_support'
|
@@ -9,6 +11,17 @@ $:.unshift "#{$WORK}/rails/activesupport/lib"
|
|
9
11
|
$:.shift
|
10
12
|
|
11
13
|
module Gorp
|
14
|
+
class BuilderTee < BlankSlate
|
15
|
+
def initialize(one, two)
|
16
|
+
@one = one
|
17
|
+
@two = two
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing sym, *args, &block
|
21
|
+
@one.method_missing sym, *args, &block
|
22
|
+
@two.method_missing sym, *args, &block
|
23
|
+
end
|
24
|
+
end
|
12
25
|
end
|
13
26
|
|
14
27
|
class Gorp::TestCase < ActiveSupport::TestCase
|
@@ -87,9 +100,9 @@ class Gorp::TestCase < ActiveSupport::TestCase
|
|
87
100
|
# report version
|
88
101
|
body =~ /rails .*?-v<\/pre>\s+.*?>(.*)<\/pre>/
|
89
102
|
@@version = $1
|
90
|
-
@@version += ' (git)'
|
91
|
-
@@version += ' (edge)'
|
92
|
-
@@version += ' (bundle)' if body =~ /gem bundle
|
103
|
+
@@version += ' (git)' if body =~ /"stdin">ln -s.*vendor.rails</
|
104
|
+
@@version += ' (edge)' if body =~ /"stdin">rails:freeze:edge</
|
105
|
+
@@version += ' (bundle)' if body =~ /"stdin">gem bundle</
|
93
106
|
STDERR.puts @@version
|
94
107
|
end
|
95
108
|
|
@@ -121,6 +134,27 @@ class Gorp::TestCase < ActiveSupport::TestCase
|
|
121
134
|
|
122
135
|
def self.sections
|
123
136
|
@@sections
|
137
|
+
end
|
138
|
+
|
139
|
+
@@base = Object.new.extend(Gorp::Commands)
|
140
|
+
include Gorp::Commands
|
141
|
+
|
142
|
+
%w(cmd rake).each do |method|
|
143
|
+
define_method(method) do |*args, &block|
|
144
|
+
begin
|
145
|
+
$y = Builder::XmlMarkup.new(:indent => 2)
|
146
|
+
$x = Gorp::BuilderTee.new($x, $y)
|
147
|
+
@@base.send method, *args
|
148
|
+
|
149
|
+
if block
|
150
|
+
@raw = $x.target!
|
151
|
+
@selected = HTML::Document.new(@raw).root.children
|
152
|
+
block.call
|
153
|
+
end
|
154
|
+
ensure
|
155
|
+
$x = $x.instance_eval { @one }
|
156
|
+
end
|
157
|
+
end
|
124
158
|
end
|
125
159
|
end
|
126
160
|
|
data/lib/version.rb
CHANGED