Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit Riessen committed Aug 31, 2011
2 parents 860a5f1 + 17ffc88 commit 900d328
Show file tree
Hide file tree
Showing 17 changed files with 527 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .document
@@ -0,0 +1,5 @@
lib/**/*.rb
bin/*
-
features/**/*.feature
LICENSE.txt
50 changes: 50 additions & 0 deletions .gitignore
@@ -0,0 +1,50 @@
# rcov generated
coverage

# rdoc generated
rdoc

# yard generated
doc
.yardoc

# bundler
.bundle

# jeweler generated
pkg

# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
#
# * Create a file at ~/.gitignore
# * Include files you want ignored
# * Run: git config --global core.excludesfile ~/.gitignore
#
# After doing this, these files will be ignored in all your git projects,
# saving you from having to 'pollute' every project you touch with them
#
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
#
# For MacOS:
#
#.DS_Store

# For TextMate
#*.tmproj
#tmtags

# For emacs:
#*~
#\#*
#.\#*

# For vim:
#*.swp

# For redcar:
#.redcar

# For rubinius:
#*.rbc
Gemfile.lock
test/.login.yml
1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm use --create ree-1.8.7-2011.03@hfcapi
18 changes: 18 additions & 0 deletions Gemfile
@@ -0,0 +1,18 @@
# -*- mode: ruby -*-
source "http://rubygems.org"

gem 'rest-client'
gem 'json'

group :development do
gem 'rake', "= 0.8.7"
gem 'pry'
gem 'pry-doc'
gem 'gist'
gem "thoughtbot-shoulda", ">= 0"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.6.4"
gem "rcov", ">= 0"
gem 'rr'
gem "cheat"
end
20 changes: 20 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,20 @@
Copyright (c) 2011 Gerrit Riessen

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.
75 changes: 75 additions & 0 deletions README.rdoc
@@ -0,0 +1,75 @@
= hitfox_coupon_api

Simple interface to the HitFox.com coupon API. Audience of this gem are publisher who have
integrated HitFox and wish to interface with HitFox to obtain and send information to deal
coupons being sold.

== Installation

Installation is either

gem install hitfox_coupon_api

Or if using bundler, in the Gemfile

gem 'hitfox_coupon_api'

The latest version can be used via github but including git option in the Gemfile:

gem 'hitfox_coupon_api', :git => 'git://github.com/gorenje/hitfox_coupon_api.git'


== Configuration

To configure the gem, you'll need API authentication details from HitFox. Once you have
these, then configuration is a matter of doing:

HitfoxCouponApi.configure do |config|
config.api_token = 'your api token'
config.api_secret = 'your api secret'
config.api_version = 'the api version as provided by HitFox.com'
config.api_endpoint = 'the api endpoint as provided by HitFox.com'
end

If using Rails, then this is best done in a config/initializer and perhaps storing the
configuration data in a separate yaml file.

== Usage

At the moment, this gem can do one thing but that really well: provide feedback to HitFox
when a coupon has been used.

This is done by providing the application id (also generated by HitFox) and the coupon id
that goes from you:

HitfoxCouponApi.application('app id from hitfox').coupon('coupon code').used

that's it. But you can also keep the application object around and use it for subsequent
calls:

# best done in Rails in an initializer
MyGlobalApplication = HitfoxCouponApi.application('app id from hitfox')

... some time later ...

MyGlobalApplication.coupon("fubar").used
MyGlobalApplication.coupon("snafu also").used

Other than that, there is not much else to see here! More features will appear as we develop
them.

== Contributing to hitfox_coupon_api

* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2011 Gerrit Riessen. See LICENSE.txt for
further details.

53 changes: 53 additions & 0 deletions Rakefile
@@ -0,0 +1,53 @@
# encoding: utf-8

require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'

require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
gem.name = "hitfox_coupon_api"
gem.homepage = "https://github.com/gorenje/hitfox_coupon_api"
gem.license = "MIT"
gem.summary = %Q{Simple JSON interface to the HitFox coupon API}
gem.description = %Q{Simple JSON interface to the HitFox coupon API}
gem.email = "gerrit.riessen@gmail.com"
gem.authors = ["Gerrit Riessen"]
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new

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

require 'rcov/rcovtask'
Rcov::RcovTask.new do |test|
test.libs << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
test.rcov_opts << '--exclude "gems/*"'
end

task :default => :test

require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "hitfox_coupon_api #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
0.0.2
88 changes: 88 additions & 0 deletions hitfox_coupon_api.gemspec
@@ -0,0 +1,88 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = "hitfox_coupon_api"
s.version = "0.0.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Gerrit Riessen"]
s.date = "2011-08-31"
s.description = "Simple JSON interface to the HitFox coupon API"
s.email = "gerrit.riessen@gmail.com"
s.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
]
s.files = [
".document",
".rvmrc",
"Gemfile",
"LICENSE.txt",
"README.rdoc",
"Rakefile",
"VERSION",
"hitfox_coupon_api.gemspec",
"lib/hitfox_coupon_api.rb",
"lib/hitfox_coupon_api/application.rb",
"lib/hitfox_coupon_api/configuration.rb",
"lib/hitfox_coupon_api/coupon.rb",
"test/.login.yml.sample",
"test/helper.rb",
"test/test_hitfox_coupon_api.rb",
"test_shell"
]
s.homepage = "https://github.com/gorenje/hitfox_coupon_api"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = "1.8.10"
s.summary = "Simple JSON interface to the HitFox coupon API"

if s.respond_to? :specification_version then
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
s.add_runtime_dependency(%q<json>, [">= 0"])
s.add_development_dependency(%q<rake>, ["= 0.8.7"])
s.add_development_dependency(%q<pry>, [">= 0"])
s.add_development_dependency(%q<pry-doc>, [">= 0"])
s.add_development_dependency(%q<gist>, [">= 0"])
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
s.add_development_dependency(%q<rcov>, [">= 0"])
s.add_development_dependency(%q<rr>, [">= 0"])
s.add_development_dependency(%q<cheat>, [">= 0"])
else
s.add_dependency(%q<rest-client>, [">= 0"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<rake>, ["= 0.8.7"])
s.add_dependency(%q<pry>, [">= 0"])
s.add_dependency(%q<pry-doc>, [">= 0"])
s.add_dependency(%q<gist>, [">= 0"])
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
s.add_dependency(%q<rcov>, [">= 0"])
s.add_dependency(%q<rr>, [">= 0"])
s.add_dependency(%q<cheat>, [">= 0"])
end
else
s.add_dependency(%q<rest-client>, [">= 0"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<rake>, ["= 0.8.7"])
s.add_dependency(%q<pry>, [">= 0"])
s.add_dependency(%q<pry-doc>, [">= 0"])
s.add_dependency(%q<gist>, [">= 0"])
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
s.add_dependency(%q<rcov>, [">= 0"])
s.add_dependency(%q<rr>, [">= 0"])
s.add_dependency(%q<cheat>, [">= 0"])
end
end

23 changes: 23 additions & 0 deletions lib/hitfox_coupon_api.rb
@@ -0,0 +1,23 @@
require 'rest-client'

require 'hitfox_coupon_api/configuration'
require 'hitfox_coupon_api/application'
require 'hitfox_coupon_api/coupon'

module HitfoxCouponApi
extend self

def configuration
@configuration ||= Configuration.new
end

def configure
config = configuration
block_given? ? yield(config) : config
config
end

def application(identifier)
Application.new(identifier)
end
end
13 changes: 13 additions & 0 deletions lib/hitfox_coupon_api/application.rb
@@ -0,0 +1,13 @@
module HitfoxCouponApi
class Application
attr_reader :identifier

def initialize(identifier)
@identifier = identifier
end

def coupon(code)
Coupon.new(self, code)
end
end
end
13 changes: 13 additions & 0 deletions lib/hitfox_coupon_api/configuration.rb
@@ -0,0 +1,13 @@
module HitfoxCouponApi
class Configuration
attr_accessor :api_endpoint, :api_token, :api_secret, :api_version

def initialize
@api_version = "1"
end

def generate_timestamp
Time.now.strftime("%s")
end
end
end

0 comments on commit 900d328

Please sign in to comment.