Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eiygy committed Oct 12, 2021
0 parents commit c523f4c
Show file tree
Hide file tree
Showing 34 changed files with 1,947 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .autotest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Autotest.add_hook(:initialize) do |at|
at.add_exception(".git")
end

Autotest.add_hook(:initialize) do |at|
at.clear_mappings

at.add_mapping %r%/^lib/(.*)\.rb$% do |_, m|
possible = File.basename(m[1])
files_matching %r%^test/.*(#{possible}_test|test_#{possible})\.rb$%
end

at.add_mapping(%r%^test/.*\.rb$%) {|filename, _| filename }
end
5 changes: 5 additions & 0 deletions .document
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
README.rdoc
lib/**/*.rb
bin/*
features/**/*.feature
LICENSE
50 changes: 50 additions & 0 deletions .github/workflows/azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will build and push a node.js application to an Azure Web App when a release is created.
#
# This workflow assumes you have already created the target Azure App Service web app.
# For instructions see https://docs.microsoft.com/azure/app-service/app-service-plan-manage#create-an-app-service-plan
#
# To configure this workflow:
#
# 1. For Linux apps, add an app setting called WEBSITE_WEBDEPLOY_USE_SCM and set it to true in your app **before downloading the file**.
# For more instructions see: https://docs.microsoft.com/azure/app-service/configure-common#configure-app-settings
#
# 2. Set up a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE with the value of your Azure publish profile.
# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret
#
# 3. Change the values for the AZURE_WEBAPP_NAME, AZURE_WEBAPP_PACKAGE_PATH and NODE_VERSION environment variables (below).
#
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
on:
release:
types: [created]

env:
AZURE_WEBAPP_NAME: your-app-name # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '10.x' # set this to the node version to use

jobs:
build-and-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: npm install, build, and test
run: |
# Build and test the project, then
# deploy to Azure Web App.
npm install
npm run build --if-present
npm run test --if-present
- name: 'Deploy to Azure WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.sw?
.DS_Store
coverage
rdoc
pkg
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2009 Wynn Netherland

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 changes: 18 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# upcoming-events

Ruby wrapper for the Yahoo! Upcoming Events API.

## Note on Patches/Pull Requests

* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but
bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

## Copyright

Copyright (c) 2009 Wynn Netherland. See LICENSE for details.
69 changes: 69 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
require 'rubygems'
require 'rake'

begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "upcoming-events"
gem.summary = %Q{Ruby wrapper for the Yahoo! Upcoming API}
gem.description = %Q{Find cool events and things to do.}
gem.email = "wynn@squeejee.com"
gem.homepage = "http://github.com/pengwynn/upcoming-events"
gem.authors = ["Wynn Netherland"]
gem.rubyforge_project = "upcoming-events"
gem.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]

gem.add_dependency('mash', '0.0.3')
gem.add_dependency('httparty', '0.4.3')

gem.add_development_dependency('thoughtbot-shoulda')
gem.add_development_dependency('jeremymcanally-matchy')
gem.add_development_dependency('mocha')
gem.add_development_dependency('fakeweb')
gem.add_development_dependency('mash')
end

rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end

require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end

begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |test|
test.libs << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end
rescue LoadError
task :rcov do
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
end
end




task :default => :test

require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
if File.exist?('VERSION.yml')
config = YAML.load(File.read('VERSION.yml'))
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
else
version = ""
end

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "upcoming-events #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end

4 changes: 4 additions & 0 deletions VERSION.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
:patch: 1
:major: 0
:minor: 0
43 changes: 43 additions & 0 deletions lib/upcoming.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'rubygems'

gem 'mash', '~> 0.0.3'
require 'mash'

gem 'httparty', '~> 0.4.3'
require 'httparty'

module Upcoming
class APIKeyNotSet < StandardError; end
module Defaults
def self.included(base)
base.send :include, HTTParty
base.send(:base_uri, 'upcoming.yahooapis.com/services/rest')
base.send(:format, :json)
end
end

def self.api_key=(value)
@api_key = value
end

def self.api_key
@api_key
end

def self.default_options
raise Upcoming::APIKeyNotSet.new("Please get your API key from http://upcoming.yahoo.com/services/api/keygen.php") if self.api_key.blank?
{:api_key => self.api_key, :format => 'json'}
end
end

directory = File.expand_path(File.dirname(__FILE__))
require File.join(directory, 'upcoming', 'auth')
require File.join(directory, 'upcoming', 'user')
require File.join(directory, 'upcoming', 'group')
require File.join(directory, 'upcoming', 'metro')
require File.join(directory, 'upcoming', 'event')
require File.join(directory, 'upcoming', 'category')
require File.join(directory, 'upcoming', 'country')
require File.join(directory, 'upcoming', 'venue')
require File.join(directory, 'upcoming', 'watchlist')
require File.join(directory, 'upcoming', 'state')
39 changes: 39 additions & 0 deletions lib/upcoming/auth.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Upcoming
class Auth
include Upcoming::Defaults

# Retrieve a token from the site, after the user has given your app an authentication Frob
#
# +frob+ (Required)
# The frob passed back to your application.
#
def self.token(frob)
Mash.new(self.get('/', :query => {:method => 'auth.getToken', :frob => frob}.merge(Upcoming.default_options))).rsp.token.first
end

# Retrieve a full token from Upcoming, from just the token code.
# This method should also be called on saved tokens before proceeding to access user data,
# in order to verify that the token has not expired and is valid.
#
# +token+ (Required)
# The token code to check.
#
#
# Step 1: Set up your callback url: http://upcoming.yahoo.com/services/api/keygen.php
#
# Step 2: Call http://upcoming.yahoo.com/services/auth/?api_key=Your API Key
#
# Step 3: Catch the frob querystring parameter on your callback page and pass to Auth.token
#
def self.check_token(token)
token = Upcoming::Auth.token_code(token)
Mash.new(self.get('/', :query => {:method => 'auth.checkToken', :token => token}.merge(Upcoming.default_options))).rsp.token.first
end

# Extracts the token code from a token hash
#
def self.token_code(token)
token.is_a?(Hash) ? token['token'] : token
end
end
end
11 changes: 11 additions & 0 deletions lib/upcoming/category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Upcoming
class Category
include Upcoming::Defaults

# Retrieve a list of valid event categories.
#
def self.list
Mash.new(self.get('/', :query => {:method => 'category.getList'}.merge(Upcoming.default_options))).rsp.category
end
end
end
13 changes: 13 additions & 0 deletions lib/upcoming/country.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Upcoming
class Country
include Upcoming::Defaults

# +country_id+ (Required)
# The country_id number of the country to look within. Country ID's are referred to within other API methods, such as metro.getStateList and state.getInfo. To run getInfo on multiple countries, simply pass an array or a comma-separated list of country_id numbers.
#
def self.info(country_id)
country_id = country_id.join(',') if country_id.is_a?(Array)
Mash.new(self.get('/', :query => {:method => 'country.getInfo', :country_id => country_id}.merge(Upcoming.default_options))).rsp.country
end
end
end
Loading

0 comments on commit c523f4c

Please sign in to comment.