wikitext 2.1.1 → 3.0b

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.
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2010 Wincent Colaiuta. All rights reserved.
1
+ # Copyright 2008-2011 Wincent Colaiuta. All rights reserved.
2
2
  #
3
3
  # Redistribution and use in source and binary forms, with or without
4
4
  # modification, are permitted provided that the following conditions are met:
@@ -27,29 +27,11 @@ require 'wikitext/string'
27
27
  module ActionView
28
28
  class Template
29
29
  module Handlers
30
-
31
- begin
32
-
33
- # assume Rails 3
34
- class Wikitext < Handler
35
- include Compilable
36
-
37
- def compile template
38
- "'" + template.source.w.gsub("'", "\\\\'") + "'"
39
- end
40
- end # class Wikitext
41
-
42
- rescue NameError
43
-
44
- # fall back to Rails 2
45
- class Wikitext
46
- def self.call template
47
- 'template.source.w'
48
- end
49
- end # class Wikitext
50
-
51
- end
52
-
30
+ class Wikitext
31
+ def self.call template
32
+ "'" + template.source.w.gsub("'", "\\\\'") + "'"
33
+ end
34
+ end # class Wikitext
53
35
  end # module Handlers
54
36
  end # class Template
55
37
  end # module ActionView
@@ -1,4 +1,4 @@
1
- # Copyright 2007-2010 Wincent Colaiuta. All rights reserved.
1
+ # Copyright 2007-2011 Wincent Colaiuta. All rights reserved.
2
2
  #
3
3
  # Redistribution and use in source and binary forms, with or without
4
4
  # modification, are permitted provided that the following conditions are met:
@@ -22,5 +22,5 @@
22
22
  # POSSIBILITY OF SUCH DAMAGE.
23
23
 
24
24
  module Wikitext
25
- VERSION = '2.1.1'
25
+ VERSION = '3.0b'
26
26
  end # module Wikitext
data/spec/rails_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2009-2010 Wincent Colaiuta. All rights reserved.
1
+ # Copyright 2009-2011 Wincent Colaiuta. All rights reserved.
2
2
  #
3
3
  # Redistribution and use in source and binary forms, with or without
4
4
  # modification, are permitted provided that the following conditions are met:
@@ -26,93 +26,80 @@ require 'wikitext/version'
26
26
  require 'fileutils'
27
27
  require 'pathname'
28
28
  require 'wopen3'
29
- require 'ostruct'
30
29
 
31
30
  module RailsSpecs
32
- TRASH_PATH = Pathname.new(__FILE__).dirname + 'trash'
33
- CLONE_PATH = TRASH_PATH + 'rails.git'
34
- RAILS2_BIN_PATH = CLONE_PATH + 'railties' + 'bin' + 'rails'
35
- RAILS3_BIN_PATH = CLONE_PATH + 'bin' + 'rails'
31
+ TRASH_PATH = Pathname.new(__FILE__).dirname + '.trash'
32
+ AREL_CLONE_PATH = TRASH_PATH + 'arel.git'
33
+ AREL_REPO = 'git://github.com/rails/arel.git'
34
+ RAILS_CLONE_PATH = TRASH_PATH + 'rails.git'
35
+ RAILS_REPO = 'git://github.com/rails/rails.git'
36
36
  WIKITEXT_GEM_PATH = TRASH_PATH + '..' + '..'
37
37
  SUCCESSFUL_TEST_RESULT = /1 tests, 3 assertions, 0 failures, 0 errors/
38
38
 
39
39
  def run cmd, *args
40
- result = OpenStruct.new
41
- result.stdout = ''
42
- result.stderr = ''
43
- Wopen3.popen3(*([cmd] + args)) do |stdin, stdout, stderr|
44
- threads = []
45
- threads << Thread.new(stdout) do |out|
46
- out.each { |line| result.stdout << line }
47
- end
48
- threads << Thread.new(stderr) do |err|
49
- err.each { |line| result.stderr << line }
50
- end
51
- threads.each { |thread| thread.join }
52
- end
53
- status = $?.exitstatus
54
- if status != 0
40
+ result = Wopen3.system(*([cmd] + args))
41
+ if result.status != 0
55
42
  command_string = ([cmd] + args).join(' ')
56
- puts "\n*** COMMAND #{command_string} EXITED WITH NON-ZERO EXIT STATUS (#{status})"
43
+ puts "\n*** COMMAND #{command_string} EXITED WITH NON-ZERO EXIT STATUS (#{result.status})"
57
44
  puts "*** STDOUT FOR COMMAND #{command_string}:", result.stdout
58
45
  puts "*** STDERR FOR COMMAND #{command_string}:", result.stderr
59
- raise "non-zero exit status (#{status}) for '#{cmd}'"
46
+ raise "non-zero exit status (#{result.status}) for '#{command_string}'"
60
47
  end
61
48
  result
62
49
  end
63
50
 
64
- def clone
65
- if File.exist? CLONE_PATH
66
- FileUtils.cd CLONE_PATH do
51
+ def clone repo, path
52
+ if File.exist? path
53
+ FileUtils.cd path do
67
54
  run 'git', 'fetch'
68
55
  end
69
56
  else
70
- run 'git', 'clone', 'git://github.com/rails/rails.git', CLONE_PATH
57
+ run 'git', 'clone', repo, path
71
58
  end
72
59
  end
73
60
 
74
61
  def app_path version
75
62
  version = 'edge' if version.nil?
76
- version = "v#{version}" if version =~ /\A3\./
63
+ version = "v#{version}" if version =~ /\A\d\./
77
64
  TRASH_PATH + "#{version}-app"
78
65
  end
79
66
 
80
- def create_rails2_app version
81
- app = app_path version
82
- clone
83
- FileUtils.rm_r(app) if File.exist?(app)
84
- FileUtils.cd CLONE_PATH do
85
- run 'git', 'checkout', '-f', "v#{version}"
67
+ # if version is nil will create an "Edge" app
68
+ def create_rails3_app rails_version, arel_version = nil
69
+ app = app_path rails_version
70
+ clone AREL_REPO, AREL_CLONE_PATH
71
+ FileUtils.cd AREL_CLONE_PATH do
72
+ if arel_version
73
+ run 'git', 'reset', '--hard', "v#{arel_version}"
74
+ else # "Edge"
75
+ run 'git', 'reset', '--hard', 'origin/master'
76
+ end
86
77
  run 'git', 'clean', '-f'
87
78
  end
88
- run 'ruby', RAILS2_BIN_PATH, app
89
- vendor = app + 'vendor'
90
- gems = vendor + 'gems'
91
- FileUtils.cd vendor do
92
- FileUtils.ln_s '../../rails.git', 'rails'
93
- end
94
- FileUtils.mkdir gems
95
- FileUtils.cd gems do
96
- FileUtils.ln_s '../../../../..', "wikitext-#{Wikitext::VERSION}"
97
- end
98
- end
99
79
 
100
- # if version is nil will create an "Edge" app
101
- def create_rails3_app version
102
- app = app_path version
103
- clone
104
- FileUtils.rm_r(app) if File.exist?(app)
105
- FileUtils.cd CLONE_PATH do
106
- if version
107
- run 'git', 'checkout', '-f', "v#{version}"
80
+ clone RAILS_REPO, RAILS_CLONE_PATH
81
+ FileUtils.cd RAILS_CLONE_PATH do
82
+ if rails_version
83
+ run 'git', 'reset', '--hard', "v#{rails_version}"
108
84
  else # "Edge"
109
- run 'git', 'checkout', '-f', 'master'
110
- run 'git', 'merge', 'origin/master'
85
+ run 'git', 'reset', '--hard', 'origin/master'
111
86
  end
112
87
  run 'git', 'clean', '-f'
88
+
89
+ begin
90
+ clean_bundler_environment
91
+ run 'env', "AREL=#{AREL_CLONE_PATH}",
92
+ 'bundle', 'install', '--path', '../bundle', '--without', 'db'
93
+ FileUtils.rm_r(app) if File.exist?(app)
94
+ run 'env', "AREL=#{AREL_CLONE_PATH}",
95
+ 'bundle', 'exec', 'bin/rails', 'new', app, '--skip-activerecord', '--dev'
96
+ ensure
97
+ restore_bundler_environment
98
+ end
113
99
  end
114
- run 'ruby', RAILS3_BIN_PATH, 'new', app, '--skip-activerecord', '--dev'
100
+
115
101
  create_gemfile app
102
+ bundlerize app
116
103
  end
117
104
 
118
105
  def insert text, after, infile
@@ -129,12 +116,6 @@ module RailsSpecs
129
116
  raise "text '#{after}' not found" unless found
130
117
  end
131
118
 
132
- # Rails 2 only
133
- def add_text_to_initializer text, infile
134
- insert text, 'Rails::Initializer.run do', infile
135
- end
136
-
137
- # Rails 3 only
138
119
  def add_text_to_routes text, infile
139
120
  insert text, 'Application.routes.draw', infile
140
121
  end
@@ -142,12 +123,25 @@ module RailsSpecs
142
123
  def create_gemfile app
143
124
  File.open(app + 'Gemfile', 'w') do |f|
144
125
  f.write <<-GEMFILE
145
- gem 'rails', :path => "#{CLONE_PATH.realpath}"
126
+ source :rubygems
127
+ gem 'arel', :path => "#{AREL_CLONE_PATH.realpath}"
128
+ gem 'rake'
129
+ gem 'rails', :path => "#{RAILS_CLONE_PATH.realpath}"
130
+ gem 'sqlite3'
146
131
  gem 'wikitext', :path => "#{WIKITEXT_GEM_PATH.realpath}"
147
132
  GEMFILE
148
133
  end
149
134
  end
150
135
 
136
+ def bundlerize app
137
+ clean_bundler_environment
138
+ Dir.chdir app do
139
+ run 'bundle', 'install', '--path', '../bundle', '--binstubs'
140
+ end
141
+ ensure
142
+ restore_bundler_environment
143
+ end
144
+
151
145
  def create_controller app
152
146
  File.open(app + 'app' + 'controllers' + 'wiki_controller.rb', 'w') do |f|
153
147
  f.write 'class WikiController < ApplicationController; end'
@@ -182,90 +176,47 @@ TEST
182
176
  end
183
177
  end
184
178
 
185
- # Rails 2 only
186
- def update_environment app
187
- environment = app + 'config' + 'environment.rb'
188
- add_text_to_initializer " config.gem 'wikitext', :version => '#{Wikitext::VERSION}'", environment
189
- FileUtils.cd app do
190
- run 'rake', 'gems:refresh_specs'
191
- end
192
- end
193
-
194
- # Rails 3 only
195
179
  def update_routes app
196
180
  routes = app + 'config' + 'routes.rb'
197
181
  add_text_to_routes 'match "/wiki" => "wiki#index"', routes
198
182
  end
199
183
 
200
- def setup_rails2_app version
201
- create_rails2_app version
202
- path = app_path version
203
- update_environment path
184
+ def setup_rails_app rails_version = nil, arel_version = nil
185
+ create_rails3_app rails_version, arel_version
186
+ path = app_path rails_version
187
+ update_routes path
204
188
  create_controller path
205
189
  create_template path
206
190
  create_test path
207
191
  end
208
192
 
209
- def setup_rails3_app version = nil
210
- create_rails3_app version
211
- path = app_path version
212
- update_routes path
213
- create_controller path
214
- create_template path
215
- create_test path
193
+ def clean_bundler_environment
194
+ @bundler_env = ENV.select { |key, value| key =~ /\A(BUNDLE|GEM)_/ }
195
+ @bundler_env.each { |pair| ENV.delete(pair.first) }
216
196
  end
217
197
 
218
- def setup_edge_app
219
- setup_rails3_app
198
+ def restore_bundler_environment
199
+ @bundler_env.each { |pair| ENV[pair[0]] = pair[1] }
220
200
  end
221
201
 
222
202
  def run_integration_test app
203
+ clean_bundler_environment
223
204
  FileUtils.cd app do
224
- return run('rake', 'test:integration').stdout
205
+ return run('bin/rake', 'test:integration').stdout
225
206
  end
207
+ ensure
208
+ restore_bundler_environment
226
209
  end
227
210
  end # module RailsSpecs
228
211
 
229
- describe 'Template handler in Rails 2.3.0' do
230
- include RailsSpecs
231
-
232
- before :all do
233
- setup_rails2_app '2.3.0'
234
- @path = app_path '2.3.0'
235
- end
236
-
237
- it 'should process the template using the wikitext module' do
238
- pending 'Rack::Lint::LintError'
239
- # Rack::Lint::LintError: a header value must be a String, but the value of
240
- # 'Set-Cookie' is a Array
241
- run_integration_test(@path).should =~ RailsSpecs::SUCCESSFUL_TEST_RESULT
242
- end
243
- end
244
-
245
- # test other Rails 2 versions
246
- %w{2.2.2 2.2.3 2.3.1 2.3.2 2.3.2.1 2.3.3 2.3.3.1 2.3.4 2.3.5 2.3.6
247
- 2.3.7 2.3.8}.each do |version|
248
- describe "Template handler in Rails #{version}" do
249
- include RailsSpecs
250
-
251
- before :all do
252
- setup_rails2_app version
253
- @path = app_path version
254
- end
255
-
256
- it 'should process the template using the wikitext module' do
257
- run_integration_test(@path).should =~ RailsSpecs::SUCCESSFUL_TEST_RESULT
258
- end
259
- end
260
- end
261
-
262
- %w{3.0.0.beta4}.each do |version|
263
- describe "Template handler in Rails #{version}" do
212
+ # different versions of Rails require different versions of Arel
213
+ { '3.1.0' => '2.1.1' }.each do |rails_version, arel_version|
214
+ describe "Template handler in Rails #{rails_version}" do
264
215
  include RailsSpecs
265
216
 
266
217
  before :all do
267
- setup_rails3_app version
268
- @path = app_path version
218
+ setup_rails_app rails_version, arel_version
219
+ @path = app_path rails_version
269
220
  end
270
221
 
271
222
  it 'should process the template using the wikitext module' do
@@ -278,7 +229,7 @@ describe 'Template handler in Edge Rails' do
278
229
  include RailsSpecs
279
230
 
280
231
  before :all do
281
- setup_edge_app
232
+ setup_rails_app
282
233
  @path = app_path nil
283
234
  end
284
235
 
data/spec/version_spec.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright 2009 Wincent Colaiuta. All rights reserved.
2
+ # Copyright 2009-2011 Wincent Colaiuta. All rights reserved.
3
3
  #
4
4
  # Redistribution and use in source and binary forms, with or without
5
5
  # modification, are permitted provided that the following conditions are met:
@@ -26,7 +26,7 @@ require 'spec_helper'
26
26
  require 'wikitext/version'
27
27
 
28
28
  describe Wikitext, 'versioning' do
29
- it 'should provide a version string' do
29
+ it 'provides a version string' do
30
30
  Wikitext::VERSION.should be_instance_of(String)
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikitext
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
5
- prerelease: false
4
+ hash: 99
5
+ prerelease: 3
6
6
  segments:
7
- - 2
8
- - 1
9
- - 1
10
- version: 2.1.1
7
+ - 3
8
+ - 0
9
+ - b
10
+ version: 3.0b
11
11
  platform: ruby
12
12
  authors:
13
13
  - Wincent Colaiuta
@@ -15,13 +15,13 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-06 00:00:00 +01:00
19
- default_executable:
18
+ date: 2011-05-28 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rake
23
22
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ type: :development
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
@@ -30,28 +30,27 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  version: "0"
33
- type: :development
34
- version_requirements: *id001
33
+ requirement: *id001
35
34
  - !ruby/object:Gem::Dependency
36
35
  name: rspec
37
36
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ type: :development
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- hash: 15
43
+ hash: 3
44
44
  segments:
45
45
  - 2
46
46
  - 0
47
- - 0
48
- version: 2.0.0
49
- type: :development
50
- version_requirements: *id002
47
+ version: "2.0"
48
+ requirement: *id002
51
49
  - !ruby/object:Gem::Dependency
52
50
  name: thor
53
51
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
52
+ type: :development
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
54
  none: false
56
55
  requirements:
57
56
  - - ">="
@@ -60,12 +59,12 @@ dependencies:
60
59
  segments:
61
60
  - 0
62
61
  version: "0"
63
- type: :development
64
- version_requirements: *id003
62
+ requirement: *id003
65
63
  - !ruby/object:Gem::Dependency
66
64
  name: yard
67
65
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
66
+ type: :development
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
69
68
  none: false
70
69
  requirements:
71
70
  - - ">="
@@ -76,12 +75,12 @@ dependencies:
76
75
  - 5
77
76
  - 8
78
77
  version: 0.5.8
79
- type: :development
80
- version_requirements: *id004
78
+ requirement: *id004
81
79
  - !ruby/object:Gem::Dependency
82
80
  name: wopen3
83
81
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
82
+ type: :development
83
+ version_requirements: &id005 !ruby/object:Gem::Requirement
85
84
  none: false
86
85
  requirements:
87
86
  - - ">="
@@ -90,8 +89,21 @@ dependencies:
90
89
  segments:
91
90
  - 0
92
91
  version: "0"
92
+ requirement: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ name: ZenTest
95
+ prerelease: false
93
96
  type: :development
94
- version_requirements: *id005
97
+ version_requirements: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ requirement: *id006
95
107
  description: " Wikitext is a fast wikitext-to-HTML translator written in C.\n"
96
108
  email: win@wincent.com
97
109
  executables:
@@ -123,7 +135,6 @@ files:
123
135
  - lib/wikitext/rails_template_handler.rb
124
136
  - lib/wikitext/string.rb
125
137
  - lib/wikitext/version.rb
126
- - rails/init.rb
127
138
  - spec/autolinking_spec.rb
128
139
  - spec/base_heading_level_spec.rb
129
140
  - spec/blockquote_spec.rb
@@ -162,7 +173,6 @@ files:
162
173
  - spec/version_spec.rb
163
174
  - spec/vim_formatter.rb
164
175
  - spec/wikitext_spec.rb
165
- has_rdoc: false
166
176
  homepage: https://wincent.com/products/wikitext
167
177
  licenses: []
168
178
 
@@ -184,16 +194,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
194
  required_rubygems_version: !ruby/object:Gem::Requirement
185
195
  none: false
186
196
  requirements:
187
- - - ">="
197
+ - - ">"
188
198
  - !ruby/object:Gem::Version
189
- hash: 3
199
+ hash: 25
190
200
  segments:
191
- - 0
192
- version: "0"
201
+ - 1
202
+ - 3
203
+ - 1
204
+ version: 1.3.1
193
205
  requirements: []
194
206
 
195
207
  rubyforge_project: wikitext
196
- rubygems_version: 1.3.7
208
+ rubygems_version: 1.8.2
197
209
  signing_key:
198
210
  specification_version: 3
199
211
  summary: Wikitext-to-HTML translator
data/rails/init.rb DELETED
@@ -1,29 +0,0 @@
1
- # Copyright 2008-2010 Wincent Colaiuta. All rights reserved.
2
- #
3
- # Redistribution and use in source and binary forms, with or without
4
- # modification, are permitted provided that the following conditions are met:
5
- #
6
- # 1. Redistributions of source code must retain the above copyright notice,
7
- # this list of conditions and the following disclaimer.
8
- # 2. Redistributions in binary form must reproduce the above copyright notice,
9
- # this list of conditions and the following disclaimer in the documentation
10
- # and/or other materials provided with the distribution.
11
-
12
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13
- # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
- # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16
- # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
- # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
- # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
- # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
- # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
- # POSSIBILITY OF SUCH DAMAGE.
23
-
24
- # this file evaluated automatically under Rails 2
25
- unless $gems_build_rake_task
26
- # avoid Rails bug #2266 by not requiring during "rake gems:build"
27
- # see: https://rails.lighthouseapp.com/projects/8994/tickets/2266
28
- require 'wikitext'
29
- end