enrico 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.5
data/enrico.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "enrico"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kalle Saas"]
data/lib/enrico.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "httparty"
4
4
  require 'json'
5
5
  require 'active_support/all'
6
+ require "addressable/uri"
6
7
 
7
8
  Dir[File.dirname(__FILE__) + '/enrico/*.rb'].each do |file|
8
9
  require file
@@ -59,20 +59,30 @@ module Enrico
59
59
  vacation_days
60
60
  end
61
61
 
62
+ def country_parameters(params)
63
+ base = { country: self.country_code, region: self.region }
64
+ base.merge!(params)
65
+ base.to_query
66
+ end
67
+
62
68
  def is_public_holiday(date)
63
- JSON.parse(self.class.get("/?action=isPublicHoliday&date=#{date.strftime("%d-%m-%Y")}&country=#{URI::encode(self.country_code)}&region=#{URI::encode(self.region)}"))
69
+ params = country_parameters({date: date.strftime("%d-%m-%Y")})
70
+ JSON.parse(self.class.get("/?action=isPublicHoliday&#{params}"))
64
71
  end
65
72
 
66
73
  def get_public_holidays_for_month(date)
67
- JSON.parse(self.class.get("/?action=getPublicHolidaysForMonth&month=#{date.month}&year=#{date.year}&country=#{URI::encode(self.country_code)}&region=#{URI::encode(self.region)}"))
74
+ params = country_parameters({month: date.month, year: date.year})
75
+ JSON.parse(self.class.get("/?action=getPublicHolidaysForMonth&#{params}"))
68
76
  end
69
77
 
70
78
  def get_public_holidays_for_year(date)
71
- JSON.parse(self.class.get("/?action=getPublicHolidaysForYear&year=#{date.year}&country=#{URI::encode(self.country_code)}&region=#{URI::encode(self.region)}"))
79
+ params = country_parameters({year: date.year})
80
+ JSON.parse(self.class.get("/?action=getPublicHolidaysForYear&#{params}"))
72
81
  end
73
82
 
74
83
  def get_public_holidays_for_date_range(from_date, to_date)
75
- JSON.parse(self.class.get("/?action=getPublicHolidaysForDateRange&fromDate=#{from_date.strftime("%d-%m-%Y")}&toDate=#{to_date.strftime("%d-%m-%Y")}&country=#{URI::encode(self.country_code)}&region=#{URI::encode(self.region)}"))
84
+ params = country_parameters({fromDate: from_date.strftime("%d-%m-%Y"), toDate: to_date.strftime("%d-%m-%Y")})
85
+ JSON.parse(self.class.get("/?action=getPublicHolidaysForDateRange&#{params}"))
76
86
  end
77
87
 
78
88
  end
@@ -100,4 +100,33 @@ http_interactions:
100
100
  Year''s Day"}]'
101
101
  http_version:
102
102
  recorded_at: Thu, 29 Nov 2012 16:56:36 GMT
103
+ - request:
104
+ method: get
105
+ uri: http://kayaposoft.com/enrico/json/v1.0/?action=getPublicHolidaysForDateRange&country=ger&from_date=01-01-2012&region=&to_date=01-03-2012
106
+ body:
107
+ encoding: US-ASCII
108
+ string: ''
109
+ headers: {}
110
+ response:
111
+ status:
112
+ code: 200
113
+ message: OK
114
+ headers:
115
+ Server:
116
+ - nginx
117
+ Date:
118
+ - Fri, 30 Nov 2012 12:32:31 GMT
119
+ Content-Type:
120
+ - text/html
121
+ Content-Length:
122
+ - '50'
123
+ Connection:
124
+ - keep-alive
125
+ Vary:
126
+ - User-Agent,Accept-Encoding
127
+ body:
128
+ encoding: US-ASCII
129
+ string: ! '{"error":"Query parameter ''fromDate'' is not set!"}'
130
+ http_version:
131
+ recorded_at: Fri, 30 Nov 2012 12:28:58 GMT
103
132
  recorded_with: VCR 2.3.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enrico
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -169,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  segments:
171
171
  - 0
172
- hash: -3664893538224163374
172
+ hash: -4538822451665088345
173
173
  required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  none: false
175
175
  requirements: