Ruby library

This commit is contained in:
Josh Sherman 2016-08-30 23:49:50 -05:00
parent 9642005814
commit 6d95a482ec
4 changed files with 57 additions and 3 deletions

6
.gitignore vendored
View file

@ -42,9 +42,9 @@ build-iPhoneSimulator/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset
Gemfile.lock
.ruby-version
.ruby-gemset
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

5
Gemfile Normal file
View file

@ -0,0 +1,5 @@
source "https://rubygems.org"
gem "addressable"
gemspec

36
lib/ruby-holidayapi.rb Normal file
View file

@ -0,0 +1,36 @@
require 'addressable/uri'
require 'json'
require 'net/http'
require 'openssl'
module HolidayAPI
class V1
def initialize(key = false)
@key = key
end
def holidays(params = Hash.new)
if !params.has_key?('key')
params['key'] = @key
end
uri = Addressable::URI.new
uri.query_values = params
uri = URI("https://holidayapi.com/v1/holidays?#{uri.query}")
Net::HTTP.start(
uri.host,
uri.port,
:use_ssl => true,
:verify_mode => OpenSSL::SSL::VERIFY_NONE
) do |http|
request = Net::HTTP::Get.new uri
response = http.request request
return JSON.parse(response.body)
end
end
end
end

13
ruby-holidayapi.gemspec Normal file
View file

@ -0,0 +1,13 @@
Gem::Specification.new do |s|
s.name = 'ruby-holidayapi'
s.version = '1.0.0'
s.date = '2016-08-30'
s.summary = 'Official Ruby library for Holiday API'
s.description = 'Official Ruby library for Holiday API'
s.authors = ['Josh Sherman']
s.email = 'hello@holidayapi.com'
s.files = ['lib/ruby-holidayapi.rb']
s.homepage = 'https://holidayapi.com'
s.license = 'MIT'
end