Permalink
Browse files

adding common.rb for common config & variables

  • Loading branch information...
1 parent 2936450 commit a1a371fc6a653ff995dd2bb8e41bac115f08f983 @smudge committed Feb 1, 2013
Showing with 47 additions and 40 deletions.
  1. +1 −37 lib/kickstarter.rb
  2. +40 −0 lib/kickstarter/common.rb
  3. +6 −3 lib/kickstarter/project_card.rb
View
@@ -2,50 +2,14 @@
require "nokogiri"
require 'open-uri'
require 'date'
-require 'money'
+require_relative "kickstarter/common"
require_relative "kickstarter/version"
require_relative "kickstarter/backer"
require_relative "kickstarter/project"
require_relative "kickstarter/project_card"
require_relative "kickstarter/tier"
module Kickstarter
- BASE_URL = "http://www.kickstarter.com"
- Money.assume_from_symbol = true
-
- Categories = {
- :art => "art",
- :comics => "comics",
- :dance => "dance",
- :design => "design",
- :fashion => "fashion",
- :film_video => "film%20&%20video",
- :food => "food",
- :games => "games",
- :music => "music",
- :photography => "photography",
- :publishing => "publishing",
- :technology => "technology",
- :theater => "theater"
- }
-
- Types = {
- :popular => 'popular',
- :recommended => 'recommended',
- :successful => 'successful',
- :most_funded => 'most-funded'
- }
-
- Lists = {
- :recommended => "recommended",
- :popular => "popular",
- :recently_launched => "recently-launched",
- :ending_soon => "ending-soon",
- :small_projects => "small-projects",
- :most_funded => "most-funded",
- :curated => "curated-pages",
- }
-
# by category
# /discover/categories/:category/:subcategories
# :type # => [recommended, popular, successful]
View
@@ -0,0 +1,40 @@
+require 'money'
+
+module Kickstarter
+ BASE_URL = "http://www.kickstarter.com"
+ Money.assume_from_symbol = true
+
+ Categories = {
+ :art => "art",
+ :comics => "comics",
+ :dance => "dance",
+ :design => "design",
+ :fashion => "fashion",
+ :film_video => "film%20&%20video",
+ :food => "food",
+ :games => "games",
+ :music => "music",
+ :photography => "photography",
+ :publishing => "publishing",
+ :technology => "technology",
+ :theater => "theater"
+ }
+
+ Types = {
+ :popular => 'popular',
+ :recommended => 'recommended',
+ :successful => 'successful',
+ :most_funded => 'most-funded'
+ }
+
+ Lists = {
+ :recommended => "recommended",
+ :popular => "popular",
+ :recently_launched => "recently-launched",
+ :ending_soon => "ending-soon",
+ :small_projects => "small-projects",
+ :most_funded => "most-funded",
+ :curated => "curated-pages",
+ }
+
+end
@@ -1,3 +1,6 @@
+# encoding: utf-8
+require_relative 'common'
+
module Kickstarter
class ProjectCard
@@ -20,7 +23,7 @@ def description
end
def url
- @url ||= BASE_URL + node.css('h2 a').first.attribute('href').to_s.split('?').first
+ @url ||= node.css('h2 a').first.attribute('href').to_s.split('?').first
end
def handle
@@ -32,7 +35,7 @@ def owner
end
def image_url
- @image_url ||= thumbnail_url.gsub(/photo-little\.jpg/,'photo-full.jpg')
+ @image_url ||= thumbnail_url.gsub(/photo-little\.jpg/,'photo-full.jpg').split('?').first
end
def currency
@@ -42,7 +45,7 @@ def currency
def pledge_amount
@pledge_amount ||= begin
Money.assume_from_symbol = true
- Money.parse(node.css('.project-stats li')[1].css('strong').inner_html)
+ Money.parse(node.css('.project-stats li.pledged strong').inner_html.gsub('£','£').gsub('Â',''))
end
end

0 comments on commit a1a371f

Please sign in to comment.