Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial Commit

  • Loading branch information...
commit 81ac52632e7fc7f4ac57dda1f8495ccae53502ee 0 parents
@jdpace jdpace authored
2  .gitignore
@@ -0,0 +1,2 @@
+pkg
+relevant*.gem
1  README.md
@@ -0,0 +1 @@
+Datetime widget for Relevant
30 Rakefile
@@ -0,0 +1,30 @@
+require 'rake'
+require File.dirname(__FILE__) + "/lib/relevant/eventbrite_signups.rb"
+
+require 'rspec/core/rake_task'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.version = Relevant::EventbriteSignups::Version
+ gemspec.name = "relevant-eventbrite-signups"
+ gemspec.summary = "Eventbrite Signup counter for Relevant"
+ gemspec.description = "Show how many signups your event has"
+ gemspec.email = "opensource@thinkrelevance.com"
+ gemspec.homepage = "http://github.com/relevance/relevant-eventbrite-signups"
+ gemspec.authors = ["Alan Dipert"]
+ gemspec.add_dependency "relevant-widget", "~> 0.0.6"
+ gemspec.add_dependency "eventbright", "~> 0.2.3"
+ gemspec.add_development_dependency "rspec", "~> 2.0.0.beta.22"
+ end
+ Jeweler::GemcutterTasks.new
+
+rescue LoadError
+ puts "Jeweler not available. Install it with: gem install jeweler"
+end
+
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec)
+task :default => :spec
+
+task :full_release => [:check_dependencies, :spec, :release]
35 lib/relevant/eventbrite_signups.rb
@@ -0,0 +1,35 @@
+require "relevant/widget"
+require 'eventbright'
+
+module Relevant
+ class EventbriteSignups
+ Version = '0.0.1'
+
+ include Relevant::Widget
+
+ refresh_every 10.minutes
+
+ available_options :user_key => :string, :event_id => :string
+
+ template_format :haml
+ template %q[
+%h2 Conj Signups
+%h3
+ = signup_count
+:css
+ h3 { margin-top: 5px; font-size: 72pt; text-align: center; }]
+
+ def signup_count
+ return '?' unless event
+
+ event.tickets.map(&:quantity_sold).reduce(:+)
+ end
+
+ def event
+ EventBright::User.new(options[:user_key]).events.detect{|e| e.id == options[:event_id].to_i}
+ end
+
+ end
+end
+
+Relevant.register Relevant::EventbriteSignups
10 lib/relevant/eventbrite_signups_spec.rb
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe Relevant::Datetime do
+
+ it 'displays the time given a strftime format' do
+ widget = Relevant::Datetime.setup :format => '%m/%d/%Y'
+ widget.to_html.should include(Time.zone.now.strftime('%m/%d/%Y'))
+ end
+
+end
52 relevant-datetime.gemspec
@@ -0,0 +1,52 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{relevant-datetime}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Jared Pace", "Rob Sanheim"]
+ s.date = %q{2010-09-24}
+ s.description = %q{Check the time}
+ s.email = %q{opensource@thinkrelevance.com}
+ s.extra_rdoc_files = [
+ "README.md"
+ ]
+ s.files = [
+ ".gitignore",
+ "README.md",
+ "Rakefile",
+ "lib/relevant/datetime.rb",
+ "spec/relevant/datetime_spec.rb",
+ "spec/spec_helper.rb"
+ ]
+ s.homepage = %q{http://github.com/relevance/relevant-datetime}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{Datetime widget for Relevant}
+ s.test_files = [
+ "spec/relevant/datetime_spec.rb",
+ "spec/spec_helper.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<relevant-widget>, ["~> 0.0.6"])
+ s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
+ else
+ s.add_dependency(%q<relevant-widget>, ["~> 0.0.6"])
+ s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
+ end
+ else
+ s.add_dependency(%q<relevant-widget>, ["~> 0.0.6"])
+ s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
+ end
+end
+
13 spec/relevant/eventbrite_signups_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe Relevant::EventbriteSignups do
+ it "gets the right event" do
+ widget = Relevant::EventbriteSignups.setup :user_key => 'ABC', :event_id => '12345'
+
+ event1 = stub('event1', :id => 55555)
+ event2 = stub('event2', :id => 12345)
+ fake_user = stub('user', :events => [event1, event2])
+ EventBright::User.stubs(:new).with('ABC').returns(fake_user)
+ widget.event.should == event2
+ end
+end
15 spec/spec_helper.rb
@@ -0,0 +1,15 @@
+require 'rspec'
+
+$LOAD_PATH.unshift "../lib"
+require "relevant/eventbrite_signups"
+
+RSpec.configure do |config|
+ config.color_enabled = true
+ config.mock_with :mocha
+
+ config.formatter = :progress
+ config.color_enabled = true
+ config.filter_run :focused => true
+ config.run_all_when_everything_filtered = true
+ config.alias_example_to :fit, :focused => true
+end
Please sign in to comment.
Something went wrong with that request. Please try again.