piston 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/History.txt +4 -0
- data/Rakefile +25 -0
- data/TODO +6 -0
- data/VERSION.yml +2 -2
- data/features/import_to_git.feature +56 -0
- data/features/import_to_svn.feature +54 -0
- data/features/step_definitions/repository.rb +213 -0
- data/features/support/env.rb +27 -0
- data/features/support/svn.rb +23 -0
- data/features/update_to_git.feature +137 -0
- data/features/update_to_svn.feature +137 -0
- data/lib/piston/commands/lock.rb +14 -0
- data/lib/piston/commands/lock_unlock.rb +0 -5
- data/lib/piston/commands/unlock.rb +14 -0
- data/lib/piston/git/commit.rb +1 -0
- data/lib/piston/svn/revision.rb +1 -0
- data/log/.gitignore +0 -0
- data/piston.gemspec +184 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/environment.rake +7 -0
- data/tasks/features.rake +6 -0
- data/tasks/manifest.rake +4 -0
- data/tasks/test.rake +62 -0
- data/tasks/website.rake +20 -0
- metadata +75 -26
@@ -0,0 +1,137 @@
|
|
1
|
+
Feature: Updating from a remote Subversion repository
|
2
|
+
In order to be on the cutting edge and benefit from bug fixes
|
3
|
+
A developer
|
4
|
+
Wants to update his pistonised repositories
|
5
|
+
So that he keeps abreast of upstream changes
|
6
|
+
|
7
|
+
Scenario: Updating from a Subversion repository when there are no changes
|
8
|
+
Given a newly created Subversion project
|
9
|
+
And a remote Subversion project named libcalc
|
10
|
+
And I imported libcalc
|
11
|
+
And I committed
|
12
|
+
When I update libcalc
|
13
|
+
Then I should see "Upstream .*/libcalc was unchanged from revision \d+"
|
14
|
+
|
15
|
+
Scenario: Updating from a Subversion repository when a file was added
|
16
|
+
Given a newly created Subversion project
|
17
|
+
And a remote Subversion project named libcalc
|
18
|
+
And a file named libcalc.rb with content "a" in remote libcalc project
|
19
|
+
And I imported libcalc
|
20
|
+
And I committed
|
21
|
+
And a file named libcomplex.rb with content "b" in remote libcalc project
|
22
|
+
When I update libcalc
|
23
|
+
Then I should see a successful update message from Piston
|
24
|
+
And I should find a libcalc/libcomplex.rb file
|
25
|
+
|
26
|
+
Scenario: Updating from a Subversion repository when a file was removed
|
27
|
+
Given a newly created Subversion project
|
28
|
+
And a remote Subversion project named libcalc
|
29
|
+
And a file named libcalc.rb with content "a" in remote libcalc project
|
30
|
+
And I imported libcalc
|
31
|
+
And I committed
|
32
|
+
And a file named libcalc.rb was deleted in remote libcalc project
|
33
|
+
When I update libcalc
|
34
|
+
Then I should see a successful update message from Piston
|
35
|
+
And I should not find a libcalc/libcalc.rb file
|
36
|
+
|
37
|
+
Scenario: Updating from a Subversion repository when a file was updated
|
38
|
+
Given a newly created Subversion project
|
39
|
+
And a remote Subversion project named libcalc
|
40
|
+
And a file named libcalc.rb with content "a" in remote libcalc project
|
41
|
+
And I imported libcalc
|
42
|
+
And I committed
|
43
|
+
And a file named libcalc.rb was updated with "a\nb\nc" in remote libcalc project
|
44
|
+
When I update libcalc
|
45
|
+
Then I should see a successful update message from Piston
|
46
|
+
And I should find a libcalc/libcalc.rb file
|
47
|
+
And I should find "a\nb\nc" in libcalc/libcalc.rb
|
48
|
+
|
49
|
+
Scenario: Updating from a Subversion repository when a file was moved
|
50
|
+
Given a newly created Subversion project
|
51
|
+
And a remote Subversion project named libcalc
|
52
|
+
And a file named libcalc.rb with content "a" in remote libcalc project
|
53
|
+
And I imported libcalc
|
54
|
+
And I committed
|
55
|
+
And a file named libcalc.rb was renamed to libcomplex.rb in remote libcalc project
|
56
|
+
When I update libcalc
|
57
|
+
Then I should see a successful update message from Piston
|
58
|
+
And I should not find a libcalc/libcalc.rb file
|
59
|
+
And I should find a libcalc/libcomplex.rb file
|
60
|
+
|
61
|
+
Scenario: Updating from a Git repository when there are no changes
|
62
|
+
Given a newly created Subversion project
|
63
|
+
And a remote Git project named libcalc
|
64
|
+
And I imported libcalc
|
65
|
+
And I committed
|
66
|
+
When I update libcalc
|
67
|
+
Then I should see "Upstream .*/libcalc.git was unchanged from commit [a-fA-F0-9]+"
|
68
|
+
|
69
|
+
Scenario: Updating from a Git repository when a file was added
|
70
|
+
Given a newly created Subversion project
|
71
|
+
And a remote Git project named libcalc
|
72
|
+
And a file named libcalc.rb with content "a" in remote libcalc project
|
73
|
+
And I imported libcalc
|
74
|
+
And I committed
|
75
|
+
And a file named libcomplex.rb with content "b" in remote libcalc project
|
76
|
+
When I update libcalc
|
77
|
+
Then I should see a successful update message from Piston
|
78
|
+
And I should find a libcalc/libcomplex.rb file
|
79
|
+
|
80
|
+
Scenario: Updating from a Git repository when a file was removed
|
81
|
+
Given a newly created Subversion project
|
82
|
+
And a remote Git project named libcalc
|
83
|
+
And a file named libcalc.rb with content "a" in remote libcalc project
|
84
|
+
And I imported libcalc
|
85
|
+
And I committed
|
86
|
+
And a file named libcalc.rb was deleted in remote libcalc project
|
87
|
+
When I update libcalc
|
88
|
+
Then I should see a successful update message from Piston
|
89
|
+
And I should not find a libcalc/libcalc.rb file
|
90
|
+
|
91
|
+
Scenario: Updating from a Git repository when a file was updated
|
92
|
+
Given a newly created Subversion project
|
93
|
+
And a remote Git project named libcalc
|
94
|
+
And a file named libcalc.rb with content "a" in remote libcalc project
|
95
|
+
And I imported libcalc
|
96
|
+
And I committed
|
97
|
+
And a file named libcalc.rb was updated with "a\nb\nc" in remote libcalc project
|
98
|
+
When I update libcalc
|
99
|
+
Then I should see a successful update message from Piston
|
100
|
+
And I should find a libcalc/libcalc.rb file
|
101
|
+
And I should find "a\nb\nc" in libcalc/libcalc.rb
|
102
|
+
|
103
|
+
Scenario: Updating from a Git repository when a file was moved
|
104
|
+
Given a newly created Subversion project
|
105
|
+
And a remote Git project named libcalc
|
106
|
+
And a file named libcalc.rb with content "a" in remote libcalc project
|
107
|
+
And I imported libcalc
|
108
|
+
And I committed
|
109
|
+
And a file named libcalc.rb was renamed to libcomplex.rb in remote libcalc project
|
110
|
+
When I update libcalc
|
111
|
+
Then I should see a successful update message from Piston
|
112
|
+
And I should not find a libcalc/libcalc.rb file
|
113
|
+
And I should find a libcalc/libcomplex.rb file
|
114
|
+
|
115
|
+
Scenario: Updating from a Subversion repository when both local and remote changes have occured
|
116
|
+
Given a newly created Subversion project
|
117
|
+
And a remote Subversion project named libcalc
|
118
|
+
And a file named libcalc.rb with content "a\nb\nc\nd\ne" in remote libcalc project
|
119
|
+
And I imported libcaclc
|
120
|
+
And I committed
|
121
|
+
And a file named libcalc.rb was updated with "a\na\nb\nc\nd\ne" in remote libcalc project
|
122
|
+
And I changed libcalc/libcalc.rb to "a\nb\nc\nd\ne\ne"
|
123
|
+
When I update libcalc
|
124
|
+
Then I should see a successful update message from Piston
|
125
|
+
And I should find "a\na\nb\nc\nd\ne\ne" in libcalc/libcalc.rb
|
126
|
+
|
127
|
+
Scenario: Updating from a Git repository when both local and remote changes have occured
|
128
|
+
Given a newly created Subversion project
|
129
|
+
And a remote Git project named libcalc
|
130
|
+
And a file named libcalc.rb with content "a\nb\nc\nd\ne" in remote libcalc project
|
131
|
+
And I imported libcaclc
|
132
|
+
And I committed
|
133
|
+
And a file named libcalc.rb was updated with "a\na\nb\nc\nd\ne" in remote libcalc project
|
134
|
+
And I changed libcalc/libcalc.rb to "a\nb\nc\nd\ne\ne"
|
135
|
+
When I update libcalc
|
136
|
+
Then I should see a successful update message from Piston
|
137
|
+
And I should find "a\na\nb\nc\nd\ne\ne" in libcalc/libcalc.rb
|
data/lib/piston/git/commit.rb
CHANGED
data/lib/piston/svn/revision.rb
CHANGED
data/log/.gitignore
ADDED
File without changes
|
data/piston.gemspec
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{piston}
|
5
|
+
s.version = "2.0.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Francois Beausoleil"]
|
9
|
+
s.date = %q{2009-07-17}
|
10
|
+
s.default_executable = %q{piston}
|
11
|
+
s.description = %q{Piston makes it easy to merge vendor branches into your own repository, without worrying about which revisions were grabbed or not. Piston will also keep your local changes in addition to the remote changes.}
|
12
|
+
s.email = %q{francois@teksol.info}
|
13
|
+
s.executables = ["piston"]
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README.txt"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
".gitignore",
|
19
|
+
"History.txt",
|
20
|
+
"License.txt",
|
21
|
+
"Manifest.txt",
|
22
|
+
"README.txt",
|
23
|
+
"Rakefile",
|
24
|
+
"TODO",
|
25
|
+
"VERSION.yml",
|
26
|
+
"bin/piston",
|
27
|
+
"features/import_to_git.feature",
|
28
|
+
"features/import_to_svn.feature",
|
29
|
+
"features/step_definitions/repository.rb",
|
30
|
+
"features/support/env.rb",
|
31
|
+
"features/support/svn.rb",
|
32
|
+
"features/update_to_git.feature",
|
33
|
+
"features/update_to_svn.feature",
|
34
|
+
"lib/piston.rb",
|
35
|
+
"lib/piston/cli.rb",
|
36
|
+
"lib/piston/commands.rb",
|
37
|
+
"lib/piston/commands/base.rb",
|
38
|
+
"lib/piston/commands/convert.rb",
|
39
|
+
"lib/piston/commands/diff.rb",
|
40
|
+
"lib/piston/commands/import.rb",
|
41
|
+
"lib/piston/commands/info.rb",
|
42
|
+
"lib/piston/commands/lock.rb",
|
43
|
+
"lib/piston/commands/lock_unlock.rb",
|
44
|
+
"lib/piston/commands/status.rb",
|
45
|
+
"lib/piston/commands/unlock.rb",
|
46
|
+
"lib/piston/commands/update.rb",
|
47
|
+
"lib/piston/commands/upgrade.rb",
|
48
|
+
"lib/piston/git.rb",
|
49
|
+
"lib/piston/git/client.rb",
|
50
|
+
"lib/piston/git/commit.rb",
|
51
|
+
"lib/piston/git/repository.rb",
|
52
|
+
"lib/piston/git/working_copy.rb",
|
53
|
+
"lib/piston/repository.rb",
|
54
|
+
"lib/piston/revision.rb",
|
55
|
+
"lib/piston/svn.rb",
|
56
|
+
"lib/piston/svn/client.rb",
|
57
|
+
"lib/piston/svn/repository.rb",
|
58
|
+
"lib/piston/svn/revision.rb",
|
59
|
+
"lib/piston/svn/working_copy.rb",
|
60
|
+
"lib/piston/version.rb",
|
61
|
+
"lib/piston/working_copy.rb",
|
62
|
+
"lib/subclass_responsibility_error.rb",
|
63
|
+
"log/.gitignore",
|
64
|
+
"piston.gemspec",
|
65
|
+
"script/destroy",
|
66
|
+
"script/generate",
|
67
|
+
"script/txt2html",
|
68
|
+
"setup.rb",
|
69
|
+
"tasks/environment.rake",
|
70
|
+
"tasks/features.rake",
|
71
|
+
"tasks/manifest.rake",
|
72
|
+
"tasks/test.rake",
|
73
|
+
"tasks/website.rake",
|
74
|
+
"test/integration_helpers.rb",
|
75
|
+
"test/spec_suite.rb",
|
76
|
+
"test/test_helper.rb",
|
77
|
+
"test/unit/git/commit/test_checkout.rb",
|
78
|
+
"test/unit/git/commit/test_each.rb",
|
79
|
+
"test/unit/git/commit/test_rememberance.rb",
|
80
|
+
"test/unit/git/commit/test_validation.rb",
|
81
|
+
"test/unit/git/repository/test_at.rb",
|
82
|
+
"test/unit/git/repository/test_basename.rb",
|
83
|
+
"test/unit/git/repository/test_branchanme.rb",
|
84
|
+
"test/unit/git/repository/test_guessing.rb",
|
85
|
+
"test/unit/git/working_copy/test_copying.rb",
|
86
|
+
"test/unit/git/working_copy/test_creation.rb",
|
87
|
+
"test/unit/git/working_copy/test_existence.rb",
|
88
|
+
"test/unit/git/working_copy/test_finalization.rb",
|
89
|
+
"test/unit/git/working_copy/test_guessing.rb",
|
90
|
+
"test/unit/git/working_copy/test_rememberance.rb",
|
91
|
+
"test/unit/svn/repository/test_at.rb",
|
92
|
+
"test/unit/svn/repository/test_basename.rb",
|
93
|
+
"test/unit/svn/repository/test_guessing.rb",
|
94
|
+
"test/unit/svn/revision/test_checkout.rb",
|
95
|
+
"test/unit/svn/revision/test_each.rb",
|
96
|
+
"test/unit/svn/revision/test_rememberance.rb",
|
97
|
+
"test/unit/svn/revision/test_validation.rb",
|
98
|
+
"test/unit/svn/working_copy/test_copying.rb",
|
99
|
+
"test/unit/svn/working_copy/test_creation.rb",
|
100
|
+
"test/unit/svn/working_copy/test_existence.rb",
|
101
|
+
"test/unit/svn/working_copy/test_externals.rb",
|
102
|
+
"test/unit/svn/working_copy/test_finalization.rb",
|
103
|
+
"test/unit/svn/working_copy/test_guessing.rb",
|
104
|
+
"test/unit/svn/working_copy/test_rememberance.rb",
|
105
|
+
"test/unit/test_info.rb",
|
106
|
+
"test/unit/test_lock_unlock.rb",
|
107
|
+
"test/unit/test_repository.rb",
|
108
|
+
"test/unit/test_revision.rb",
|
109
|
+
"test/unit/working_copy/test_guessing.rb",
|
110
|
+
"test/unit/working_copy/test_info.rb",
|
111
|
+
"test/unit/working_copy/test_rememberance.rb",
|
112
|
+
"test/unit/working_copy/test_validate.rb",
|
113
|
+
"tmp/.gitignore"
|
114
|
+
]
|
115
|
+
s.homepage = %q{http://francois.github.com/piston}
|
116
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
117
|
+
s.require_paths = ["lib"]
|
118
|
+
s.rubyforge_project = %q{piston}
|
119
|
+
s.rubygems_version = %q{1.3.2}
|
120
|
+
s.summary = %q{Ease your vendor branch management worries}
|
121
|
+
s.test_files = [
|
122
|
+
"test/integration_helpers.rb",
|
123
|
+
"test/spec_suite.rb",
|
124
|
+
"test/test_helper.rb",
|
125
|
+
"test/unit/git/commit/test_checkout.rb",
|
126
|
+
"test/unit/git/commit/test_each.rb",
|
127
|
+
"test/unit/git/commit/test_rememberance.rb",
|
128
|
+
"test/unit/git/commit/test_validation.rb",
|
129
|
+
"test/unit/git/repository/test_at.rb",
|
130
|
+
"test/unit/git/repository/test_basename.rb",
|
131
|
+
"test/unit/git/repository/test_branchanme.rb",
|
132
|
+
"test/unit/git/repository/test_guessing.rb",
|
133
|
+
"test/unit/git/working_copy/test_copying.rb",
|
134
|
+
"test/unit/git/working_copy/test_creation.rb",
|
135
|
+
"test/unit/git/working_copy/test_existence.rb",
|
136
|
+
"test/unit/git/working_copy/test_finalization.rb",
|
137
|
+
"test/unit/git/working_copy/test_guessing.rb",
|
138
|
+
"test/unit/git/working_copy/test_rememberance.rb",
|
139
|
+
"test/unit/svn/repository/test_at.rb",
|
140
|
+
"test/unit/svn/repository/test_basename.rb",
|
141
|
+
"test/unit/svn/repository/test_guessing.rb",
|
142
|
+
"test/unit/svn/revision/test_checkout.rb",
|
143
|
+
"test/unit/svn/revision/test_each.rb",
|
144
|
+
"test/unit/svn/revision/test_rememberance.rb",
|
145
|
+
"test/unit/svn/revision/test_validation.rb",
|
146
|
+
"test/unit/svn/working_copy/test_copying.rb",
|
147
|
+
"test/unit/svn/working_copy/test_creation.rb",
|
148
|
+
"test/unit/svn/working_copy/test_existence.rb",
|
149
|
+
"test/unit/svn/working_copy/test_externals.rb",
|
150
|
+
"test/unit/svn/working_copy/test_finalization.rb",
|
151
|
+
"test/unit/svn/working_copy/test_guessing.rb",
|
152
|
+
"test/unit/svn/working_copy/test_rememberance.rb",
|
153
|
+
"test/unit/test_info.rb",
|
154
|
+
"test/unit/test_lock_unlock.rb",
|
155
|
+
"test/unit/test_repository.rb",
|
156
|
+
"test/unit/test_revision.rb",
|
157
|
+
"test/unit/working_copy/test_guessing.rb",
|
158
|
+
"test/unit/working_copy/test_info.rb",
|
159
|
+
"test/unit/working_copy/test_rememberance.rb",
|
160
|
+
"test/unit/working_copy/test_validate.rb"
|
161
|
+
]
|
162
|
+
|
163
|
+
if s.respond_to? :specification_version then
|
164
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
165
|
+
s.specification_version = 3
|
166
|
+
|
167
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
168
|
+
s.add_development_dependency(%q<cucumber>, [">= 0.1.16"])
|
169
|
+
s.add_runtime_dependency(%q<main>, [">= 2.8.3"])
|
170
|
+
s.add_runtime_dependency(%q<log4r>, [">= 1.0.5"])
|
171
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.0.0"])
|
172
|
+
else
|
173
|
+
s.add_dependency(%q<cucumber>, [">= 0.1.16"])
|
174
|
+
s.add_dependency(%q<main>, [">= 2.8.3"])
|
175
|
+
s.add_dependency(%q<log4r>, [">= 1.0.5"])
|
176
|
+
s.add_dependency(%q<activesupport>, [">= 2.0.0"])
|
177
|
+
end
|
178
|
+
else
|
179
|
+
s.add_dependency(%q<cucumber>, [">= 0.1.16"])
|
180
|
+
s.add_dependency(%q<main>, [">= 2.8.3"])
|
181
|
+
s.add_dependency(%q<log4r>, [">= 1.0.5"])
|
182
|
+
s.add_dependency(%q<activesupport>, [">= 2.0.0"])
|
183
|
+
end
|
184
|
+
end
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
begin
|
5
|
+
require 'newgem'
|
6
|
+
rescue LoadError
|
7
|
+
puts "\n\nGenerating the website requires the newgem RubyGem"
|
8
|
+
puts "Install: gem install newgem\n\n"
|
9
|
+
exit(1)
|
10
|
+
end
|
11
|
+
require 'redcloth'
|
12
|
+
require 'syntax/convertors/html'
|
13
|
+
require 'erb'
|
14
|
+
require File.dirname(__FILE__) + '/../lib/piston/version.rb'
|
15
|
+
|
16
|
+
version = Piston::VERSION::STRING
|
17
|
+
download = 'http://rubyforge.org/projects/piston'
|
18
|
+
|
19
|
+
class Fixnum
|
20
|
+
def ordinal
|
21
|
+
# teens
|
22
|
+
return 'th' if (10..19).include?(self % 100)
|
23
|
+
# others
|
24
|
+
case self % 10
|
25
|
+
when 1: return 'st'
|
26
|
+
when 2: return 'nd'
|
27
|
+
when 3: return 'rd'
|
28
|
+
else return 'th'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Time
|
34
|
+
def pretty
|
35
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def convert_syntax(syntax, source)
|
40
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
41
|
+
end
|
42
|
+
|
43
|
+
if ARGV.length >= 1
|
44
|
+
src, template = ARGV
|
45
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
|
46
|
+
|
47
|
+
else
|
48
|
+
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
49
|
+
exit!
|
50
|
+
end
|
51
|
+
|
52
|
+
template = ERB.new(File.open(template).read)
|
53
|
+
|
54
|
+
title = nil
|
55
|
+
body = nil
|
56
|
+
File.open(src) do |fsrc|
|
57
|
+
title_text = fsrc.readline
|
58
|
+
body_text = fsrc.read
|
59
|
+
syntax_items = []
|
60
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
61
|
+
ident = syntax_items.length
|
62
|
+
element, syntax, source = $1, $2, $3
|
63
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
64
|
+
"syntax-temp-#{ident}"
|
65
|
+
}
|
66
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
67
|
+
body = RedCloth.new(body_text).to_html
|
68
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
69
|
+
end
|
70
|
+
stat = File.stat(src)
|
71
|
+
created = stat.ctime
|
72
|
+
modified = stat.mtime
|
73
|
+
|
74
|
+
$stdout << template.result(binding)
|