Skip to content

Commit

Permalink
- unicode dependency
Browse files Browse the repository at this point in the history
Jruby doesn't like Ruby C extentions.
  • Loading branch information
Stanley committed Sep 15, 2011
1 parent f8f584c commit 8e37cb5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ group :app do
gem 'sinatra'
gem 'neo4j', :path => "/github/neo4j"
gem 'unicode'
gem 'chronik', :path=>'/code/chronik'
gem 'jruby-openssl'
gem 'chronik', :path => "/code/chronik"
gem 'msgpack-jruby'
Expand Down
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ GEM
term-ansicolor (1.0.6)
thor (0.14.6)
tilt (1.3.3)
unicode (0.4.0)
will_paginate (3.0.pre4)

PLATFORMS
Expand Down
7 changes: 7 additions & 0 deletions lib/bagatela.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
require './lib/bagatela/graph/search/fast'
require './lib/bagatela/graph/search/astar'

# Monkey patch
class String
def upcase
to_java_string.to_upper_case
end
end

module Bagatela
module Resources
# Load configuration from YAML file.
Expand Down
7 changes: 3 additions & 4 deletions lib/bagatela/graph/import.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'msgpack'
require 'unicode'
require 'jruby/profiler'

module Bagatela
Expand Down Expand Up @@ -102,7 +101,7 @@ def self.nodes(db, group)

def self.stops(db)
Resources::Stop.view(db, :by_name, :reduce=>false).map do |doc|
id = doc['finish'] ? Unicode.upcase(doc['name']) : doc['_id']
id = doc['finish'] ? doc['name'].upcase : doc['_id']
stop = doc['location'] || {}
stop['name'] = doc['name']
[id, stop]
Expand All @@ -111,11 +110,11 @@ def self.stops(db)

def self.hubs(db)
Resources::Stop.view(db, :by_name, :group_level=>1).map do |doc|
id = Unicode.upcase(doc['_key'][0]).force_encoding("UTF-8")
id = doc['_key'][0].upcase
#hub = Hub.new(doc['location'])
#hub[:name] = doc['_key'][0].force_encoding("UTF-8")
#hub[:source] = doc['docs'].map{|id| "#{db}-#{id}"} if doc['docs']
[id, {'name' => doc['_key'][0].force_encoding("UTF-8")}.merge(doc['location'] || {})]
[id, {'name' => doc['_key'][0]}.merge(doc['location'] || {})]
end
end

Expand Down
8 changes: 3 additions & 5 deletions lib/bagatela/resources/timetable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'unicode'

module Bagatela
module Resources
class Timetable < Resource
Expand All @@ -12,8 +10,8 @@ def self.to_s
#
# Returns String; timetable's line destination.
def destination
self['destination'] ? Unicode.upcase(self['destination']).force_encoding("UTF-8") :
self['route'].split('-').last.strip.split.map{|word| Unicode.upcase(word)}.join(' ').force_encoding("UTF-8")
return self['destination'].upcase if self['destination']
self['route'] ? self['route'].split('-').last.strip.upcase : ''
end

# Based on two timetables, where one follows another, we can guess (with
Expand Down Expand Up @@ -43,7 +41,7 @@ def rides(date, next_timetable=nil)
#
# Returns String.
def stop_id
self['stop_id'] || Unicode.upcase(self['stop']).force_encoding("UTF-8")
self['stop_id'] || self['stop'].upcase
end

# Find one of many tables.
Expand Down

0 comments on commit 8e37cb5

Please sign in to comment.