Permalink
Browse files

full 02 coverage

  • Loading branch information...
1 parent c840f34 commit 5b36049ecf9392cee85477ea5ad9097a99f1a381 @pengwynn committed May 23, 2010
View
12 Gemfile
@@ -0,0 +1,12 @@
+# Generated from /Users/wynn/Projects/plancast/plancast.gemspec
+source :gemcutter
+gem "hashie", ">= 0.1.3"
+gem "monster_mash", ">= 0.1.0"
+gem "yajl", "~> 0.7.6"
+
+group :development do
+ gem "shoulda", ">= 2.10.1"
+ gem "matchy", "= 0.4.0"
+ gem "fakeweb", ">= 1.2.5"
+ gem "yard", ">= 0"
+end
View
@@ -1,58 +1,20 @@
-require 'rubygems'
-require 'rake'
+$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
+require "bundler/version"
+require "shoulda/tasks"
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "plancast"
- gem.summary = %Q{Wrapper for the unpublished Plancast API}
- gem.description = %Q{Wrapper for the unpublished Plancast API}
- gem.email = "wynn.netherland@gmail.com"
- gem.homepage = "http://github.com/pengwynn/plancast"
- gem.authors = ["Wynn Netherland"]
-
- gem.add_dependency('hashie', '>= 0.1.3')
- gem.add_dependency('httparty', '>= 0.5.0')
-
- gem.add_development_dependency('shoulda', '>= 2.10.1')
- gem.add_development_dependency('matchy', '0.4.0')
- gem.add_development_dependency('fakeweb', '>= 1.2.5')
- gem.add_development_dependency "yard", ">= 0"
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
-end
-
-require 'rake/testtask'
+require "rake/testtask"
Rake::TestTask.new(:test) do |test|
- test.libs << 'lib' << 'test'
- test.pattern = 'test/**/test_*.rb'
- test.verbose = true
+ test.ruby_opts = ["-rubygems"] if defined? Gem
+ test.libs << "lib" << "test"
+ test.pattern = "test/**/*_test.rb"
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
+
+task :build do
+ system "gem build plancast.gemspec"
end
-
-task :test => :check_dependencies
-
-task :default => :test
-
-begin
- require 'yard'
- YARD::Rake::YardocTask.new
-rescue LoadError
- task :yardoc do
- abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
- end
+
+task :release => :build do
+ system "gem push bundler-#{Plancast::VERSION}"
end
+
+task :default => :test
View
@@ -1 +1 @@
-0.0.2
+0.1.0
View
@@ -7,6 +7,30 @@
module Plancast
+ VERSION = "0.1.0".freeze
+
+ def self.configure
+ yield self
+ true
+ end
+
+ def self.api_url(endpoint, version = self.api_version)
+ "http://api.plancast.com/#{version}#{endpoint}.json"
+ end
+
+ # class << self
+ # attr_accessor :api_key
+ # attr_accessor :api_version
+ # end
+
+ def self.api_version
+ @api_version || "02"
+ end
+
+ def self.api_version=(value)
+ @api_version = value
+ end
+
class PlancastError < StandardError
attr_reader :data
View
@@ -1,7 +1,7 @@
module Plancast
class Client
include HTTParty
- base_uri 'api.plancast.com/01'
+ base_uri "api.plancast.com/#{Plancast.api_version}"
format :json
attr_reader :username
@@ -12,62 +12,91 @@ def initialize(username, password)
end
def verify_credentials
- Hashie::Mash.new(self.class.get("/account/verify_credentials.json"))
+ self.class.get("/account/verify_credentials.json")
end
- def home_timeline
- Hashie::Mash.new(self.class.get("/plans/home_timeline.json"))
+ def user(query={})
+ self.class.get("/users/show.json", :query => query)
end
- def user_timeline(username=self.username)
- timeline = Hashie::Mash.new(self.class.get("/plans/user_timeline.json"))
+ def subscriptions(query={})
+ self.class.get("/users/subscriptions.json", :query => query)
end
- def update(details={})
- plan = Hashie::Mash.new(self.class.post("/plans/update.json", :body => details))
+ def update_subscription(options={})
+ self.class.post("/subscriptions/update.json", :body => options)
end
- def attend(plan_id)
- plan = Hashie::Mash.new(self.class.post("/plans/attend.json", :query => {:plan_id => plan_id}))
+ def destroy_subscription(options={})
+ self.class.post("/subscriptions/destroy.json", :body => options)
end
- def unattend(attendance_id)
- plan = Hashie::Mash.new(self.class.post("/plans/destroy.json", :query => {:attendance_id => attendance_id}))
+ def subscribers(query={})
+ self.class.get("/users/subscribers.json", :query => query)
end
- def plan(attendance_id)
- plan = Hashie::Mash.new(self.class.get("/plans/show.json", :query => {:attendance_id => attendance_id}))
+ def discover_friends(query={})
+ self.class.get("/users/discover_friends.json", :query => query)
end
- def search_plans(q, options={})
- results = Hashie::Mash.new(self.class.get("/plans/search.json", :query => options.merge({:q => q})))
+ def search_users(q, options={})
+ self.class.get("/users/search.json", :query => options.merge({:q => q}))
end
- def user(screen_name=nil)
- user = Hashie::Mash.new(self.class.get("/users/show.json", :query => {:screen_name => screen_name}))
+ def plans(query = {})
+ self.class.get("/plans/user.json", :query => query)
end
- def search_users(q, options={})
- results = Hashie::Mash.new(self.class.get("/users/search.json", :query => options.merge({:q => q})))
+ def home
+ self.class.get("/plans/home.json")
+ end
+
+ def plan(query = {})
+ self.class.get("/plans/show.json", :query => query)
end
- def subscriptions(user_id)
- results = self.class.get("/users/subscriptions.json", :query => {:user_id => user_id}).map{|s| Hashie::Mash.new(s)}
+ def search_plans(query)
+ self.class.get("/plans/search.json", :query => query)
end
- def subscribers(user_id)
- results = self.class.get("/users/subscribers.json", :query => {:user_id => user_id}).map{|s| Hashie::Mash.new(s)}
+ def parse_when(q)
+ date = self.class.get("/plans/parse_when.json", :query => {:when => q})
+ date.start = Time.at(date.start)
+ date.stop = Time.at(date.stop)
+ date
end
- def create_comment(details={})
- comment = Hashie::Mash.new(self.class.post("/comments/update.json", :body => details))
+ def parse_where(where)
+ locations = self.class.get("/plans/parse_where.json", :query => {:where => where})
+ locations.each{|l| l.latitude = l.latitude.to_f; l.longitude = l.longitude.to_f}
+ locations
end
- def create_friendship(user_id)
- user = Hashie::Mash.new(self.class.post("/friendships/create.json", :body => {:user_id => user_id}))
+ def update(details={})
+ self.class.post("/plans/update.json", :body => details)
+ end
+
+ def attend(details={})
+ self.class.post("/plans/attend.json", :body => details)
end
+ def user_timeline(username=self.username)
+ self.class.get("/plans/user_timeline.json")
+ end
+
+ def unattend(options)
+ self.class.post("/plans/destroy.json", :body => options)
+ end
+
+ def update_comment(details={})
+ self.class.post("/comments/update.json", :body => details)
+ end
+ def destroy_comment(comment_id)
+ self.class.post("/comments/destroy.json", :body => {:comment_id => comment_id})
+ end
+
+
def self.get(*args); handle_response super end
def self.post(*args); handle_response super end
@@ -80,7 +109,11 @@ def self.handle_response(response)
when 500...600; raise ServerError.new(response.code)
else; response
end
- response
+ if response.is_a?(Array)
+ response.map{|item| Hashie::Mash.new(item)}
+ else
+ Hashie::Mash.new(response)
+ end
end
end
View
@@ -1,86 +1,25 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
-# -*- encoding: utf-8 -*-
+require 'bundler'
+require 'bundler/version'
Gem::Specification.new do |s|
s.name = %q{plancast}
- s.version = "0.0.2"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.version = Bundler::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.required_rubygems_version = ">= 1.3.6"
s.authors = ["Wynn Netherland"]
- s.date = %q{2010-03-21}
+ s.date = %q{2010-05-21}
s.description = %q{Wrapper for the unpublished Plancast API}
s.email = %q{wynn.netherland@gmail.com}
- s.extra_rdoc_files = [
- "LICENSE",
- "README.rdoc"
- ]
- s.files = [
- ".document",
- ".gitignore",
- "LICENSE",
- "README.rdoc",
- "Rakefile",
- "VERSION",
- "lib/plancast.rb",
- "lib/plancast/client.rb",
- "plancast.gemspec",
- "test/fixtures/attend.json",
- "test/fixtures/comment.json",
- "test/fixtures/create_friendship.json",
- "test/fixtures/featured.json",
- "test/fixtures/home_timeline.json",
- "test/fixtures/parse_when.json",
- "test/fixtures/plan.json",
- "test/fixtures/search.json",
- "test/fixtures/subscribers.json",
- "test/fixtures/subscriptions.json",
- "test/fixtures/unattend.json",
- "test/fixtures/update.json",
- "test/fixtures/user.json",
- "test/fixtures/user_search.json",
- "test/fixtures/user_timeline.json",
- "test/fixtures/verify_credentials.json",
- "test/helper.rb",
- "test/test_plancast.rb"
- ]
+ s.files = Dir.glob("{lib}/**/*")
s.homepage = %q{http://github.com/pengwynn/plancast}
- s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.5}
+ s.rubygems_version = %q{1.3.6}
s.summary = %q{Wrapper for the unpublished Plancast API}
s.test_files = [
"test/helper.rb",
- "test/test_plancast.rb"
+ "test/plancast_test.rb"
]
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<hashie>, [">= 0.1.3"])
- s.add_runtime_dependency(%q<httparty>, [">= 0.5.0"])
- s.add_development_dependency(%q<shoulda>, [">= 2.10.1"])
- s.add_development_dependency(%q<matchy>, ["= 0.4.0"])
- s.add_development_dependency(%q<fakeweb>, [">= 1.2.5"])
- s.add_development_dependency(%q<yard>, [">= 0"])
- else
- s.add_dependency(%q<hashie>, [">= 0.1.3"])
- s.add_dependency(%q<httparty>, [">= 0.5.0"])
- s.add_dependency(%q<shoulda>, [">= 2.10.1"])
- s.add_dependency(%q<matchy>, ["= 0.4.0"])
- s.add_dependency(%q<fakeweb>, [">= 1.2.5"])
- s.add_dependency(%q<yard>, [">= 0"])
- end
- else
- s.add_dependency(%q<hashie>, [">= 0.1.3"])
- s.add_dependency(%q<httparty>, [">= 0.5.0"])
- s.add_dependency(%q<shoulda>, [">= 2.10.1"])
- s.add_dependency(%q<matchy>, ["= 0.4.0"])
- s.add_dependency(%q<fakeweb>, [">= 1.2.5"])
- s.add_dependency(%q<yard>, [">= 0"])
- end
+ s.add_bundler_dependencies
end
Oops, something went wrong.

0 comments on commit 5b36049

Please sign in to comment.