Browse files

Port HTTP client code over to JRuby, cleanup readme

  • Loading branch information...
1 parent d736df0 commit 620bb9b4bdc87a63c0cd0a047b88524e3a304a69 @kyledrake kyledrake committed Apr 2, 2011
View
3 Gemfile
@@ -10,6 +10,7 @@ gem 'xmpp4r-simple', '0.8.8'
gem 'symboltable', '1.0.0'
gem 'dm-mysql-adapter', '1.1.0'
gem 'rake'
+gem 'mizuno'
group :development do
gem 'shotgun', '0.9', :require => nil
@@ -20,4 +21,4 @@ group :test do
gem 'rack-test', '0.5.7', :require => 'rack/test'
gem 'contest', '0.1.2'
gem 'dm-sqlite-adapter', '1.1.0'
-end
+end
View
3 Gemfile.lock
@@ -43,6 +43,8 @@ GEM
json_pure (1.5.1)
linecache (0.43)
mime-types (1.16)
+ mizuno (0.4.0)
+ rack (>= 1.0.0)
rack (1.2.2)
rack-test (0.5.7)
rack (>= 1.0)
@@ -79,6 +81,7 @@ DEPENDENCIES
dm-timestamps (= 1.1.0)
jruby-openssl
json_pure (= 1.5.1)
+ mizuno
rack-test (= 0.5.7)
rake
rest-client (= 1.6.1)
View
33 README.markdown
@@ -8,28 +8,21 @@ Install
---
1) Clone the repository.
-2) Ensure Xcode is installed.
-3) Install bundler, the ruby package manager: sudo gem install bundler
-4) Install the packages by running this command: bundle install
-5) Start the server in reload mode with shotgun: bundle exec shotgun -P public
-6) Point your browser to http://localhost:9393
-
-For fast, non-development: bundle exec rackup -p 9393
+2) Ensure Xcode is installed on OSX, or the compiler environment for Linux
+3) Install RVM! http://rvm.beginrescueend.com/
+4) Set your environment to JRuby: rvm install jruby && rvm use jruby
+5) Install bundler: sudo gem install bundler
+6) Install the packages by running this command: bundle install
+7) Start the server in reload mode with shotgun: bundle exec shotgun -P public -p 4567 -OR- the faster non-reload version: bundle exec mizuno -p 4567 -E production
+8) Point your browser to http://localhost:4567
To run tests: bundle exec test/test.rb
config.yml example:
---
-development:
- database:
- adapter: mysql
- username: user
- password: pass
- database: pacmap
- host: localhost
- oauth_token: 1234blahblah
-test:
- database:
- adapter: sqlite
- database: test.sqlite3
- oauth_token: phonytokendontusearealone
+development:
+ database: "mysql://pacmap:pass@localhost/pacmap_dev"
+ oauth_token: 1jd3f3f2blahblah
+production:
+ database: "mysql://pacmap:pass@localhost/pacmap"
+ oauth_token: 23Ejdf32blahblah
View
7 environment.rb
@@ -9,15 +9,14 @@ class Sinatra::Base
set :root, File.expand_path(File.join(File.dirname(__FILE__)))
set :public, File.join(root, 'public')
Dir.glob(File.join(root, 'models', '**/*.rb')).each { |f| require f }
-
- config_hash = YAML.load_file File.join(root, 'config.yml')
+ config_hash = YAML.load_file(File.join(root, 'config.yml'))[environment.to_s]
Geoloqi::OAUTH_TOKEN = config_hash['oauth_token']
DataMapper.finalize
- DataMapper.setup :default, ENV['DATABASE_URL'] || config_hash[environment.to_s]['database']
+ DataMapper.setup :default, ENV['DATABASE_URL'] || config_hash['database']
# DataMapper.auto_upgrade!
DataMapper::Model.raise_on_save_failure = true
end
end
-require File.join(Sinatra::Base.root, 'pdx_pacman.rb')
+require File.join(Sinatra::Base.root, 'pdx_pacman.rb')
View
14 models/geoloqi.rb
@@ -2,14 +2,12 @@ module Geoloqi
API_URL = 'https://api.geoloqi.com/1/'
def self.headers(oauth_token); {'Authorization' => "OAuth #{oauth_token}", 'Content-Type' => 'application/json'} end
- def self.run(meth, oauth_token, url, body=nil)
- args = {:method => meth.to_sym, :url => API_URL+url, :headers => headers(oauth_token)}
- args.merge!(:body => body.to_json) if body
- JSON.response RestClient::Request.execute(args)
+ def self.run(meth, oauth_token, url, payload='')
+ JSON.parse RestClient::Request.execute(:method => meth.to_sym, :url => API_URL+url, :headers => headers(oauth_token), :payload => (payload == '' ? '' : payload.to_json))
end
- def self.post(oauth_token, url, body)
- response = run :post, oauth_token, url, body
+ def self.post(oauth_token, url, payload)
+ obj = run :post, oauth_token, url, payload
case obj
when Array
ret = []
@@ -23,7 +21,7 @@ def self.post(oauth_token, url, body)
end
def self.get(oauth_token, url)
- response = run :get, oauth_token, url
+ obj = run :get, oauth_token, url
case obj
when Array
ret = []
@@ -35,4 +33,4 @@ def self.get(oauth_token, url)
end
ret
end
-end
+end
View
BIN vendor/cache/mizuno-0.4.0.gem
Binary file not shown.
View
BIN vendor/cache/rake-0.8.7.gem
Binary file not shown.

0 comments on commit 620bb9b

Please sign in to comment.