day-of-the-week 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +2 -0
- data/Gemfile +12 -0
- data/Rakefile +2 -0
- data/day-of-the-week.gemspec +23 -0
- data/lib/day-of-the-week.rb +26 -0
- data/lib/day-of-the-week/version.rb +3 -0
- data/spec/day-of-the-week_spec.rb +22 -0
- metadata +64 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in day-of-the-week.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
#gem 'params-validator'
|
7
|
+
|
8
|
+
gem 'params-validator', :git => 'git@github.com:jdbd/params-validator.git', :branch => 'master'
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'rspec'
|
12
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "day-of-the-week/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "day-of-the-week"
|
7
|
+
s.version = DayOfTheWeek::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Juan de Bravo"]
|
10
|
+
s.email = ["juandebravo@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/juandebraco/day-of-the-week"
|
12
|
+
s.summary = %q{This gem helps you to get the week day of a specific date}
|
13
|
+
s.description = %q{This gem helps you to get the week day of a specific date}
|
14
|
+
|
15
|
+
s.rubyforge_project = "day-of-the-week"
|
16
|
+
|
17
|
+
#s.add_dependency("params-validator")
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'params-validator'
|
3
|
+
#require 'logger'
|
4
|
+
|
5
|
+
module DayOfTheWeek
|
6
|
+
extend ParamsValidator::ValidParams
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def get_day(params)
|
11
|
+
validate_method(params) do
|
12
|
+
year(Fixnum){ |year| year <= Time.now.year }
|
13
|
+
month(Fixnum)
|
14
|
+
day(Fixnum)
|
15
|
+
end
|
16
|
+
|
17
|
+
date = Date.new(params[:year], params[:month], params[:day])
|
18
|
+
Date::DAYNAMES[date.wday]
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
require 'day-of-the-week'
|
3
|
+
|
4
|
+
describe DayOfTheWeek do
|
5
|
+
|
6
|
+
it "should return Tuesday when year => 2011, month => 5, day => 17" do
|
7
|
+
DayOfTheWeek::get_day({:year => 2011, :month => 5, :day => 17}).should eql("Tuesday")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise error if no year provided" do
|
11
|
+
lambda {DayOfTheWeek::get_day({:month => 5, :day => 17})}.should raise_error(ArgumentError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should raise error if no month provided" do
|
15
|
+
lambda {DayOfTheWeek::get_day({:year => 2011, :day => 17})}.should raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should raise error if year greater than actual" do
|
19
|
+
lambda {DayOfTheWeek::get_day({:year => 2012, :day => 17})}.should raise_error(ArgumentError)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: day-of-the-week
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Juan de Bravo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-17 00:00:00 +02:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: This gem helps you to get the week day of a specific date
|
18
|
+
email:
|
19
|
+
- juandebravo@gmail.com
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- .rvmrc
|
29
|
+
- Gemfile
|
30
|
+
- Rakefile
|
31
|
+
- day-of-the-week.gemspec
|
32
|
+
- lib/day-of-the-week.rb
|
33
|
+
- lib/day-of-the-week/version.rb
|
34
|
+
- spec/day-of-the-week_spec.rb
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/juandebraco/day-of-the-week
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project: day-of-the-week
|
59
|
+
rubygems_version: 1.6.2
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: This gem helps you to get the week day of a specific date
|
63
|
+
test_files:
|
64
|
+
- spec/day-of-the-week_spec.rb
|