easyregexp 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in easyregexp.gemspec
4
+ gemspec
5
+ gem 'rspec'
data/README.markdown ADDED
@@ -0,0 +1,7 @@
1
+ easyregexp
2
+ -
3
+
4
+ Easyregexp is a regular expression generator.
5
+
6
+ Right now this project is in a beta phase, with only a few methods
7
+ working. We hope to get to a more advanced state in a few weeks.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "easyregexp/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "easyregexp"
7
+ s.version = Easyregexp::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Cristian Planas']
10
+ s.email = ['me@cristianplanas.com']
11
+ s.homepage = ""
12
+ s.summary = %q{'A regular expression generator'}
13
+ s.description = %q{'Regular expression syntaxis is hard to remember. Easyregexp wants to make your life easier.'}
14
+
15
+ s.rubyforge_project = "easyregexp"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,3 @@
1
+ module Easyregexp
2
+ VERSION = "0.0.1"
3
+ end
data/lib/easyregexp.rb ADDED
@@ -0,0 +1,28 @@
1
+ module Easyregexp
2
+
3
+ class Easyregexp
4
+
5
+ attr_reader :verbose, :regexp
6
+
7
+ def anything_but_whitespaces
8
+ @regexp ||= Regexp.new('\S*')
9
+ verbalize(__method__)
10
+ end
11
+
12
+ def anything_but(arg)
13
+ @regexp ||= Regexp.new('[^'+arg.to_s+']')
14
+ verbalize(__method__, arg)
15
+ end
16
+
17
+ private
18
+
19
+ def verbalize(method, arg = '')
20
+ unless arg.empty?
21
+ arg = ' '+arg
22
+ end
23
+ @verbose = method.to_s.gsub!('_',' ').capitalize+arg
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ describe Easyregexp::Easyregexp do
3
+ describe 'attributes' do
4
+ end
5
+ describe 'generating methods' do
6
+ describe '#anything_but_?' do
7
+ describe '#anything_but()' do
8
+ it 'returns the correct regexp' do
9
+ subject.anything_but('a')
10
+ subject.regexp.should == /[^a]/
11
+ end
12
+ it 'returns the correct verbose form' do
13
+ subject.anything_but('b')
14
+ subject.verbose.should == 'Anything but b'
15
+ end
16
+ it 'should behave properly accepting' do
17
+ subject.anything_but('c')
18
+ 'aaa'.should =~ subject.regexp
19
+ end
20
+ it 'should behave properly rejecting' do
21
+ subject.anything_but('c')
22
+ 'ccc'.should_not =~ subject.regexp
23
+ end
24
+ end
25
+ describe '#anything_but_whitespaces' do
26
+ it 'returns the correct regexp' do
27
+ subject.anything_but_whitespaces
28
+ subject.regexp.should == /\S*/
29
+ end
30
+ it 'returns the correct verbose form' do
31
+ subject.anything_but_whitespaces
32
+ subject.verbose.should == 'Anything but whitespaces'
33
+ end
34
+ it 'should behave properly' do
35
+ subject.anything_but_whitespaces
36
+ 'AAAAA'.should =~ subject.regexp
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'easyregexp' # and any other gems you need
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
9
+
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easyregexp
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Cristian Planas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-02-03 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: "'Regular expression syntaxis is hard to remember. Easyregexp wants to make your life easier.'"
17
+ email:
18
+ - me@cristianplanas.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - .rspec
28
+ - Gemfile
29
+ - README.markdown
30
+ - Rakefile
31
+ - easyregexp.gemspec
32
+ - lib/easyregexp.rb
33
+ - lib/easyregexp/version.rb
34
+ - spec/easyregexp_spec.rb
35
+ - spec/spec_helper.rb
36
+ homepage: ""
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ requirements: []
57
+
58
+ rubyforge_project: easyregexp
59
+ rubygems_version: 1.8.15
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: "'A regular expression generator'"
63
+ test_files:
64
+ - spec/easyregexp_spec.rb
65
+ - spec/spec_helper.rb