Permalink
Browse files

rename project name from caline to calour; reorganize files

  • Loading branch information...
1 parent e1587f6 commit ee8df4ae9c5a77c04047e0c1de1612a97212c271 @melborne committed Dec 18, 2010
View
@@ -2,8 +2,8 @@
#-*-encoding: utf-8-*-
require "optparse"
require "date"
-require_relative "../lib/caline"
-Version = Caline::VERSION
+require_relative "../lib/calour"
+Version = Calour::VERSION
def parse_argument(args)
mon, year = args.sort
@@ -22,8 +22,8 @@ end
def banner
<<-EOS
- caline - displays a calendar with color
- caline [-3lmnty] [-c [country_code]] [[month] year]
+ calour - displays a calendar with color
+ calour [-3lmnty] [-c [country_code]] [[month] year]
EOS
end
@@ -46,10 +46,10 @@ opt.parse! ARGV rescue opt.parse! ['-h']
mon, year = parse_argument ARGV.map(&:to_i)
if year > 100 && !mon
- cal = Caline::Year.new(year, holidays: OPTS[:holidays])
+ cal = Calour::Year.new(year, holidays: OPTS[:holidays])
puts cal.format(OPTS[:style], OPTS[:from], OPTS[:color], OPTS[:footer])
else
- cal = Caline::Month.new(year, mon)
+ cal = Calour::Month.new(year, mon)
cal.holidays = OPTS[:holidays] if OPTS[:color]
puts cal.format(OPTS[:style], OPTS[:from], OPTS[:color], OPTS[:footer])
end
@@ -2,11 +2,11 @@
#-*-encoding: utf-8-*-
require "date"
require "term/ansicolor"
-require_relative 'month'
-require_relative 'year'
-require_relative "gcalendar"
+require_relative 'calour/month'
+require_relative 'calour/year'
+require_relative "calour/gcalendar"
-module Caline
+module Calour
String.send(:include, Term::ANSIColor)
VERSION = '1.0'
end
@@ -1,4 +1,4 @@
-module Caline
+module Calour
module ColumnForm
def three_columns_formatter(months, from, color)
out, year_label = [], nil
@@ -6,7 +6,7 @@
require "cgi"
require "date"
-module Caline
+module Calour
class GCalendar
def initialize(year, month=nil)
@year, @month = year, month
@@ -69,6 +69,6 @@ def parse_xml_to_hash(xml)
end
if __FILE__ == $0
- g = Caline::GCalendar.new(2010, 9)
+ g = Calour::GCalendar.new(2010, 9)
p g.holidays
end
@@ -2,7 +2,7 @@
#-*-encoding: utf-8-*-
require_relative "column"
-module Caline
+module Calour
class Month
include ColumnForm
@@holidays = Hash.new{ |h, k| h[k] = {} }
@@ -1,14 +1,14 @@
#!/usr/bin/env ruby
#-*-encoding: utf-8-*-
require_relative "column"
-module Caline
+module Calour
class Year
include ColumnForm
@@holidays = Hash.new{ |h, k| h[k] = {} }
def initialize(year, opts={})
@year = year
@code = opts.delete(:holidays)
- @months = (1..12).map { |m| Caline::Month.new(@year, m, opts) }
+ @months = (1..12).map { |m| Calour::Month.new(@year, m, opts) }
if @code
@months.each { |m| m.holidays = @code }
@@holidays[@year] = @months.first.holidays[@year]
View
@@ -1,16 +1,16 @@
require "test/unit"
-require_relative "../lib/gcalendar"
+require_relative "../lib/calour"
class TestLibGcalendar < Test::Unit::TestCase
def test_holidays_for_a_month
- gc = Caline::GCalendar.new(2010, 12)
+ gc = Calour::GCalendar.new(2010, 12)
assert_equal(23, gc.holidays.keys[0].day)
end
def test_holidays_for_a_year
- gc = Caline::GCalendar.new(2010)
+ gc = Calour::GCalendar.new(2010)
puts holidays_ja = gc.holidays.map { |k, v| "#{k.strftime("%m/%d")} => #{v}" }
puts holidays_us = gc.holidays(:us).map { |k, v| "#{k.strftime("%m/%d")} => #{v}" }
end
-end
+end
View
@@ -2,16 +2,16 @@
# -*- encoding:utf-8 -*-
require "test/unit"
-require_relative "../lib/caline"
+require_relative "../lib/calour"
class TestMonth < Test::Unit::TestCase
def setup
- @m = Caline::Month.new(2010, 12)
+ @m = Calour::Month.new(2010, 12)
@lasts2010 = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
end
def test_last_day
- (1..12).each { |m| assert_equal(@lasts2010[m], Caline::Month.new(2010, m).last.day) }
+ (1..12).each { |m| assert_equal(@lasts2010[m], Calour::Month.new(2010, m).last.day) }
end
def test_year_month
@@ -20,7 +20,7 @@ def test_year_month
end
def test_dates
- assert_equal((1..28).to_a, Caline::Month.new(2011, 2).dates(0, false, false).map(&:day))
+ assert_equal((1..28).to_a, Calour::Month.new(2011, 2).dates(0, false, false).map(&:day))
assert_equal((1..31).to_a, @m.dates(0, false, false).map(&:day))
assert_equal([29, 30]+(1..31).to_a, @m.dates(1, true, false).map(&:day))
assert_equal((1..31).to_a+[1], @m.dates(0, false, true).map(&:day))
@@ -134,11 +134,11 @@ def test_holidays
end
def test_color_format_with_color_changes
- m = Caline::Month.new(2011, 2, sunday: :yellow, saturday: :green)
+ m = Calour::Month.new(2011, 2, sunday: :yellow, saturday: :green)
colors = {12 => 32, 13 => 33}.map { |d, c| /\e\[#{c}m#{d}\e\[0m/ }
colors.each { |c| assert_match(c, m.color_format(:line).join) }
- m = Caline::Month.new(2010, 12)
+ m = Calour::Month.new(2010, 12)
m.holidays = :ja_ja
colors = { year: :cyan, month: :red, today: [:blue, :on_yellow],
saturday: :white, sunday: :black, holiday: :blue, neighbor: :black }
View
@@ -1,10 +1,10 @@
require "test/unit"
-require_relative "../lib/caline"
+require_relative "../lib/calour"
class TestYear < Test::Unit::TestCase
def setup
- @y2010 = Caline::Year.new(2010)
+ @y2010 = Calour::Year.new(2010)
end
def test_format_with_block_style
@@ -94,12 +94,12 @@ def test_neighbor_option
"\e[30m28\e[0m \e[30m29\e[0m \e[30m30\e[0m \e[30m31\e[0m 1 2 \e[36m 3\e[0m \e[35m 1\e[0m 2 3 4 5 6 \e[36m 7\e[0m \e[35m 1\e[0m 2 3 4 5 6 \e[36m 7\e[0m",
"\e[35m18\e[0m 19 20 21 22 23 \e[36m24\e[0m \e[35m22\e[0m 23 24 25 26 27 \e[36m28\e[0m \e[35m22\e[0m 23 24 25 26 27 \e[36m28\e[0m", "\e[35m25\e[0m 26 27 28 29 30 \e[36m31\e[0m \e[35m29\e[0m 30 31 \e[30m 1\e[0m \e[30m 2\e[0m \e[30m 3\e[0m \e[30m 4\e[0m"
]
- format = Caline::Year.new(2009, neighbor: :black).color_format.join
+ format = Calour::Year.new(2009, neighbor: :black).color_format.join
y2009.each { |line| assert_match(/#{Regexp.escape line}/, format) }
end
def test_holidays_names
- y = Caline::Year.new(2010, holidays: :ja_ja)
+ y = Calour::Year.new(2010, holidays: :ja_ja)
puts y.color_format
end
end

0 comments on commit ee8df4a

Please sign in to comment.