rubulex 0.5.0 → 0.6.5

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cf8dbc1b09724952fb721f0a7c6ca4866a2c505a
4
+ data.tar.gz: a796b809e1f10a132efcb4e70cf055ee7f565b84
5
+ SHA512:
6
+ metadata.gz: 47e2441c60a0b99081ab04a3401140fd821665fa9599dcaf5ab5b5a584d57c5f238cb362564790859d9a2c746fe1b94face55b9eb186efa4a215a8fd8075dd9a
7
+ data.tar.gz: 140501b4dbbcbe6614c5fb163733ddf474714c02d08487c41bf05e4271e8433176c4c239afc98cdde0a8cdede4c689567419f3430cab74142f23a2192e02d932
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ .sass-cache
3
4
  .bundle
4
5
  .config
5
6
  .yardoc
data/README.md CHANGED
@@ -1,29 +1,13 @@
1
1
  # Rubulex
2
2
 
3
- TODO: Write a gem description
3
+ Rubulex is a simple self-hosted Sinatra Rubular clone.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'rubulex'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
7
  $ gem install rubulex
18
8
 
19
9
  ## Usage
20
10
 
21
- TODO: Write usage instructions here
22
-
23
- ## Contributing
11
+ $ rubulex
24
12
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
13
+ Open a browser an go to http://localhost:4567
@@ -1,11 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
- require 'bundler'
4
-
5
- ENV['BUNDLE_GEMFILE'] ||= File.join(File.dirname(__FILE__), "..", "Gemfile")
6
- ENV['RACK_ENV'] ||= "testing"
7
- Bundler.require(:default, ENV['RACK_ENV'])
8
-
9
3
  require 'rubulex'
10
4
 
11
5
  Rubulex::App.run!
@@ -9,146 +9,144 @@ html
9
9
 
10
10
  body
11
11
  .page
12
- .header
12
+ header
13
13
  h1 Rubulex
14
14
  h2 a Ruby Regular Expression Editor
15
15
 
16
- .content
17
- .editor
18
- form#editor_form method="post" action="regex/test" accept-charset="UTF-8"
19
- .regexp_entry
20
- label Your regular expression:
21
- br
22
- span= "/"
23
- input id="regex" type="text" tabindex="1" size="60" name="regex"
24
- span= "/"
25
- input id="regex_options" type="text" tabindex="1" size="6" name="options"
26
- span= "/"
27
- .test
28
- .data_pane
29
- label Your test data:
30
- textarea id="test_data" tabindex="3" rows="10" name="test_data" cols="56"
31
- .match_pane
32
- .results
33
- label Your result:
34
- #result
35
- .result_groups{ style="display: none;" }
36
- label Your result groups:
37
- #result_groups
38
- .help
39
- div style="float:left"
40
- table
41
- tr
42
- td
43
- code [abc]
44
- td A single character of: a, b or c
45
- tr
46
- td
47
- code [^abc]
48
- td Any single character except: a, b, or c
49
- tr
50
- td
51
- code [a-z]
52
- td Any single character in the range a-z
53
- tr
54
- td
55
- code [a-zA-Z]
56
- td Any single character in the range a-z or A-Z
57
- tr
58
- td
59
- code ^
60
- td Start of line
61
- tr
62
- td
63
- code $
64
- td End of line
65
- tr
66
- td
67
- code \A
68
- td Start of string
69
- tr
70
- td
71
- code \z
72
- td End of string
16
+ section.editor
17
+ form#editor_form method="post" action="regex/test" accept-charset="UTF-8"
18
+ .regexp_entry
19
+ label Regular expression:
20
+ br
21
+ span= "/"
22
+ input id="regex" type="text" tabindex="1" size="60" name="regex"
23
+ span= "/"
24
+ input id="regex_options" type="text" tabindex="1" size="6" name="options"
25
+ span= "/"
26
+ .test
27
+ .data_pane
28
+ label Test data:
29
+ textarea id="test_data" tabindex="3" rows="10" name="test_data" cols="56"
30
+ .match_pane
31
+ .results
32
+ label Match results:
33
+ #result
34
+ .result_groups{ style="display: none;" }
35
+ label Match groups:
36
+ #result_groups
37
+ section.help
38
+ div style="float:left"
39
+ table
40
+ tr
41
+ td
42
+ code= "[abc]"
43
+ td A single character of: a, b or c
44
+ tr
45
+ td
46
+ code= "[^abc]"
47
+ td Any single character except: a, b, or c
48
+ tr
49
+ td
50
+ code [a-z]
51
+ td Any single character in the range a-z
52
+ tr
53
+ td
54
+ code [a-zA-Z]
55
+ td Any single character in the range a-z or A-Z
56
+ tr
57
+ td
58
+ code ^
59
+ td Start of line
60
+ tr
61
+ td
62
+ code $
63
+ td End of line
64
+ tr
65
+ td
66
+ code \A
67
+ td Start of string
68
+ tr
69
+ td
70
+ code \z
71
+ td End of string
73
72
 
74
- div style="float:left"
75
- table
76
- tr
77
- td
78
- code .
79
- td Any single character
80
- tr
81
- td
82
- code \s
83
- td Any whitespace character
84
- tr
85
- td
86
- code \S
87
- td Any non-whitespace character
88
- tr
89
- td
90
- code \d
91
- td Any digit
92
- tr
93
- td
94
- code \D
95
- td Any non-digit
96
- tr
97
- td
98
- code \w
99
- td Any word character (letter, number, underscore)
100
- tr
101
- td
102
- code \W
103
- td Any non-word character
104
- tr
105
- td
106
- code \b
107
- td Any word boundary
108
73
  table
109
74
  tr
110
75
  td
111
- code (...)
112
- td Capture everything enclosed
76
+ code .
77
+ td Any single character
113
78
  tr
114
79
  td
115
- code (a|b)
116
- td a or b
80
+ code \s
81
+ td Any whitespace character
117
82
  tr
118
83
  td
119
- code a?
120
- td Zero or one of a
84
+ code \S
85
+ td Any non-whitespace character
121
86
  tr
122
87
  td
123
- code a*
124
- td Zero or more of a
88
+ code \d
89
+ td Any digit
125
90
  tr
126
91
  td
127
- code a+
128
- td One or more of a
92
+ code \D
93
+ td Any non-digit
129
94
  tr
130
95
  td
131
- code a{3}
132
- td Exactly 3 of a
96
+ code \w
97
+ td Any word character (letter, number, underscore)
133
98
  tr
134
99
  td
135
- code a{3,}
136
- td 3 or more of a
100
+ code \W
101
+ td Any non-word character
137
102
  tr
138
103
  td
139
- code a{3,6}
140
- td Between 3 and 6 of a
104
+ code \b
105
+ td Any word boundary
106
+ table
107
+ tr
108
+ td
109
+ code= "(...)"
110
+ td Capture everything enclosed
111
+ tr
112
+ td
113
+ code= "(a|b)"
114
+ td a or b
115
+ tr
116
+ td
117
+ code a?
118
+ td Zero or one of a
119
+ tr
120
+ td
121
+ code a*
122
+ td Zero or more of a
123
+ tr
124
+ td
125
+ code a+
126
+ td One or more of a
127
+ tr
128
+ td
129
+ code a{3}
130
+ td Exactly 3 of a
131
+ tr
132
+ td
133
+ code a{3,}
134
+ td 3 or more of a
135
+ tr
136
+ td
137
+ code a{3,6}
138
+ td Between 3 and 6 of a
141
139
 
142
- .regex_options
143
- p
144
- | options:
145
- code i
146
- | case insensitive
147
- code m
148
- | make dot match newlines
149
- code x
150
- | ignore whitespace in regex
151
- code o
152
- | perform {...} substitutions only once
153
- .footer
154
- | Copyright © #{Rubulex::VERSION} Expression
140
+ .regex_options
141
+ p
142
+ | options:
143
+ code i
144
+ | case insensitive
145
+ code m
146
+ | make dot match newlines
147
+ code x
148
+ | ignore whitespace in regex
149
+ code o
150
+ | perform {...} substitutions only once
151
+ footer
152
+ | Copyright © v#{Rubulex::VERSION}
@@ -18,6 +18,10 @@ h1
18
18
  h2
19
19
  font-size: 16pt
20
20
 
21
+ dl
22
+ dd
23
+ margin-left: 16px
24
+
21
25
  form
22
26
  input, textarea
23
27
  font-size: 13pt
@@ -44,8 +48,10 @@ span.blue
44
48
  background-color: blue
45
49
  color: white
46
50
 
51
+ label
52
+ display: block
53
+
47
54
  html
48
- head
49
55
  body
50
56
  width: 100%
51
57
  height: 100%
@@ -60,86 +66,97 @@ html
60
66
  min-height: 100%
61
67
  width: 960px
62
68
 
63
- .header
69
+ header
64
70
  color: #454545
65
71
  height: 120px
66
72
  text-align: center
67
73
  text-shadow: 2px 2px 2px gray
68
74
 
69
- .content
70
- height: 640px
75
+ section.editor
76
+ @include rounded
77
+ @include shadow
71
78
 
72
- .editor
73
- @include rounded
74
- @include shadow
79
+ background-color: #FEFEFE
80
+ border: 1px solid #D0D0D0
81
+ padding: 18px
75
82
 
76
- background-color: #FEFEFE
77
- border: 1px solid #D0D0D0
78
- padding: 18px
79
-
80
- .regexp_entry
81
- padding: 8px
83
+ .regexp_entry
84
+ padding: 8px
82
85
 
83
- input, span
84
- display: inline-block
85
- margin: 4px
86
+ input, span
87
+ display: inline-block
88
+ margin: 4px
86
89
 
87
- span
88
- color: gray
89
- font-size: 24pt
90
- vertical-align: middle
91
-
92
- .test
93
-
94
- .data_pane
95
- padding: 8px
96
- float: left
97
- width: 420px
98
-
99
- textarea
100
- font-family: monaco, courier
101
- font-size: 13pt
102
- font-weight: bold
103
- padding: 6pt
104
- width: 100%
105
-
106
- .match_pane
107
- padding: 8px
108
- margin-left: 50%
109
- width: 440px
110
-
111
- #result, #result_groups
112
- font-family: monaco, courier
113
- font-size: 13pt
114
- font-weight: bold
115
- padding: 6pt
116
- margin: 4px
117
- min-height: 200px
118
- border: 1px solid #D0D0D0
119
-
120
- .help
121
- @include rounded
122
- @include shadow
123
- border: 1px solid #D0D0D0
124
- margin-top: 32px
125
- padding: 8px
126
- font-size: 8pt
127
-
128
- code
129
- font-weight: bold
90
+ span
91
+ color: gray
92
+ font-size: 24pt
93
+ vertical-align: middle
94
+
95
+ .test
96
+ display: table
97
+ width: 100%
130
98
 
131
- table
132
- tr
133
- td
134
- padding-right: 12px
135
-
136
- .regex_options
137
- text-align: center
138
- border-top: 1px solid #D0D0D0
139
- padding-top: 16px
140
- margin-top: 16px
99
+ .data_pane
100
+ width: 50%
101
+ padding: 8px
102
+ display: table-cell
141
103
 
142
- code
104
+ textarea
105
+ font-family: monaco, courier
106
+ font-size: 10pt
107
+ font-weight: bold
108
+ padding: 6pt
109
+ min-height: 218px
110
+ width: 100%
111
+ box-sizing: border-box
112
+ -moz-box-sizing: border-box
113
+
114
+ .match_pane
115
+ width: 50%
116
+ padding: 8px
117
+ display: table-cell
118
+
119
+ #result, #result_groups
120
+ font-family: monaco, courier
121
+ font-size: 10pt
122
+ font-weight: bold
123
+ padding: 6pt
124
+ margin: 4px
125
+ min-height: 200px
126
+ border: 1px solid #D0D0D0
127
+ box-sizing: border-box
128
+ -moz-box-sizing: border-size
129
+
130
+ section.help
131
+ @include rounded
132
+ @include shadow
133
+ border: 1px solid #D0D0D0
134
+ margin-top: 32px
135
+ padding: 8px
136
+ font-size: 8pt
137
+
138
+ code
139
+ font-weight: bold
140
+
141
+ table
142
+ display: table-cell
143
+
144
+ tr
145
+ td
143
146
  padding-right: 12px
144
- padding-left: 12px
147
+
148
+ .regex_options
149
+ text-align: center
150
+ border-top: 1px solid #D0D0D0
151
+ padding-top: 16px
152
+ margin-top: 16px
153
+
154
+ code
155
+ padding-right: 12px
156
+ padding-left: 12px
145
157
 
158
+ footer
159
+ color: grey
160
+ margin-top: 16px
161
+ min-height: 32px
162
+ text-align: center
@@ -1,5 +1,7 @@
1
1
  module Rubulex
2
2
  class RegexpParser
3
+ Struct.new("MatchRelation", :name, :text)
4
+
3
5
  def initialize(regex, options, data)
4
6
  self.options = options
5
7
  self.regex = regex
@@ -15,7 +17,7 @@ module Rubulex
15
17
  end
16
18
 
17
19
  def regex=(regex)
18
- @regex = Regexp.new(/#{regex}/, @options)
20
+ @regex = Regexp.new("#{regex}", @options)
19
21
  rescue RegexpError => error
20
22
  @regex = //
21
23
  end
@@ -35,29 +37,55 @@ module Rubulex
35
37
 
36
38
  def parse
37
39
  @data.match(@regex) do |match|
38
- colors = ->() do
39
- (@colors ||= [:red, :green, :darkorange, :blue].cycle).next
40
- end
41
- @match_result = @data.dup
42
- @match_result.gsub!(@regex) do |match|
43
- "<span class='#{colors.call}'>#{match}</span>"
44
- end
45
- @match_result.gsub!(/\n/,"<br />")
46
-
47
- @match_groups = if match.names.length > 0
48
- match.names.each_with_object([]) { |match_name, memo|
49
- memo << { match_name.to_sym => match[match_name] }
50
- }
51
- elsif match.length > 0
52
- match.to_a[1..-1].map.with_index { |match, index| { index => match } }
40
+ @match_result = render_match_result(@data.dup)
41
+ @match_groups = render_match_groups(@data.dup)
42
+ end
43
+ end
44
+
45
+ def render_match_result(data)
46
+ colors = ->() do
47
+ (@colors ||= [:red, :green, :darkorange, :blue].cycle).next
48
+ end
49
+ data.gsub!(@regex) do |match|
50
+ "<span class='#{colors.call}'>#{match}</span>"
51
+ end
52
+
53
+ data.gsub(/\n/,"<br />")
54
+ end
55
+
56
+ def render_match_groups(data)
57
+ match_groups = []
58
+
59
+ data.gsub(@regex) do |match_text|
60
+ sub_match = match_text.match(@regex)
61
+ match_group_count = sub_match.length - 1
62
+ if match_group_count > 0
63
+ sub_match_set = []
64
+
65
+ match_group_count.times do |index|
66
+ key = sub_match.names[index] || index + 1
67
+ match_text = sub_match[key]
68
+
69
+ sub_match_set << Struct::MatchRelation.new(key, match_text)
70
+ end
71
+
72
+ match_groups << sub_match_set
53
73
  end
54
74
  end
75
+
76
+ match_groups.map.with_index { |sub_set, index|
77
+ group = "<dl><dt>Match #{index + 1}</dt>"
78
+ group << sub_set.map { |match|
79
+ "<dd>#{match.name}: #{match.text}</dd>"
80
+ }.join
81
+ group << "</dl>"
82
+ }.join("<br />")
55
83
  end
56
84
 
57
85
  def result
58
86
  {
59
87
  match_result: @match_result,
60
- match_groups: @match_groups.join("<br />")
88
+ match_groups: @match_groups
61
89
  }
62
90
  end
63
91
  end
@@ -1,3 +1,3 @@
1
1
  module Rubulex
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.5"
3
3
  end
@@ -13,12 +13,11 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = "https://github.com/ofeldt/rubulex"
14
14
 
15
15
  gem.add_runtime_dependency "sinatra", "~> 1.4.3"
16
- gem.add_runtime_dependency "sinatra-contrib", "~> 1.4.0"
17
- gem.add_runtime_dependency "slim", "~> 1.3.6"
18
- gem.add_runtime_dependency "sass", "~> 3.2.7"
19
- gem.add_runtime_dependency "bundler", "~> 1.3.5"
16
+ gem.add_runtime_dependency "sinatra-contrib", "~> 1.4.1"
17
+ gem.add_runtime_dependency "slim", "~> 2.0.1"
18
+ gem.add_runtime_dependency "sass", "~> 3.2.10"
20
19
 
21
- gem.add_development_dependency "rspec", "~> 2.13.0"
20
+ gem.add_development_dependency "rspec", "~> 2.14.1"
22
21
 
23
22
  gem.files = `git ls-files`.split($/)
24
23
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubulex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
5
- prerelease:
4
+ version: 0.6.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Oliver Feldt
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-11 00:00:00.000000000 Z
11
+ date: 2013-09-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sinatra
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,83 +27,59 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: sinatra-contrib
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: 1.4.0
33
+ version: 1.4.1
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 1.4.0
40
+ version: 1.4.1
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: slim
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: 1.3.6
47
+ version: 2.0.1
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: 1.3.6
54
+ version: 2.0.1
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: sass
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
69
- version: 3.2.7
61
+ version: 3.2.10
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
77
- version: 3.2.7
78
- - !ruby/object:Gem::Dependency
79
- name: bundler
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ~>
84
- - !ruby/object:Gem::Version
85
- version: 1.3.5
86
- type: :runtime
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: 1.3.5
68
+ version: 3.2.10
94
69
  - !ruby/object:Gem::Dependency
95
70
  name: rspec
96
71
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
72
  requirements:
99
73
  - - ~>
100
74
  - !ruby/object:Gem::Version
101
- version: 2.13.0
75
+ version: 2.14.1
102
76
  type: :development
103
77
  prerelease: false
104
78
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
79
  requirements:
107
80
  - - ~>
108
81
  - !ruby/object:Gem::Version
109
- version: 2.13.0
82
+ version: 2.14.1
110
83
  description: A simple self-hosted Rubular Clone
111
84
  email:
112
85
  - oliver.feldt@googlemail.com
@@ -116,8 +89,6 @@ extensions: []
116
89
  extra_rdoc_files: []
117
90
  files:
118
91
  - .gitignore
119
- - .sass-cache/585bcb933d47ad9fc0e0c198b6c88f057e68fc16/default.sassc
120
- - Gemfile
121
92
  - LICENSE.txt
122
93
  - README.md
123
94
  - Rakefile
@@ -133,26 +104,25 @@ files:
133
104
  - rubulex.gemspec
134
105
  homepage: https://github.com/ofeldt/rubulex
135
106
  licenses: []
107
+ metadata: {}
136
108
  post_install_message:
137
109
  rdoc_options: []
138
110
  require_paths:
139
111
  - lib
140
112
  required_ruby_version: !ruby/object:Gem::Requirement
141
- none: false
142
113
  requirements:
143
114
  - - '>='
144
115
  - !ruby/object:Gem::Version
145
116
  version: '0'
146
117
  required_rubygems_version: !ruby/object:Gem::Requirement
147
- none: false
148
118
  requirements:
149
119
  - - '>='
150
120
  - !ruby/object:Gem::Version
151
121
  version: '0'
152
122
  requirements: []
153
123
  rubyforge_project:
154
- rubygems_version: 1.8.25
124
+ rubygems_version: 2.0.3
155
125
  signing_key:
156
- specification_version: 3
126
+ specification_version: 4
157
127
  summary: Rubulex is a simple web application for developing/testing Regular Expression
158
128
  test_files: []
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rubulex.gemspec
4
- gemspec