-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from tom-lord/named-property-lambda
Named properties saved in PStore, for each ruby version
- Loading branch information
Showing
12 changed files
with
156 additions
and
336 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
unicode_ranges_2.0.pstore |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
Dir[File.dirname(__FILE__) + '/regexp-examples/**/*.rb'].each {|file| require file } | ||
require_relative "regexp-examples/unicode_char_ranges" | ||
require_relative "regexp-examples/backreferences" | ||
require_relative "regexp-examples/chargroup_parser" | ||
require_relative "regexp-examples/constants" | ||
require_relative "regexp-examples/groups" | ||
require_relative "regexp-examples/helpers" | ||
require_relative "regexp-examples/parser" | ||
require_relative "regexp-examples/repeaters" | ||
require_relative "regexp-examples/unicode_char_ranges" | ||
require_relative "regexp-examples/version" | ||
require_relative "core_extensions/regexp/examples" | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'pstore' | ||
|
||
module RegexpExamples | ||
class UnicodeCharRanges | ||
|
||
# These values were generated by: scripts/unicode_lister.rb | ||
# Note: Only the first 128 results are listed, for performance. | ||
# Also, some groups seem to have no matches (weird!) | ||
# (Don't care about ruby micro version number) | ||
STORE_FILENAME = "unicode_ranges_#{RUBY_VERSION[0..2]}.pstore" | ||
|
||
attr_reader :range_store | ||
|
||
def initialize(location="db/#{STORE_FILENAME}") | ||
@range_store = PStore.new(location) | ||
end | ||
|
||
def get(key) | ||
range_store.transaction(true) do | ||
ranges_to_unicode(range_store[key]) | ||
end | ||
end | ||
|
||
alias_method :[], :get | ||
|
||
private | ||
|
||
# TODO: Document example input/output of this method | ||
# It's pretty simple, but this code is a little confusing!! | ||
def ranges_to_unicode(ranges) | ||
result = [] | ||
ranges.each do |range| | ||
if range.is_a? Fixnum # Small hack to increase data compression | ||
result << hex_to_unicode(range.to_s(16)) | ||
else | ||
range.each { |num| result << hex_to_unicode(num.to_s(16)) } | ||
end | ||
end | ||
result | ||
end | ||
|
||
def hex_to_unicode(hex) | ||
eval("?\\u{#{hex}}") | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module RegexpExamples | ||
VERSION = '1.1.0' | ||
VERSION = '1.1.1' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.