Permalink
Browse files

- book model from example

  • Loading branch information...
1 parent 6eb7ddc commit 70db1e798c88d5a71e36a263e02d5429758ac280 @floere committed Sep 10, 2012
@@ -0,0 +1,45 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activesupport (3.2.8)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ backports (2.6.4)
+ eventmachine (0.12.10)
+ haml (3.1.7)
+ i18n (0.6.0)
+ multi_json (1.3.6)
+ picky-client (4.6.4)
+ activesupport (>= 3.0)
+ yajl-ruby
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ sinatra (1.3.3)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ sinatra-contrib (1.3.1)
+ backports (>= 2.0)
+ eventmachine
+ rack-protection
+ rack-test
+ sinatra (~> 1.3.0)
+ tilt (~> 1.3)
+ sinatra-reloader (1.0)
+ sinatra-contrib
+ tilt (1.3.3)
+ yajl-ruby (1.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ activesupport
+ haml
+ i18n
+ picky-client
+ sinatra
+ sinatra-reloader
@@ -2,14 +2,14 @@
require 'bundler'
Bundler.require
-require File.expand_path 'book', File.dirname(__FILE__)
+require File.expand_path '../../../../generators/prototypes/shared/both/book', __FILE__
set :haml, { :format => :html5 } # default Haml format is :xhtml
# What you would do in an app.
#
-FullBooks = Picky::Client::Full.new :host => 'picky-simple-example-backend.heroku.com', :port => 80, :path => '/books/full'
-LiveBooks = Picky::Client::Live.new :host => 'picky-simple-example-backend.heroku.com', :port => 80, :path => '/books/live'
+FullBooks = Picky::Client.new :host => 'picky-simple-example-backend.heroku.com', :port => 80, :path => '/books/full'
+LiveBooks = Picky::Client.new :host => 'picky-simple-example-backend.heroku.com', :port => 80, :path => '/books/live'
set :static, true
set :public, File.dirname(__FILE__)
@@ -1,30 +0,0 @@
-require 'csv'
-
-class Book
-
- @@books_mapping = {}
-
- # Load the books on startup.
- #
- file_name = File.expand_path 'books.csv', File.dirname(__FILE__)
- CSV.open(file_name, 'r').each do |row|
- @@books_mapping[row.shift.to_i] = row
- end
-
- def self.find ids, _ = {}
- ids.map { |id| new(id, *@@books_mapping[id]) }
- end
-
- attr_reader :id
-
- def initialize id, title, author, isbn, year, publisher, subjects
- @id, @title, @author, @isbn, @year, @publisher, @subjects = id, title, author, isbn, year, publisher, subjects
- end
-
- # "Rendering" ;)
- #
- def to_s
- "<div class='book'><p>\"#{@title}\", by #{@author}</p><p>#{@year}, #{@publisher}, #{@isbn}</p><p>#{@subjects}</p></div>"
- end
-
-end

0 comments on commit 70db1e7

Please sign in to comment.