copyright 0.1.3 → 0.1.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/README.md +5 -0
- data/VERSION +1 -1
- data/copyright.gemspec +2 -1
- data/lib/copyright.rb +1 -0
- data/lib/copyright_helper.rb +6 -4
- data/test/test_copyright.rb +3 -3
- metadata +2 -1
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/copyright.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{copyright}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Takaaki Kato"]
|
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
"doc/method_list.html",
|
46
46
|
"doc/top-level-namespace.html",
|
47
47
|
"init.rb",
|
48
|
+
"lib/copyright.rb",
|
48
49
|
"lib/copyright_helper.rb",
|
49
50
|
"test/test_copyright.rb",
|
50
51
|
"test/test_helper.rb"
|
data/lib/copyright.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "copyright_helper"
|
data/lib/copyright_helper.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# Adds a method for copyright period
|
4
4
|
# @author Takaaki Kato <takaaki.kato@gmail.com>
|
5
5
|
module CopyrightHelper
|
6
|
+
require 'date'
|
7
|
+
|
6
8
|
# Returns copyright period in years
|
7
9
|
# @example When the argument is the year of now
|
8
10
|
# copyright_years(2009) #=> "2009"
|
@@ -11,10 +13,10 @@ module CopyrightHelper
|
|
11
13
|
# @param [#is_a?(Integer)]
|
12
14
|
def copyright_years(since)
|
13
15
|
raise ArgumentError, "Argument should be a number" unless since.is_a?(Integer)
|
14
|
-
raise ArgumentError, "since should not be a future" if
|
15
|
-
if
|
16
|
-
since
|
17
|
-
else
|
16
|
+
raise ArgumentError, "since should not be a future" if since > Date.today.year
|
17
|
+
if since == Date.today.year
|
18
|
+
"#{since}"
|
19
|
+
else
|
18
20
|
"#{since}-#{Date.today.year}"
|
19
21
|
end
|
20
22
|
end
|
data/test/test_copyright.rb
CHANGED
@@ -8,10 +8,10 @@ class CopyrightYearTest < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
def setup
|
10
10
|
@today = Date.stubs(:today).returns(Date.civil(2009))
|
11
|
-
|
11
|
+
@today.stubs(:year).returns(2009)
|
12
12
|
end
|
13
13
|
|
14
|
-
should "raise when an argument is not
|
14
|
+
should "raise when an argument is not a number" do
|
15
15
|
assert_raise(ArgumentError) { copyright_years() }
|
16
16
|
assert_raise(ArgumentError) { copyright_years("123") }
|
17
17
|
assert_nothing_raised { copyright_years(2004) }
|
@@ -19,7 +19,7 @@ class CopyrightYearTest < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
should "returen the number of 'since' when the 'since' is the year of today" do
|
22
|
-
assert_equal(2009
|
22
|
+
assert_equal("2009", copyright_years(@today.year))
|
23
23
|
end
|
24
24
|
|
25
25
|
should "return 2009 - 2010 when the argument is not the year of 'since'" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copyright
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takaaki Kato
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- doc/method_list.html
|
71
71
|
- doc/top-level-namespace.html
|
72
72
|
- init.rb
|
73
|
+
- lib/copyright.rb
|
73
74
|
- lib/copyright_helper.rb
|
74
75
|
- test/test_copyright.rb
|
75
76
|
- test/test_helper.rb
|