rugex 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'thor', '>= 0.14.6'
4
-
5
3
  group :development do
6
4
  gem 'rspec', '~> 2.3.0'
7
5
  gem 'bundler', '~> 1.0.9'
data/Gemfile.lock CHANGED
@@ -16,7 +16,6 @@ GEM
16
16
  rspec-expectations (2.3.0)
17
17
  diff-lcs (~> 1.1.2)
18
18
  rspec-mocks (2.3.0)
19
- thor (0.14.6)
20
19
 
21
20
  PLATFORMS
22
21
  ruby
@@ -25,4 +24,3 @@ DEPENDENCIES
25
24
  bundler (~> 1.0.9)
26
25
  jeweler (~> 1.5.2)
27
26
  rspec (~> 2.3.0)
28
- thor (>= 0.14.6)
data/README.textile ADDED
@@ -0,0 +1,48 @@
1
+ h1. About
2
+
3
+ Rugex is a simple tool for testing regular expressions from Ruby using the terminal.
4
+
5
+ It can be useful if you often use regular expressions or if you are learning it.
6
+
7
+ h1. Installation
8
+
9
+ <pre><code>gem install rugex</code></pre>
10
+
11
+ h1. Usage
12
+
13
+ Open a terminal and run:
14
+
15
+ <pre><code>rugex [text] [regex]</code></pre>
16
+
17
+ h2. For example:
18
+
19
+ <pre><code>rugex aquarius aqua</code></pre>
20
+ => *aqua* rius
21
+
22
+ <pre><code>rugex aquarius /aqua/</code></pre>
23
+ => *aqua* rius
24
+
25
+ <pre><code>rugex aquarius ^a..a.+$</code></pre>
26
+ => *aquarius*
27
+
28
+ <pre><code>rugex aquarius /a[qr]/</code></pre>
29
+ => *aq* u *ar* ius
30
+
31
+ h1. TODO
32
+
33
+ * File Suport
34
+ * Regex Options (i, m, x, o)
35
+
36
+ h1. Contributing to Lucas Caton
37
+
38
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
39
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
40
+ * Fork the project
41
+ * Start a feature/bugfix branch
42
+ * Commit and push until you are happy with your contribution
43
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
44
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
45
+
46
+ h2. Copyright
47
+
48
+ Copyright (c) 2011 Lucas Caton. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/bin/rugex CHANGED
@@ -1,3 +1,36 @@
1
1
  #! /usr/bin/env ruby
2
+
3
+ # Rugex - A CLI to test regular expressions on Ruby
4
+ # Author: Lucas Caton - lucascaton at gmail
5
+
2
6
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
- require 'rugex'
7
+
8
+ require 'optparse'
9
+ require 'rugex/string'
10
+
11
+ options = {}
12
+
13
+ optparse = OptionParser.new do |opts|
14
+ opts.banner = "Usage:\n\nrugex <text> <regex>\n\nYou can use flags as such:"
15
+
16
+ opts.on('-h', '--help', 'Display this screen') do
17
+ puts opts
18
+ exit
19
+ end
20
+
21
+ if ARGV.size < 2
22
+ puts opts
23
+ exit
24
+ end
25
+ end
26
+
27
+ begin
28
+ optparse.parse!
29
+ rescue OptionParser::InvalidOption => e
30
+ puts e
31
+ exit
32
+ end
33
+
34
+ text = ARGV[0]
35
+ regex_string = ARGV[1]
36
+ puts Rugex::String.new text, regex_string
data/lib/rugex/print.rb CHANGED
@@ -4,10 +4,10 @@ module Rugex
4
4
  private
5
5
  def print_colored_text
6
6
  colors = {
7
- :black => "\033[m",
8
- :blue => "\033[44m"
7
+ :white => "\033[0;37m",
8
+ :red => "\033[0;31m"
9
9
  }
10
- @text.gsub(@regex,"#{colors[:blue]}\\&#{colors[:black]}")
10
+ @text.gsub(@regex,"#{colors[:red]}\\&#{colors[:white]}")
11
11
  end
12
12
  end
13
13
  end
data/lib/rugex/string.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  require 'rugex/print'
2
2
  require 'rugex/regex'
3
3
 
4
- class EmptyRegexError < Exception; end
4
+ class EmptyRegexError < Exception
5
+ def initialize
6
+ super 'The regex param should not be blank.'
7
+ end
8
+ end
5
9
 
6
10
  module Rugex
7
11
  class String
data/rugex.gemspec CHANGED
@@ -5,18 +5,18 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rugex}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lucas Caton"]
12
- s.date = %q{2011-01-31}
12
+ s.date = %q{2011-02-06}
13
13
  s.default_executable = %q{rugex}
14
14
  s.description = %q{A CLI to test regular expressions on Ruby}
15
15
  s.email = %q{lucascaton@gmail.com}
16
16
  s.executables = ["rugex"]
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
- "README.rdoc"
19
+ "README.textile"
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
@@ -24,18 +24,16 @@ Gem::Specification.new do |s|
24
24
  "Gemfile",
25
25
  "Gemfile.lock",
26
26
  "LICENSE.txt",
27
- "README.rdoc",
27
+ "README.textile",
28
28
  "Rakefile",
29
29
  "VERSION",
30
30
  "bin/rugex",
31
- "lib/rugex.rb",
32
31
  "lib/rugex/print.rb",
33
32
  "lib/rugex/regex.rb",
34
33
  "lib/rugex/string.rb",
35
34
  "rugex.gemspec",
36
35
  "spec/lib/regex_spec.rb",
37
36
  "spec/lib/string_spec.rb",
38
- "spec/rugex_spec.rb",
39
37
  "spec/spec_helper.rb"
40
38
  ]
41
39
  s.homepage = %q{https://github.com/lucascaton/rugex}
@@ -46,7 +44,6 @@ Gem::Specification.new do |s|
46
44
  s.test_files = [
47
45
  "spec/lib/regex_spec.rb",
48
46
  "spec/lib/string_spec.rb",
49
- "spec/rugex_spec.rb",
50
47
  "spec/spec_helper.rb"
51
48
  ]
52
49
 
@@ -54,18 +51,15 @@ Gem::Specification.new do |s|
54
51
  s.specification_version = 3
55
52
 
56
53
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
- s.add_runtime_dependency(%q<thor>, [">= 0.14.6"])
58
54
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
59
55
  s.add_development_dependency(%q<bundler>, ["~> 1.0.9"])
60
56
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
61
57
  else
62
- s.add_dependency(%q<thor>, [">= 0.14.6"])
63
58
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
59
  s.add_dependency(%q<bundler>, ["~> 1.0.9"])
65
60
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
66
61
  end
67
62
  else
68
- s.add_dependency(%q<thor>, [">= 0.14.6"])
69
63
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
70
64
  s.add_dependency(%q<bundler>, ["~> 1.0.9"])
71
65
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
@@ -5,12 +5,12 @@ describe 'Rugex::String' do
5
5
  context 'successful' do
6
6
  it 'checks text with regular expression' do
7
7
  output = Rugex::String.new('John Doe', 'ohn')
8
- output.to_s.should == "J\e[44mohn\e[m Doe"
8
+ output.to_s.should == "J\e[0;31mohn\e[0;37m Doe"
9
9
  end
10
10
 
11
11
  it 'checks text with other regular expression' do
12
12
  output = Rugex::String.new('John Doe', 'John D')
13
- output.to_s.should == "\e[44mJohn D\e[moe"
13
+ output.to_s.should == "\e[0;31mJohn D\e[0;37moe"
14
14
  end
15
15
  end
16
16
 
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,11 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
- require 'rugex'
5
4
 
6
5
  # Requires supporting files with custom matchers and macros, etc,
7
6
  # in ./support/ and its subdirectories.
8
7
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
8
+ Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each {|f| require f}
9
9
 
10
10
  RSpec.configure do |config|
11
-
12
11
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rugex
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lucas Caton
@@ -15,27 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-31 00:00:00 -02:00
18
+ date: 2011-02-06 00:00:00 -02:00
19
19
  default_executable: rugex
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 43
28
- segments:
29
- - 0
30
- - 14
31
- - 6
32
- version: 0.14.6
33
- requirement: *id001
34
- prerelease: false
35
- name: thor
36
- type: :runtime
37
- - !ruby/object:Gem::Dependency
38
- version_requirements: &id002 !ruby/object:Gem::Requirement
39
23
  none: false
40
24
  requirements:
41
25
  - - ~>
@@ -46,12 +30,12 @@ dependencies:
46
30
  - 3
47
31
  - 0
48
32
  version: 2.3.0
49
- requirement: *id002
33
+ requirement: *id001
50
34
  prerelease: false
51
35
  name: rspec
52
36
  type: :development
53
37
  - !ruby/object:Gem::Dependency
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
55
39
  none: false
56
40
  requirements:
57
41
  - - ~>
@@ -62,12 +46,12 @@ dependencies:
62
46
  - 0
63
47
  - 9
64
48
  version: 1.0.9
65
- requirement: *id003
49
+ requirement: *id002
66
50
  prerelease: false
67
51
  name: bundler
68
52
  type: :development
69
53
  - !ruby/object:Gem::Dependency
70
- version_requirements: &id004 !ruby/object:Gem::Requirement
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
71
55
  none: false
72
56
  requirements:
73
57
  - - ~>
@@ -78,7 +62,7 @@ dependencies:
78
62
  - 5
79
63
  - 2
80
64
  version: 1.5.2
81
- requirement: *id004
65
+ requirement: *id003
82
66
  prerelease: false
83
67
  name: jeweler
84
68
  type: :development
@@ -90,25 +74,23 @@ extensions: []
90
74
 
91
75
  extra_rdoc_files:
92
76
  - LICENSE.txt
93
- - README.rdoc
77
+ - README.textile
94
78
  files:
95
79
  - .document
96
80
  - .rspec
97
81
  - Gemfile
98
82
  - Gemfile.lock
99
83
  - LICENSE.txt
100
- - README.rdoc
84
+ - README.textile
101
85
  - Rakefile
102
86
  - VERSION
103
87
  - bin/rugex
104
- - lib/rugex.rb
105
88
  - lib/rugex/print.rb
106
89
  - lib/rugex/regex.rb
107
90
  - lib/rugex/string.rb
108
91
  - rugex.gemspec
109
92
  - spec/lib/regex_spec.rb
110
93
  - spec/lib/string_spec.rb
111
- - spec/rugex_spec.rb
112
94
  - spec/spec_helper.rb
113
95
  has_rdoc: true
114
96
  homepage: https://github.com/lucascaton/rugex
@@ -147,5 +129,4 @@ summary: A simple tool for testing regular expressions from Ruby using the termi
147
129
  test_files:
148
130
  - spec/lib/regex_spec.rb
149
131
  - spec/lib/string_spec.rb
150
- - spec/rugex_spec.rb
151
132
  - spec/spec_helper.rb
data/README.rdoc DELETED
@@ -1,18 +0,0 @@
1
- = rugex
2
-
3
- Description goes here.
4
-
5
- == Contributing to Lucas Caton
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 Lucas Caton. See LICENSE.txt for
18
- further details.
data/lib/rugex.rb DELETED
@@ -1,21 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # Rugex - A CLI to test regular expressions on Ruby
4
- # Author: Lucas Caton - lucascaton at gmail
5
-
6
- require 'rubygems'
7
- require 'thor'
8
- require 'rugex/string'
9
-
10
- module Rugex
11
- class Base < Thor
12
- ARGV.unshift 'string' if (ARGV[0] =~ /-./) == nil
13
-
14
- desc '<text> <regex>', 'show the match text using regular expression'
15
- def string(text, regex_string)
16
- puts Rugex::String.new text, regex_string
17
- end
18
- end
19
- end
20
-
21
- Rugex::Base.start
data/spec/rugex_spec.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Rugex::Base' do
4
- end