Hokkaido 0.0.3 → 0.0.4
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/Gemfile +2 -0
- data/Gemfile.lock +2 -2
- data/ansiterm-color/.gitignore +3 -0
- data/ansiterm-color/CHANGES +28 -0
- data/ansiterm-color/COPYING +340 -0
- data/ansiterm-color/README +137 -0
- data/ansiterm-color/Rakefile +88 -0
- data/ansiterm-color/VERSION +1 -0
- data/ansiterm-color/bin/cdiff +19 -0
- data/ansiterm-color/bin/decolor +12 -0
- data/ansiterm-color/doc-main.txt +119 -0
- data/ansiterm-color/examples/example.rb +90 -0
- data/ansiterm-color/install.rb +15 -0
- data/ansiterm-color/lib/term/ansicolor/.keep +0 -0
- data/ansiterm-color/lib/term/ansicolor/version.rb +10 -0
- data/ansiterm-color/lib/term/ansicolor.rb +102 -0
- data/ansiterm-color/make_doc.rb +4 -0
- data/ansiterm-color/tests/ansicolor_test.rb +66 -0
- data/chronic/.gitignore +6 -0
- data/chronic/HISTORY.md +205 -0
- data/chronic/LICENSE +21 -0
- data/chronic/README.md +181 -0
- data/chronic/Rakefile +46 -0
- data/chronic/chronic.gemspec +20 -0
- data/chronic/lib/chronic/grabber.rb +33 -0
- data/chronic/lib/chronic/handler.rb +88 -0
- data/chronic/lib/chronic/handlers.rb +572 -0
- data/chronic/lib/chronic/mini_date.rb +38 -0
- data/chronic/lib/chronic/numerizer.rb +121 -0
- data/chronic/lib/chronic/ordinal.rb +47 -0
- data/chronic/lib/chronic/pointer.rb +32 -0
- data/chronic/lib/chronic/repeater.rb +145 -0
- data/chronic/lib/chronic/repeaters/repeater_day.rb +53 -0
- data/chronic/lib/chronic/repeaters/repeater_day_name.rb +52 -0
- data/chronic/lib/chronic/repeaters/repeater_day_portion.rb +108 -0
- data/chronic/lib/chronic/repeaters/repeater_fortnight.rb +71 -0
- data/chronic/lib/chronic/repeaters/repeater_hour.rb +58 -0
- data/chronic/lib/chronic/repeaters/repeater_minute.rb +58 -0
- data/chronic/lib/chronic/repeaters/repeater_month.rb +79 -0
- data/chronic/lib/chronic/repeaters/repeater_month_name.rb +94 -0
- data/chronic/lib/chronic/repeaters/repeater_season.rb +109 -0
- data/chronic/lib/chronic/repeaters/repeater_season_name.rb +43 -0
- data/chronic/lib/chronic/repeaters/repeater_second.rb +42 -0
- data/chronic/lib/chronic/repeaters/repeater_time.rb +128 -0
- data/chronic/lib/chronic/repeaters/repeater_week.rb +74 -0
- data/chronic/lib/chronic/repeaters/repeater_weekday.rb +85 -0
- data/chronic/lib/chronic/repeaters/repeater_weekend.rb +66 -0
- data/chronic/lib/chronic/repeaters/repeater_year.rb +77 -0
- data/chronic/lib/chronic/scalar.rb +116 -0
- data/chronic/lib/chronic/season.rb +26 -0
- data/chronic/lib/chronic/separator.rb +94 -0
- data/chronic/lib/chronic/span.rb +31 -0
- data/chronic/lib/chronic/tag.rb +36 -0
- data/chronic/lib/chronic/time_zone.rb +32 -0
- data/chronic/lib/chronic/token.rb +47 -0
- data/chronic/lib/chronic.rb +442 -0
- data/chronic/test/helper.rb +12 -0
- data/chronic/test/test_chronic.rb +150 -0
- data/chronic/test/test_daylight_savings.rb +118 -0
- data/chronic/test/test_handler.rb +104 -0
- data/chronic/test/test_mini_date.rb +32 -0
- data/chronic/test/test_numerizer.rb +72 -0
- data/chronic/test/test_parsing.rb +1061 -0
- data/chronic/test/test_repeater_day_name.rb +51 -0
- data/chronic/test/test_repeater_day_portion.rb +254 -0
- data/chronic/test/test_repeater_fortnight.rb +62 -0
- data/chronic/test/test_repeater_hour.rb +68 -0
- data/chronic/test/test_repeater_minute.rb +34 -0
- data/chronic/test/test_repeater_month.rb +50 -0
- data/chronic/test/test_repeater_month_name.rb +56 -0
- data/chronic/test/test_repeater_season.rb +40 -0
- data/chronic/test/test_repeater_time.rb +70 -0
- data/chronic/test/test_repeater_week.rb +62 -0
- data/chronic/test/test_repeater_weekday.rb +55 -0
- data/chronic/test/test_repeater_weekend.rb +74 -0
- data/chronic/test/test_repeater_year.rb +69 -0
- data/chronic/test/test_span.rb +23 -0
- data/chronic/test/test_token.rb +25 -0
- data/lib/Hokkaido/version.rb +1 -1
- data/lib/Hokkaido.rb +13 -9
- data/lib/gem_modifier.rb +23 -3
- data/lib/term/ansicolor.rb +4 -1
- data/spec/Hokkaido/port_spec.rb +15 -7
- metadata +78 -2
@@ -0,0 +1,119 @@
|
|
1
|
+
== Term::ANSIColor - ANSI escape sequences in Ruby
|
2
|
+
|
3
|
+
=== Description
|
4
|
+
|
5
|
+
This library can be used to color/uncolor strings using ANSI escape sequences.
|
6
|
+
|
7
|
+
=== Author
|
8
|
+
|
9
|
+
Florian Frank mailto:flori@ping.de
|
10
|
+
|
11
|
+
=== License
|
12
|
+
|
13
|
+
This is free software; you can redistribute it and/or modify it under the
|
14
|
+
terms of the GNU General Public License Version 2 as published by the Free
|
15
|
+
Software Foundation: www.gnu.org/copyleft/gpl.html
|
16
|
+
|
17
|
+
=== Download
|
18
|
+
|
19
|
+
The latest version of this library can be downloaded at
|
20
|
+
|
21
|
+
* http://rubyforge.org/frs?group_id=391
|
22
|
+
|
23
|
+
The homepage of this library is located at
|
24
|
+
|
25
|
+
* http://term-ansicolor.rubyforge.org
|
26
|
+
|
27
|
+
=== Examples
|
28
|
+
|
29
|
+
The file examples/example.rb in the source/gem-distribution shows how
|
30
|
+
this library can be used:
|
31
|
+
require 'term/ansicolor'
|
32
|
+
|
33
|
+
# Use this trick to work around namespace cluttering that
|
34
|
+
# happens if you just include Term::ANSIColor:
|
35
|
+
|
36
|
+
class Color
|
37
|
+
class << self
|
38
|
+
include Term::ANSIColor
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
43
|
+
print Color.green + "green" + Color.clear, "\n"
|
44
|
+
print Color.on_red(Color.green("green")), "\n"
|
45
|
+
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
46
|
+
|
47
|
+
# Or shortcut Term::ANSIColor by assignment:
|
48
|
+
c = Term::ANSIColor
|
49
|
+
|
50
|
+
print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
|
51
|
+
print c.green + "green" + c.clear, "\n"
|
52
|
+
print c.on_red(c.green("green")), "\n"
|
53
|
+
print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
|
54
|
+
|
55
|
+
# Anyway, I don't define any of Term::ANSIColor's methods in this example
|
56
|
+
# and I want to keep it short:
|
57
|
+
include Term::ANSIColor
|
58
|
+
|
59
|
+
print red, bold, "Usage as constants:", reset, "\n"
|
60
|
+
print clear, "clear", reset, reset, "reset", reset,
|
61
|
+
bold, "bold", reset, dark, "dark", reset,
|
62
|
+
underscore, "underscore", reset, blink, "blink", reset,
|
63
|
+
negative, "negative", reset, concealed, "concealed", reset, "|\n",
|
64
|
+
black, "black", reset, red, "red", reset, green, "green", reset,
|
65
|
+
yellow, "yellow", reset, blue, "blue", reset, magenta, "magenta", reset,
|
66
|
+
cyan, "cyan", reset, white, "white", reset, "|\n",
|
67
|
+
on_black, "on_black", reset, on_red, "on_red", reset,
|
68
|
+
on_green, "on_green", reset, on_yellow, "on_yellow", reset,
|
69
|
+
on_blue, "on_blue", reset, on_magenta, "on_magenta", reset,
|
70
|
+
on_cyan, "on_cyan", reset, on_white, "on_white", reset, "|\n\n"
|
71
|
+
|
72
|
+
print red, bold, "Usage as unary argument methods:", reset, "\n"
|
73
|
+
print clear("clear"), reset("reset"), bold("bold"), dark("dark"),
|
74
|
+
underscore("underscore"), blink("blink"), negative("negative"),
|
75
|
+
concealed("concealed"), "|\n",
|
76
|
+
black("black"), red("red"), green("green"), yellow("yellow"),
|
77
|
+
blue("blue"), magenta("magenta"), cyan("cyan"), white("white"), "|\n",
|
78
|
+
on_black("on_black"), on_red("on_red"), on_green("on_green"),#
|
79
|
+
on_yellow("on_yellow"), on_blue("on_blue"), on_magenta("on_magenta"),
|
80
|
+
on_cyan("on_cyan"), on_white("on_white"), "|\n\n"
|
81
|
+
|
82
|
+
print red { bold { "Usage as block forms:" } }, "\n"
|
83
|
+
print clear { "clear" }, reset { "reset" }, bold { "bold" },
|
84
|
+
dark { "dark" }, underscore { "underscore" }, blink { "blink" },
|
85
|
+
negative { "negative" }, concealed { "concealed" }, "|\n",
|
86
|
+
black { "black" }, red { "red" }, green { "green" },
|
87
|
+
yellow { "yellow" }, blue { "blue" }, magenta { "magenta" },
|
88
|
+
cyan { "cyan" }, white { "white" }, "|\n",
|
89
|
+
on_black { "on_black" }, on_red { "on_red" }, on_green { "on_green" },
|
90
|
+
on_yellow { "on_yellow" }, on_blue { "on_blue" },
|
91
|
+
on_magenta { "on_magenta" }, on_cyan { "on_cyan" },
|
92
|
+
on_white { "on_white" }, "|\n\n"
|
93
|
+
|
94
|
+
# Usage as Mixin into String or its Subclasses
|
95
|
+
class String
|
96
|
+
include Term::ANSIColor
|
97
|
+
end
|
98
|
+
|
99
|
+
print "Usage as String Mixins:".red.bold, "\n"
|
100
|
+
print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
101
|
+
"underscore".underscore, "blink".blink, "negative".negative,
|
102
|
+
"concealed".concealed, "|\n",
|
103
|
+
"black".black, "red".red, "green".green, "yellow".yellow,
|
104
|
+
"blue".blue, "magenta".magenta, "cyan".cyan, "white".white, "|\n",
|
105
|
+
"on_black".on_black, "on_red".on_red, "on_green".on_green,
|
106
|
+
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
107
|
+
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
108
|
+
|
109
|
+
symbols = Term::ANSIColor::attributes
|
110
|
+
print red { bold { "All supported attributes = " } },
|
111
|
+
blue { symbols.inspect }, "\n\n"
|
112
|
+
|
113
|
+
print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
114
|
+
print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
|
115
|
+
|
116
|
+
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
117
|
+
print [ "red".red, "not red anymore".red.uncolored,
|
118
|
+
uncolored { "not red anymore".red }, uncolored("not red anymore".red)
|
119
|
+
].map { |x| x + "\n" }
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'term/ansicolor'
|
2
|
+
|
3
|
+
# Use this trick to work around namespace cluttering that
|
4
|
+
# happens if you just include Term::ANSIColor:
|
5
|
+
|
6
|
+
class Color
|
7
|
+
extend Term::ANSIColor
|
8
|
+
end
|
9
|
+
|
10
|
+
print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
|
11
|
+
print Color.green + "green" + Color.clear, "\n"
|
12
|
+
print Color.on_red(Color.green("green")), "\n"
|
13
|
+
print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
|
14
|
+
|
15
|
+
# Or shortcut Term::ANSIColor by assignment:
|
16
|
+
c = Term::ANSIColor
|
17
|
+
|
18
|
+
print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
|
19
|
+
print c.green + "green" + c.clear, "\n"
|
20
|
+
print c.on_red(c.green("green")), "\n"
|
21
|
+
print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
|
22
|
+
|
23
|
+
# Anyway, I don't define any of Term::ANSIColor's methods in this example
|
24
|
+
# and I want to keep it short:
|
25
|
+
include Term::ANSIColor
|
26
|
+
|
27
|
+
print red, bold, "Usage as constants:", reset, "\n"
|
28
|
+
print clear, "clear", reset, reset, "reset", reset,
|
29
|
+
bold, "bold", reset, dark, "dark", reset,
|
30
|
+
underscore, "underscore", reset, blink, "blink", reset,
|
31
|
+
negative, "negative", reset, concealed, "concealed", reset, "|\n",
|
32
|
+
black, "black", reset, red, "red", reset, green, "green", reset,
|
33
|
+
yellow, "yellow", reset, blue, "blue", reset, magenta, "magenta", reset,
|
34
|
+
cyan, "cyan", reset, white, "white", reset, "|\n",
|
35
|
+
on_black, "on_black", reset, on_red, "on_red", reset,
|
36
|
+
on_green, "on_green", reset, on_yellow, "on_yellow", reset,
|
37
|
+
on_blue, "on_blue", reset, on_magenta, "on_magenta", reset,
|
38
|
+
on_cyan, "on_cyan", reset, on_white, "on_white", reset, "|\n\n"
|
39
|
+
|
40
|
+
print red, bold, "Usage as unary argument methods:", reset, "\n"
|
41
|
+
print clear("clear"), reset("reset"), bold("bold"), dark("dark"),
|
42
|
+
underscore("underscore"), blink("blink"), negative("negative"),
|
43
|
+
concealed("concealed"), "|\n",
|
44
|
+
black("black"), red("red"), green("green"), yellow("yellow"),
|
45
|
+
blue("blue"), magenta("magenta"), cyan("cyan"), white("white"), "|\n",
|
46
|
+
on_black("on_black"), on_red("on_red"), on_green("on_green"),#
|
47
|
+
on_yellow("on_yellow"), on_blue("on_blue"), on_magenta("on_magenta"),
|
48
|
+
on_cyan("on_cyan"), on_white("on_white"), "|\n\n"
|
49
|
+
|
50
|
+
print red { bold { "Usage as block forms:" } }, "\n"
|
51
|
+
print clear { "clear" }, reset { "reset" }, bold { "bold" },
|
52
|
+
dark { "dark" }, underscore { "underscore" }, blink { "blink" },
|
53
|
+
negative { "negative" }, concealed { "concealed" }, "|\n",
|
54
|
+
black { "black" }, red { "red" }, green { "green" },
|
55
|
+
yellow { "yellow" }, blue { "blue" }, magenta { "magenta" },
|
56
|
+
cyan { "cyan" }, white { "white" }, "|\n",
|
57
|
+
on_black { "on_black" }, on_red { "on_red" }, on_green { "on_green" },
|
58
|
+
on_yellow { "on_yellow" }, on_blue { "on_blue" },
|
59
|
+
on_magenta { "on_magenta" }, on_cyan { "on_cyan" },
|
60
|
+
on_white { "on_white" }, "|\n\n"
|
61
|
+
|
62
|
+
# Usage as Mixin into String or its Subclasses
|
63
|
+
class String
|
64
|
+
include Term::ANSIColor
|
65
|
+
end
|
66
|
+
|
67
|
+
print "Usage as String Mixins:".red.bold, "\n"
|
68
|
+
print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
|
69
|
+
"underscore".underscore, "blink".blink, "negative".negative,
|
70
|
+
"concealed".concealed, "|\n",
|
71
|
+
"black".black, "red".red, "green".green, "yellow".yellow,
|
72
|
+
"blue".blue, "magenta".magenta, "cyan".cyan, "white".white, "|\n",
|
73
|
+
"on_black".on_black, "on_red".on_red, "on_green".on_green,
|
74
|
+
"on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
|
75
|
+
"on_cyan".on_cyan, "on_white".on_white, "|\n\n"
|
76
|
+
|
77
|
+
symbols = Term::ANSIColor::attributes
|
78
|
+
print red { bold { "All supported attributes = " } },
|
79
|
+
blue { symbols.inspect }, "\n\n"
|
80
|
+
|
81
|
+
print "Send symbols to strings:".send(:red).send(:bold), "\n"
|
82
|
+
print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
|
83
|
+
|
84
|
+
print red { bold { "Make strings monochromatic again:" } }, "\n"
|
85
|
+
print [
|
86
|
+
"red".red,
|
87
|
+
"not red anymore".red.uncolored,
|
88
|
+
uncolored { "not red anymore".red },
|
89
|
+
uncolored("not red anymore".red)
|
90
|
+
].map { |x| x + "\n" }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
include Config
|
5
|
+
require 'fileutils'
|
6
|
+
include FileUtils::Verbose
|
7
|
+
|
8
|
+
destdir = "#{ENV['DESTDIR']}"
|
9
|
+
libdir = CONFIG["sitelibdir"]
|
10
|
+
dest = destdir + File.join(libdir, 'term')
|
11
|
+
mkdir_p dest
|
12
|
+
install 'lib/term/ansicolor.rb', dest
|
13
|
+
dest = destdir + File.join(libdir, 'term', 'ansicolor')
|
14
|
+
mkdir_p dest
|
15
|
+
install 'lib/term/ansicolor/version.rb', dest
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Term
|
2
|
+
module ANSIColor
|
3
|
+
# Term::ANSIColor version
|
4
|
+
VERSION = '1.0.5'
|
5
|
+
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
|
6
|
+
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
7
|
+
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
8
|
+
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'term/ansicolor/version'
|
2
|
+
|
3
|
+
module Term
|
4
|
+
# The ANSIColor module can be used for namespacing and mixed into your own
|
5
|
+
# classes.
|
6
|
+
module ANSIColor
|
7
|
+
# :stopdoc:
|
8
|
+
ATTRIBUTES = [
|
9
|
+
[ :clear , 0 ],
|
10
|
+
[ :reset , 0 ], # synonym for :clear
|
11
|
+
[ :bold , 1 ],
|
12
|
+
[ :dark , 2 ],
|
13
|
+
[ :italic , 3 ], # not widely implemented
|
14
|
+
[ :underline , 4 ],
|
15
|
+
[ :underscore , 4 ], # synonym for :underline
|
16
|
+
[ :blink , 5 ],
|
17
|
+
[ :rapid_blink , 6 ], # not widely implemented
|
18
|
+
[ :negative , 7 ], # no reverse because of String#reverse
|
19
|
+
[ :concealed , 8 ],
|
20
|
+
[ :strikethrough, 9 ], # not widely implemented
|
21
|
+
[ :black , 30 ],
|
22
|
+
[ :red , 31 ],
|
23
|
+
[ :green , 32 ],
|
24
|
+
[ :yellow , 33 ],
|
25
|
+
[ :blue , 34 ],
|
26
|
+
[ :magenta , 35 ],
|
27
|
+
[ :cyan , 36 ],
|
28
|
+
[ :white , 37 ],
|
29
|
+
[ :on_black , 40 ],
|
30
|
+
[ :on_red , 41 ],
|
31
|
+
[ :on_green , 42 ],
|
32
|
+
[ :on_yellow , 43 ],
|
33
|
+
[ :on_blue , 44 ],
|
34
|
+
[ :on_magenta , 45 ],
|
35
|
+
[ :on_cyan , 46 ],
|
36
|
+
[ :on_white , 47 ],
|
37
|
+
]
|
38
|
+
|
39
|
+
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
40
|
+
# :startdoc:
|
41
|
+
|
42
|
+
# Returns true, if the coloring function of this module
|
43
|
+
# is switched on, false otherwise.
|
44
|
+
def self.coloring?
|
45
|
+
@coloring
|
46
|
+
end
|
47
|
+
|
48
|
+
# Turns the coloring on or off globally, so you can easily do
|
49
|
+
# this for example:
|
50
|
+
# Term::ANSIColor::coloring = STDOUT.isatty
|
51
|
+
def self.coloring=(val)
|
52
|
+
@coloring = val
|
53
|
+
end
|
54
|
+
self.coloring = true
|
55
|
+
|
56
|
+
ATTRIBUTES.each do |c, v|
|
57
|
+
eval %Q{
|
58
|
+
def #{c}(string = nil)
|
59
|
+
result = ''
|
60
|
+
result << "\e[#{v}m" if Term::ANSIColor.coloring?
|
61
|
+
if block_given?
|
62
|
+
result << yield
|
63
|
+
elsif string
|
64
|
+
result << string
|
65
|
+
elsif respond_to?(:to_str)
|
66
|
+
result << to_str
|
67
|
+
else
|
68
|
+
return result #only switch on
|
69
|
+
end
|
70
|
+
result << "\e[0m" if Term::ANSIColor.coloring?
|
71
|
+
result
|
72
|
+
end
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
# Regular expression that is used to scan for ANSI-sequences while
|
77
|
+
# uncoloring strings.
|
78
|
+
COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
|
79
|
+
|
80
|
+
# Returns an uncolored version of the string, that is all
|
81
|
+
# ANSI-sequences are stripped from the string.
|
82
|
+
def uncolored(string = nil) # :yields:
|
83
|
+
if block_given?
|
84
|
+
yield.gsub(COLORED_REGEXP, '')
|
85
|
+
elsif string
|
86
|
+
string.gsub(COLORED_REGEXP, '')
|
87
|
+
elsif respond_to?(:to_str)
|
88
|
+
to_str.gsub(COLORED_REGEXP, '')
|
89
|
+
else
|
90
|
+
''
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
module_function
|
95
|
+
|
96
|
+
# Returns an array of all Term::ANSIColor attributes as symbols.
|
97
|
+
def attributes
|
98
|
+
ATTRIBUTE_NAMES
|
99
|
+
end
|
100
|
+
extend self
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'term/ansicolor'
|
5
|
+
|
6
|
+
class String
|
7
|
+
include Term::ANSIColor
|
8
|
+
end
|
9
|
+
|
10
|
+
class Color
|
11
|
+
extend Term::ANSIColor
|
12
|
+
end
|
13
|
+
|
14
|
+
class ANSIColorTest < Test::Unit::TestCase
|
15
|
+
include Term::ANSIColor
|
16
|
+
|
17
|
+
def setup
|
18
|
+
@string = "red"
|
19
|
+
@string_red = "\e[31mred\e[0m"
|
20
|
+
@string_red_on_green = "\e[42m\e[31mred\e[0m\e[0m"
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :string, :string_red, :string_red_on_green
|
24
|
+
|
25
|
+
def test_red
|
26
|
+
assert_equal string_red, string.red
|
27
|
+
assert_equal string_red, Color.red(string)
|
28
|
+
assert_equal string_red, Color.red { string }
|
29
|
+
assert_equal string_red, Term::ANSIColor.red { string }
|
30
|
+
assert_equal string_red, red { string }
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_red_on_green
|
34
|
+
assert_equal string_red_on_green, string.red.on_green
|
35
|
+
assert_equal string_red_on_green, Color.on_green(Color.red(string))
|
36
|
+
assert_equal string_red_on_green, Color.on_green { Color.red { string } }
|
37
|
+
assert_equal string_red_on_green,
|
38
|
+
Term::ANSIColor.on_green { Term::ANSIColor.red { string } }
|
39
|
+
assert_equal string_red_on_green, on_green { red { string } }
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def test_uncolored
|
44
|
+
assert_equal string, string_red.uncolored
|
45
|
+
assert_equal string, Color.uncolored(string_red)
|
46
|
+
assert_equal string, Color.uncolored { string_red }
|
47
|
+
assert_equal string, Term::ANSIColor.uncolored { string_red }
|
48
|
+
assert_equal string, uncolored { string }
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_attributes
|
52
|
+
foo = 'foo'
|
53
|
+
for (a, _) in Term::ANSIColor.attributes
|
54
|
+
assert_not_equal foo, foo_colored = foo.__send__(a)
|
55
|
+
assert_equal foo, foo_colored.uncolored
|
56
|
+
assert_not_equal foo, foo_colored = Color.__send__(a, foo)
|
57
|
+
assert_equal foo, Color.uncolored(foo_colored)
|
58
|
+
assert_not_equal foo, foo_colored = Color.__send__(a) { foo }
|
59
|
+
assert_equal foo, Color.uncolored { foo_colored }
|
60
|
+
assert_not_equal foo, foo_colored = Term::ANSIColor.__send__(a) { foo }
|
61
|
+
assert_equal foo, Term::ANSIColor.uncolored { foo_colored }
|
62
|
+
assert_not_equal foo, foo_colored = __send__(a) { foo }
|
63
|
+
assert_equal foo, uncolored { foo }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/chronic/.gitignore
ADDED
data/chronic/HISTORY.md
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
# 0.8.0 / 2012-09-16
|
2
|
+
|
3
|
+
* Support parsing "<ordinal> of this month" (#109)
|
4
|
+
* Support parsing ISO 8601 format (#115)
|
5
|
+
* Support parsing "on <day>" without a timestamp (#117)
|
6
|
+
* Fix time parsing regexp (#125)
|
7
|
+
* Support time when parsing dd-mm-yyy <time> (#126)
|
8
|
+
* Allow anchor handler to accept any separators (at, on) (#128)
|
9
|
+
* Support parsing EXIF date format (#112)
|
10
|
+
* Start using minitest for testing
|
11
|
+
* Ensure periods are interpreted as colons (#81).
|
12
|
+
* Support month/day and day/month parsing (#59).
|
13
|
+
* Support day(scalar)-month(name)-year(scalar) (#99).
|
14
|
+
* Handle text starting with 'a' or 'an' (#101, @steveburkett).
|
15
|
+
* Ensure post medium timestamps are correctly formatted (#89)
|
16
|
+
|
17
|
+
# 0.6.7 / 2012-01-31
|
18
|
+
|
19
|
+
* Handle day, month names with scalar day and year (Joe Fiorini)
|
20
|
+
* Ensure 31st parses correctly with day names (Joe Fiorini)
|
21
|
+
|
22
|
+
# 0.6.6 / 2011-11-23
|
23
|
+
|
24
|
+
* `Chronic.parse('thur')` no longer returns `nil` (@harold)
|
25
|
+
|
26
|
+
# 0.6.5 / 2011-11-04
|
27
|
+
|
28
|
+
* Fix bug when parsing ordinal repeaters (#73)
|
29
|
+
* Added handler support for day_name month_name (@imme5150)
|
30
|
+
* Fix bug when parsing strings prefixed with PM
|
31
|
+
|
32
|
+
# 0.6.4 / 2011-08-08
|
33
|
+
|
34
|
+
* Fixed bug where 'noon' was parsed as 00:00 rather than 12:00
|
35
|
+
with :ambiguous_time_range => :none (Vladimir Chernis)
|
36
|
+
* Add support for handling '2009 May 22nd'
|
37
|
+
* Add the ability to handle scalar-day/repeater-month-name as well as ordinals
|
38
|
+
|
39
|
+
# 0.6.3 / 2011-08-01
|
40
|
+
|
41
|
+
* Ensure 'thu' is parsed as Thursday for 1.8.7 generic timestamp
|
42
|
+
|
43
|
+
# 0.6.2 / 2011-07-28
|
44
|
+
|
45
|
+
* Ensure specific endian handlers are prioritised over normal date handlers
|
46
|
+
* Recognize UTC as timezone and accept HH::MM timezone offset (Jason Dusek)
|
47
|
+
|
48
|
+
# 0.6.1 / 2011-07-21
|
49
|
+
|
50
|
+
* Ensure Handler definitions are executed in the correct order
|
51
|
+
|
52
|
+
# 0.6.0 / 2011-07-19
|
53
|
+
|
54
|
+
* Attempting to parse strings with days past the last day of a month will
|
55
|
+
now return nil. ex: `Chronic.parse("30th February") #=> nil`
|
56
|
+
* All deprecated methods are marked for removal in Chronic 0.7.0
|
57
|
+
* Deprecated `Chronic.numericize_numbers` instead use
|
58
|
+
`Chronic::Numerizer.numerize`
|
59
|
+
* Deprecated `Chronic::InvalidArgumentException` and instead use
|
60
|
+
`ArgumentError`
|
61
|
+
* Deprecated `Time.construct` and use `Chronic.construct` in place of this
|
62
|
+
* Deprecated `Time#to_minidate`, instead use `Chronic::MiniDate.from_time(time)`
|
63
|
+
* Add support for handling generic timestamp for Ruby 1.9+
|
64
|
+
|
65
|
+
# 0.5.0 / 2011-07-01
|
66
|
+
|
67
|
+
* Replace commas with spaces instead of removing the char (Thomas Walpole)
|
68
|
+
* Added tests for RepeaterSeason
|
69
|
+
* Re-factored tests. Now rather than having a test_parsing method for testing
|
70
|
+
all handlers, break them down independent of handler method. For example
|
71
|
+
with handler `handle_sm_sd_sy` the subsequent test would be
|
72
|
+
`test_handle_sm_sd_sy`
|
73
|
+
* Added support for parsing ordinal-dates/month-names/year, ie:
|
74
|
+
`2nd of May 1995`
|
75
|
+
* Added support for parsing ordinal-dates and month names, ie:
|
76
|
+
`22nd of February at 6:30pm`
|
77
|
+
* Fix `Time.construct` leap year checking. Instead use `Date.leap?(year)`
|
78
|
+
|
79
|
+
# 0.4.4 / 2011-06-12
|
80
|
+
|
81
|
+
* Fix RepeaterYear for fetching past year offsets when the current day is
|
82
|
+
later than the last day of the same month in a past year (leap years) ie
|
83
|
+
on 29th/feb (leap year) `last year` should (and now does) return 28th/feb
|
84
|
+
instead of 1st/march
|
85
|
+
* Opt in for gem testing http://test.rubygems.org/
|
86
|
+
|
87
|
+
# 0.4.3 / 2011-06-08
|
88
|
+
|
89
|
+
* Fix issue with parsing 1:xxPM -- Ensure 1 is treated as ambiguous, not
|
90
|
+
just >1
|
91
|
+
|
92
|
+
# 0.4.2 / 2011-06-07
|
93
|
+
|
94
|
+
* Fix MonthRepeater for fetching past month offsets when current day is
|
95
|
+
later than the last day of a past month (ie on 29th of March when parsing
|
96
|
+
`last month` Chronic would return March instead of February. Now Chronic
|
97
|
+
returns the last day of the past month)
|
98
|
+
|
99
|
+
# 0.4.1 / 2011-06-05
|
100
|
+
|
101
|
+
* Fix MiniDate ranges for parsing seasons (Thomas Walpole)
|
102
|
+
|
103
|
+
# 0.4.0 / 2011-06-04
|
104
|
+
|
105
|
+
* Ensure context is being passed through grabbers. Now "Sunday at 2:18pm"
|
106
|
+
with `:context => :past` will return the correct date
|
107
|
+
* Support parsing ordinal strings (eg first, twenty third => 1st, 23rd)
|
108
|
+
* Seasons now ignore DST and return 00 as an hour
|
109
|
+
* Support parsing 2 digit years and added `ambiguous_year_future_bias` option
|
110
|
+
* Support parsing 'thurs' for Thursday
|
111
|
+
* Fix pre_normalize() to remove periods before numerizing
|
112
|
+
* Fix RepeaterDays to not add an extra hour in future tense. This meant
|
113
|
+
when parsing 'yesterday' after 11PM, Chronic would return today
|
114
|
+
* Discard any prefixed 0 for time strings when using post noon portion
|
115
|
+
* Gemspec updates for RubyGems deprecations
|
116
|
+
* Ensure 0:10 is treated like 00:10
|
117
|
+
* Ensure we load classes after setting Chronic class instance variables
|
118
|
+
so we can debug initialization and do assignments at compile time
|
119
|
+
* Added a Tag.scan_for method for DRYing up some scanning code
|
120
|
+
* Move some classes into their own files for maintainability
|
121
|
+
* Numerizer.andition should be a private class method, make it so
|
122
|
+
* Namespaced Numerizer, Season and MiniDate (Sascha Teske)
|
123
|
+
* Support for Ruby 1.9 (Dave Lee, Aaron Hurley)
|
124
|
+
* Fix `:context => :past` where parsed date is in current month (Marc Hedlund)
|
125
|
+
* Fix undefined variable in RepeaterHour (Ryan Garver)
|
126
|
+
* Added support for parsing 'Fourty' as another mis-spelling (Lee Reilly)
|
127
|
+
* Added ordinal format support: ie 'February 14th, 2004' (Jeff Felchner)
|
128
|
+
* Fix dates when working with daylight saving times (Mike Mangino)
|
129
|
+
|
130
|
+
# 0.3.0 / 2010-10-22
|
131
|
+
|
132
|
+
* Fix numerizer number combination bug (27 Oct 2006 7:30pm works now)
|
133
|
+
* Allow numeric timezone offset (e.g -0500)
|
134
|
+
* Disregard commas (so as to not return nil)
|
135
|
+
* Fix parse of (am|pm|oclock) separation to handle "Ham sandwich" properly
|
136
|
+
* Handle 'on' e.g. 5pm on Monday
|
137
|
+
* Support seasons
|
138
|
+
* Support weekend/weekday
|
139
|
+
* Add endianness option
|
140
|
+
* Update version number in the module
|
141
|
+
* Fix/improve logic checks in Ordinal, and Scalar
|
142
|
+
* Parse 'a' or 'p' as 'am' and 'pm' google-calendar style
|
143
|
+
* Dates < 1 are not valid
|
144
|
+
* Fix bugs related to timezone offset
|
145
|
+
* Use RakeGem for build management
|
146
|
+
* Reformat README and HISTORY to use Markdown
|
147
|
+
* Global whitespace removal
|
148
|
+
|
149
|
+
# 0.2.3
|
150
|
+
|
151
|
+
* Fix 12am/12pm
|
152
|
+
|
153
|
+
# 0.2.2
|
154
|
+
|
155
|
+
* Add missing files (damn you manifest)
|
156
|
+
|
157
|
+
# 0.2.1
|
158
|
+
|
159
|
+
* Fix time overflow issue
|
160
|
+
* Implement "next" for minute repeater
|
161
|
+
* Generalize time dealiasing to dealias regardless of day portion and
|
162
|
+
time position
|
163
|
+
* Add additional token match for cases like "friday evening at 7" and
|
164
|
+
"tomorrow evening at 7"
|
165
|
+
* Add support for Time#to_s output format: "Mon Apr 02 17:00:00 PDT 2007"
|
166
|
+
|
167
|
+
# 0.2.0 2007-03-20
|
168
|
+
|
169
|
+
* Implement numerizer, allowing the use of number words (e.g. five weeks ago)
|
170
|
+
|
171
|
+
# 0.1.6 2006-01-15
|
172
|
+
|
173
|
+
* Add 'weekend' support
|
174
|
+
|
175
|
+
# 0.1.5 2006-12-20
|
176
|
+
|
177
|
+
* Fix 'aug 20' returning next year if current month is august
|
178
|
+
* Modify behavior of 'from now'
|
179
|
+
* Add support for seconds on times, and thus db timestamp format:
|
180
|
+
"2006-12-20 18:04:23"
|
181
|
+
* Make Hoe compliant
|
182
|
+
|
183
|
+
# 0.1.4
|
184
|
+
|
185
|
+
* Remove verbose error checking code. oops. :-/
|
186
|
+
|
187
|
+
# 0.1.3
|
188
|
+
|
189
|
+
* improved regexes for word variations
|
190
|
+
* Fix a bug that caused "today at 3am" to return nil if current time is
|
191
|
+
after 3am
|
192
|
+
|
193
|
+
# 0.1.2
|
194
|
+
|
195
|
+
* Remove Date dependency (now works on windows properly without fiddling)
|
196
|
+
|
197
|
+
# 0.1.1
|
198
|
+
|
199
|
+
* Run to_s on incoming object
|
200
|
+
* Fix loop loading of repeaters files (out of order on some machines)
|
201
|
+
* Fix find_within to use this instead of next (was breaking "today at 6pm")
|
202
|
+
|
203
|
+
# 0.1.0
|
204
|
+
|
205
|
+
* Initial release
|
data/chronic/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) Tom Preston-Werner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|