pretty_match_data 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/lib/pretty_match_data.rb +18 -0
- data/pretty_match_data.gemspec +22 -0
- metadata +70 -0
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'term/ansicolor'
|
2
|
+
class MatchData
|
3
|
+
include Term::ANSIColor
|
4
|
+
|
5
|
+
def to_s
|
6
|
+
match = self[0].dup
|
7
|
+
to_a[1..-1].each do |capture|
|
8
|
+
match.gsub!(capture) { |s| underline { send(_next_color) { s } } }
|
9
|
+
end
|
10
|
+
pre_match + underline { match } + post_match
|
11
|
+
end
|
12
|
+
|
13
|
+
def _next_color
|
14
|
+
@_color ||= %w(red green yellow blue magenta cyan).map { |c| c.to_sym }
|
15
|
+
@_color.push @_color.shift
|
16
|
+
@_color[0]
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "pretty_match_data"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["jugyo"]
|
9
|
+
s.email = ["jugyo.org@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/jugyo/pretty_match_data"
|
11
|
+
s.summary = %q{pretty MatchData}
|
12
|
+
s.description = %q{pretty MatchData. It provides pretty #to_s method}
|
13
|
+
|
14
|
+
s.rubyforge_project = "pretty_match_data"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency "term-ansicolor"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pretty_match_data
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- jugyo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-21 00:00:00 +09:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: term-ansicolor
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: "pretty MatchData. It provides pretty #to_s method"
|
28
|
+
email:
|
29
|
+
- jugyo.org@gmail.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- Gemfile
|
38
|
+
- Rakefile
|
39
|
+
- lib/pretty_match_data.rb
|
40
|
+
- pretty_match_data.gemspec
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: https://github.com/jugyo/pretty_match_data
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project: pretty_match_data
|
65
|
+
rubygems_version: 1.6.0
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: pretty MatchData
|
69
|
+
test_files: []
|
70
|
+
|