wikitext 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c61ab6467120d8def1be560fcb4604ee7c90454b
4
- data.tar.gz: 1c7be94a73a1d038a18744775054910772a964f0
3
+ metadata.gz: ddabd2110e5aac5afaf4174532fa0140fef9ab78
4
+ data.tar.gz: 9f8921cf631c7f835e14b30bfc0efe5b913b0bac
5
5
  SHA512:
6
- metadata.gz: df484b7d09e76c9b01a53cf4c8cb7b7bcea8fba56d6e7d1443e01259b3b41934e4f517a87cf0a4593ac33646c47a9b9b4c96accf4f810db83013d32a248dd3f7
7
- data.tar.gz: 66d3a468c2d787a2ec572b24ff53e8210cc520f37fd4caab68fc3536c0640f01deaddbe59e22f892eea8f2872788ef2f50bc66bba363298c1e5cee7c655cd444
6
+ metadata.gz: 32743798b2dea9ae8733e0473b315d9e0fc801b0ecd46d45d03941b54c7e7095ab2f115b07c0d264863f0b66706ad6a7b7649be668e90552a0c48239234bf7ab
7
+ data.tar.gz: 4cf45c3fee66016ac479559b154629083e785617e6eda0da8c086b4698deaa4f64ab3f7124d7e602a36cdd1a4690d3dba0dcd28127d79163c70e4cc8e675fa24
data/bin/wikitext CHANGED
@@ -1,16 +1,116 @@
1
1
  #!/usr/bin/env ruby
2
+ # Copyright 2008-2013 Wincent Colaiuta. All rights reserved.
2
3
  #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'wikitext' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
7
6
  #
7
+ # 1. Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ # this list of conditions and the following disclaimer in the documentation
11
+ # and/or other materials provided with the distribution.
12
+
13
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
17
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
+ # POSSIBILITY OF SUCH DAMAGE.
24
+
25
+ require 'wikitext'
26
+ require 'wikitext/version'
27
+
28
+ module Wikitext
29
+ module Tool
30
+ # Simple substitute for the HighLine library if it is not available.
31
+ class FakeHighLine
32
+ def color(str, _)
33
+ str
34
+ end
35
+
36
+ def output_cols
37
+ 80
38
+ end
39
+ end
40
+
41
+ INPUT_FILES = []
42
+
43
+ def self.interactive?
44
+ STDOUT.tty? && STDIN.tty? && INPUT_FILES.empty?
45
+ end
46
+
47
+ def self.pretty_print tokens
48
+ tokens.each do |token|
49
+ puts <<-END
50
+ Token: type: #{token.token_type}
51
+ line: #{token.line_start}..#{token.line_stop} column: #{token.column_start}..#{token.column_stop}
52
+ pointer: #{token.start}..#{token.stop}
53
+ code_point: #{token.code_point}
54
+ string_value: #{token.string_value.inspect}
55
+
56
+ END
57
+ end
58
+ end
8
59
 
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
60
+ method = :parse
61
+ ARGV.each do |arg|
62
+ if arg =~ /\A--tok/
63
+ method = :tokenize
64
+ else
65
+ INPUT_FILES << arg
66
+ end
67
+ end
12
68
 
13
- require 'rubygems'
14
- require 'bundler/setup'
69
+ if interactive?
70
+ begin
71
+ require 'highline'
72
+ rescue LoadError
73
+ begin
74
+ require 'rubygems'
75
+ require 'highline'
76
+ rescue LoadError
77
+ end
78
+ end
79
+ puts "wikitext #{Wikitext::VERSION}"
80
+ highline = (defined?(HighLine) ? HighLine : FakeHighLine).new
81
+ end
15
82
 
16
- load Gem.bin_path('wikitext', 'wikitext')
83
+ parser = Parser.new
84
+ if INPUT_FILES.empty?
85
+ begin
86
+ while true
87
+ puts highline.color('(Ctrl+D to process, Ctrl+C to exit)>>', :bold) if interactive?
88
+ input = STDIN.read
89
+ puts '-' * highline.output_cols if interactive?
90
+ if method == :tokenize
91
+ pretty_print parser.tokenize(input)
92
+ else
93
+ puts parser.parse(input)
94
+ end
95
+ puts '-' * highline.output_cols if interactive?
96
+ exit unless interactive?
97
+ end
98
+ rescue Interrupt
99
+ end
100
+ else # we have INPUT_FILES
101
+ exit_status = 0
102
+ INPUT_FILES.each do |file|
103
+ begin
104
+ puts parser.parse(File.new(file).read)
105
+ rescue Errno::ENOENT
106
+ STDERR.puts "error: no such file or directory: #{file}"
107
+ exit_status |= 1
108
+ rescue Errno::EACCES
109
+ STDERR.puts "error: permission denied: #{file}"
110
+ exit_status |= 2
111
+ end
112
+ end
113
+ exit exit_status
114
+ end
115
+ end # module Tool
116
+ end # module Wikitext
@@ -28,10 +28,7 @@ def missing item
28
28
  exit 1
29
29
  end
30
30
 
31
- case RUBY_VERSION
32
- when /\A2\.0/
33
- $CFLAGS += ' -DRUBY_2_0_x'
34
- else
31
+ if RUBY_VERSION !~ /\A2\.[01]\./
35
32
  raise "unsupported Ruby version: #{RUBY_VERSION}"
36
33
  end
37
34
 
@@ -22,5 +22,5 @@
22
22
  # POSSIBILITY OF SUCH DAMAGE.
23
23
 
24
24
  module Wikitext
25
- VERSION = '4.0.2'
25
+ VERSION = '4.0.3'
26
26
  end # module Wikitext
data/spec/spec_helper.rb CHANGED
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  # prepend local directories to search path if not already present
54
54
  basedir = Pathname.new(__dir__) + '..'
55
- extdir = (basedir + 'ext').realpath
55
+ extdir = (basedir + 'ext' + 'wikitext').realpath
56
56
  libdir = (basedir + 'lib').realpath
57
57
  normalized = $:.map { |path| Pathname.new(path).realpath rescue path }
58
58
  [libdir, extdir].each { |d| $:.unshift(d) unless normalized.include?(d) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikitext
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wincent Colaiuta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-19 00:00:00.000000000 Z
11
+ date: 2013-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project: wikitext
187
- rubygems_version: 2.0.0
187
+ rubygems_version: 2.1.11
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Wikitext-to-HTML translator