epitools 0.1.1 → 0.1.2

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/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/ruby
1
2
  require 'rubygems'
2
3
  require 'rake'
3
4
 
@@ -39,7 +40,7 @@ Rake::RDocTask.new do |rdoc|
39
40
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
41
 
41
42
  rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "testtt #{version}"
43
+ rdoc.title = "epitools #{version}"
43
44
  rdoc.rdoc_files.include('README*')
44
45
  rdoc.rdoc_files.include('lib/**/*.rb')
45
46
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{epitools}
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["epitron"]
12
+ s.date = %q{2010-05-15}
13
+ s.description = %q{Miscellaneous utility libraries to make my life easier.}
14
+ s.email = %q{chris@ill-logic.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "epitools.gemspec",
27
+ "lib/epitools.rb",
28
+ "lib/epitools/basetypes.rb",
29
+ "lib/epitools/hexdump.rb",
30
+ "lib/epitools/http.rb",
31
+ "lib/epitools/lcs.rb",
32
+ "lib/epitools/metaclass.rb",
33
+ "lib/epitools/niceprint.rb",
34
+ "lib/epitools/permutations.rb",
35
+ "lib/epitools/pretty_backtrace.rb",
36
+ "lib/epitools/rails.rb",
37
+ "lib/epitools/rash.rb",
38
+ "lib/epitools/string_to_proc.rb",
39
+ "spec/basetypes_spec.rb",
40
+ "spec/lcs_spec.rb",
41
+ "spec/metaclass_spec.rb",
42
+ "spec/permutations_spec.rb",
43
+ "spec/rash_spec.rb",
44
+ "spec/spec.opts",
45
+ "spec/spec_helper.rb"
46
+ ]
47
+ s.homepage = %q{http://github.com/epitron/epitools}
48
+ s.rdoc_options = ["--charset=UTF-8"]
49
+ s.require_paths = ["lib"]
50
+ s.rubygems_version = %q{1.3.6}
51
+ s.summary = %q{NOT UTILS... METILS!}
52
+ s.test_files = [
53
+ "spec/lcs_spec.rb",
54
+ "spec/rash_spec.rb",
55
+ "spec/metaclass_spec.rb",
56
+ "spec/permutations_spec.rb",
57
+ "spec/spec_helper.rb",
58
+ "spec/basetypes_spec.rb"
59
+ ]
60
+
61
+ if s.respond_to? :specification_version then
62
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
63
+ s.specification_version = 3
64
+
65
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
66
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
67
+ else
68
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
72
+ end
73
+ end
74
+
@@ -0,0 +1,71 @@
1
+ # String#to_proc
2
+ #
3
+ # See http://weblog.raganwald.com/2007/10/stringtoproc.html
4
+ #
5
+ # Ported from the String Lambdas in Oliver Steele's Functional Javascript
6
+ # http://osteele.com/sources/javascript/functional/
7
+ #
8
+ # This work is licensed under the MIT License:
9
+ #
10
+ # (c) 2007 Reginald Braithwaite
11
+ # Portions Copyright (c) 2006 Oliver Steele
12
+ #
13
+ # Permission is hereby granted, free of charge, to any person obtaining
14
+ # a copy of this software and associated documentation files (the
15
+ # "Software"), to deal in the Software without restriction, including
16
+ # without limitation the rights to use, copy, modify, merge, publish,
17
+ # distribute, sublicense, and/or sell copies of the Software, and to
18
+ # permit persons to whom the Software is furnished to do so, subject to
19
+ # the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be
22
+ # included in all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
+
32
+ class String
33
+ unless public_method_defined? :to_proc
34
+ def to_proc &block
35
+ params = []
36
+ expr = self
37
+ sections = expr.split(/\s*->\s*/m)
38
+ if sections.length > 1 then
39
+ eval_block(sections.reverse!.inject { |e, p| "(Proc.new { |#{p.split(/\s/).join(', ')}| #{e} })" }, block)
40
+ elsif expr.match(/\b_\b/)
41
+ eval_block("Proc.new { |_| #{expr} }", block)
42
+ else
43
+ leftSection = expr.match(/^\s*(?:[+*\/%&|\^\.=<>\[]|!=)/m)
44
+ rightSection = expr.match(/[+\-*\/%&|\^\.=<>!]\s*$/m)
45
+ if leftSection || rightSection then
46
+ if (leftSection) then
47
+ params.push('$left')
48
+ expr = '$left' + expr
49
+ end
50
+ if (rightSection) then
51
+ params.push('$right')
52
+ expr = expr + '$right'
53
+ end
54
+ else
55
+ self.gsub(
56
+ /(?:\b[A-Z]|\.[a-zA-Z_$])[a-zA-Z_$\d]*|[a-zA-Z_$][a-zA-Z_$\d]*:|self|arguments|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/, ''
57
+ ).scan(
58
+ /([a-z_$][a-z_$\d]*)/i
59
+ ) do |v|
60
+ params.push(v) unless params.include?(v)
61
+ end
62
+ end
63
+ eval_block("Proc.new { |#{params.join(', ')}| #{expr} }", block)
64
+ end
65
+ end
66
+ private
67
+ def eval_block(code, block)
68
+ eval code, block && block.binding
69
+ end
70
+ end
71
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - epitron
@@ -47,6 +47,7 @@ files:
47
47
  - README.rdoc
48
48
  - Rakefile
49
49
  - VERSION
50
+ - epitools.gemspec
50
51
  - lib/epitools.rb
51
52
  - lib/epitools/basetypes.rb
52
53
  - lib/epitools/hexdump.rb
@@ -58,10 +59,12 @@ files:
58
59
  - lib/epitools/pretty_backtrace.rb
59
60
  - lib/epitools/rails.rb
60
61
  - lib/epitools/rash.rb
62
+ - lib/epitools/string_to_proc.rb
61
63
  - spec/basetypes_spec.rb
62
64
  - spec/lcs_spec.rb
63
65
  - spec/metaclass_spec.rb
64
66
  - spec/permutations_spec.rb
67
+ - spec/rash_spec.rb
65
68
  - spec/spec.opts
66
69
  - spec/spec_helper.rb
67
70
  has_rdoc: true