Doing a resync from mainline 8633:10895. There was one simple to resolve conflict on app/models/node.rb. Also moving the migrations for API0.6 to new sequence numbers since there was some new migrations added to mainline, where the migration numbers would conflict if not moved.
This commit is contained in:
commit
d9e070e069
395 changed files with 2348 additions and 25020 deletions
File diff suppressed because it is too large
Load diff
|
@ -126,6 +126,14 @@ class ApiController < ApplicationController
|
|||
|
||||
doc = OSM::API.new.get_xml_doc
|
||||
|
||||
# add bounds
|
||||
bounds = XML::Node.new 'bounds'
|
||||
bounds['minlat'] = min_lat.to_s
|
||||
bounds['minlon'] = min_lon.to_s
|
||||
bounds['maxlat'] = max_lat.to_s
|
||||
bounds['maxlon'] = max_lon.to_s
|
||||
doc.root << bounds
|
||||
|
||||
# get ways
|
||||
# find which ways are needed
|
||||
ways = Array.new
|
||||
|
@ -168,15 +176,15 @@ class ApiController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
relations = visible_nodes.values.collect { |node| node.containing_relations.visible }.flatten +
|
||||
way_ids.collect { |id| Way.find(id).containing_relations.visible }.flatten
|
||||
relations = Relation.find_for_nodes(visible_nodes.keys, :conditions => "visible = 1") +
|
||||
Relation.find_for_ways(way_ids, :conditions => "visible = 1")
|
||||
|
||||
# we do not normally return the "other" partners referenced by an relation,
|
||||
# e.g. if we return a way A that is referenced by relation X, and there's
|
||||
# another way B also referenced, that is not returned. But we do make
|
||||
# an exception for cases where an relation references another *relation*;
|
||||
# in that case we return that as well (but we don't go recursive here)
|
||||
relations += relations.collect { |relation| relation.containing_relations.visible }.flatten
|
||||
relations += Relation.find_for_relations(relations.collect { |r| r.id }, :conditions => "visible = 1")
|
||||
|
||||
# this "uniq" may be slightly inefficient; it may be better to first collect and output
|
||||
# all node-related relations, then find the *not yet covered* way-related ones etc.
|
||||
|
|
|
@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def authorize_web
|
||||
if session[:user]
|
||||
@user = User.find(session[:user])
|
||||
@user = User.find(session[:user], :conditions => "visible = 1")
|
||||
elsif session[:token]
|
||||
@user = User.authenticate(:token => session[:token])
|
||||
session[:user] = @user.id
|
||||
|
|
|
@ -2,16 +2,40 @@ class DiaryEntryController < ApplicationController
|
|||
layout 'site', :except => :rss
|
||||
|
||||
before_filter :authorize_web
|
||||
before_filter :require_user, :only => [:new]
|
||||
before_filter :require_user, :only => [:new, :edit]
|
||||
before_filter :check_database_availability
|
||||
|
||||
def new
|
||||
@title = 'new diary entry'
|
||||
@title = 'New diary entry'
|
||||
|
||||
if params[:diary_entry]
|
||||
@diary_entry = DiaryEntry.new(params[:diary_entry])
|
||||
@diary_entry.user = @user
|
||||
|
||||
if @diary_entry.save
|
||||
redirect_to :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@title= 'Edit diary entry'
|
||||
@diary_entry = DiaryEntry.find(params[:id])
|
||||
|
||||
if @user != @diary_entry.user
|
||||
redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
|
||||
elsif params[:diary_entry]
|
||||
@diary_entry.title = params[:diary_entry][:title]
|
||||
@diary_entry.body = params[:diary_entry][:body]
|
||||
@diary_entry.latitude = params[:diary_entry][:latitude]
|
||||
@diary_entry.longitude = params[:diary_entry][:longitude]
|
||||
|
||||
if @diary_entry.save
|
||||
redirect_to :controller => 'diary_entry', :action => 'view', :id => params[:id]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -27,10 +51,11 @@ class DiaryEntryController < ApplicationController
|
|||
render :action => 'view'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def list
|
||||
if params[:display_name]
|
||||
@this_user = User.find_by_display_name(params[:display_name])
|
||||
@this_user = User.find_by_display_name(params[:display_name], :conditions => "visible = 1")
|
||||
|
||||
if @this_user
|
||||
@title = @this_user.display_name + "'s diary"
|
||||
@entry_pages, @entries = paginate(:diary_entries,
|
||||
|
@ -39,6 +64,7 @@ class DiaryEntryController < ApplicationController
|
|||
:per_page => 20)
|
||||
else
|
||||
@not_found_user = params[:display_name]
|
||||
|
||||
render :action => 'no_such_user', :status => :not_found
|
||||
end
|
||||
else
|
||||
|
@ -51,23 +77,37 @@ class DiaryEntryController < ApplicationController
|
|||
|
||||
def rss
|
||||
if params[:display_name]
|
||||
user = User.find_by_display_name(params[:display_name])
|
||||
@entries = DiaryEntry.find(:all, :conditions => ['user_id = ?', user.id], :order => 'created_at DESC', :limit => 20)
|
||||
@title = "OpenStreetMap diary entries for #{user.display_name}"
|
||||
@description = "Recent OpenStreetmap diary entries from #{user.display_name}"
|
||||
@link = "http://www.openstreetmap.org/user/#{user.display_name}/diary"
|
||||
user = User.find_by_display_name(params[:display_name], :conditions => "visible = 1")
|
||||
|
||||
if user
|
||||
@entries = DiaryEntry.find(:all, :conditions => ['user_id = ?', user.id], :order => 'created_at DESC', :limit => 20)
|
||||
@title = "OpenStreetMap diary entries for #{user.display_name}"
|
||||
@description = "Recent OpenStreetmap diary entries from #{user.display_name}"
|
||||
@link = "http://www.openstreetmap.org/user/#{user.display_name}/diary"
|
||||
|
||||
render :content_type => Mime::RSS
|
||||
else
|
||||
render :nothing => true, :status => :not_found
|
||||
end
|
||||
else
|
||||
@entries = DiaryEntry.find(:all, :order => 'created_at DESC', :limit => 20)
|
||||
@title = "OpenStreetMap diary entries"
|
||||
@description = "Recent diary entries from users of OpenStreetMap"
|
||||
@link = "http://www.openstreetmap.org/diary"
|
||||
end
|
||||
|
||||
render :content_type => Mime::RSS
|
||||
render :content_type => Mime::RSS
|
||||
end
|
||||
end
|
||||
|
||||
def view
|
||||
user = User.find_by_display_name(params[:display_name])
|
||||
@entry = DiaryEntry.find(:first, :conditions => ['user_id = ? AND id = ?', user.id, params[:id]])
|
||||
user = User.find_by_display_name(params[:display_name], :conditions => "visible = 1")
|
||||
|
||||
if user
|
||||
@entry = DiaryEntry.find(:first, :conditions => ['user_id = ? AND id = ?', user.id, params[:id]])
|
||||
else
|
||||
@not_found_user = params[:display_name]
|
||||
|
||||
render :action => 'no_such_user', :status => :not_found
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -117,8 +117,8 @@ class SwfController < ApplicationController
|
|||
def startShape
|
||||
s =0.chr # No fill styles
|
||||
s+=2.chr # Two line styles
|
||||
s+=packUI16(5) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
|
||||
s+=packUI16(5) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
|
||||
s+=packUI16(0) + 0.chr + 255.chr + 255.chr # Width 5, RGB #00FFFF
|
||||
s+=packUI16(0) + 255.chr + 0.chr + 255.chr # Width 5, RGB #FF00FF
|
||||
s+=34.chr # 2 fill, 2 line index bits
|
||||
s
|
||||
end
|
||||
|
|
|
@ -12,13 +12,13 @@ class TraceController < ApplicationController
|
|||
# from display name, pick up user id if one user's traces only
|
||||
display_name = params[:display_name]
|
||||
if target_user.nil? and !display_name.blank?
|
||||
target_user = User.find(:first, :conditions => [ "display_name = ?", display_name])
|
||||
target_user = User.find(:first, :conditions => [ "visible = 1 and display_name = ?", display_name])
|
||||
end
|
||||
|
||||
# set title
|
||||
if target_user.nil?
|
||||
@title = "Public GPS traces"
|
||||
elsif @user and @user.id == target_user.id
|
||||
elsif @user and @user == target_user
|
||||
@title = "Your GPS traces"
|
||||
else
|
||||
@title = "Public GPS traces from #{target_user.display_name}"
|
||||
|
@ -38,7 +38,7 @@ class TraceController < ApplicationController
|
|||
conditions = ["gpx_files.public = 1"] #2
|
||||
end
|
||||
else
|
||||
if @user and @user.id == target_user.id
|
||||
if @user and @user == target_user
|
||||
conditions = ["gpx_files.user_id = ?", @user.id] #3 (check vs user id, so no join + can't pick up non-public traces by changing name)
|
||||
else
|
||||
conditions = ["gpx_files.public = 1 AND gpx_files.user_id = ?", target_user.id] #4
|
||||
|
@ -88,7 +88,7 @@ class TraceController < ApplicationController
|
|||
@trace = Trace.find(params[:id])
|
||||
|
||||
if @trace and @trace.visible? and
|
||||
(@trace.public? or @trace.user.id == @user.id)
|
||||
(@trace.public? or @trace.user == @user)
|
||||
@title = "Viewing trace #{@trace.name}"
|
||||
else
|
||||
flash[:notice] = "Trace not found!"
|
||||
|
|
|
@ -2,8 +2,8 @@ class UserController < ApplicationController
|
|||
layout 'site'
|
||||
|
||||
before_filter :authorize, :only => [:api_details, :api_gpx_files]
|
||||
before_filter :authorize_web, :only => [:account, :go_public, :view, :diary, :make_friend, :remove_friend, :upload_image]
|
||||
before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image]
|
||||
before_filter :authorize_web, :except => [:api_details, :api_gpx_files]
|
||||
before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image]
|
||||
before_filter :check_database_availability, :except => [:api_details, :api_gpx_files]
|
||||
before_filter :check_read_availability, :only => [:api_details, :api_gpx_files]
|
||||
|
||||
|
@ -13,12 +13,13 @@ class UserController < ApplicationController
|
|||
@title = 'create account'
|
||||
@user = User.new(params[:user])
|
||||
|
||||
@user.visible = true
|
||||
@user.data_public = true
|
||||
|
||||
@user.description = "" if @user.description.nil?
|
||||
|
||||
if @user.save
|
||||
token = @user.tokens.create
|
||||
flash[:notice] = "User was successfully created. Check your email for a confirmation note, and you\'ll be mapping in no time :-)<br>Please note that you won't be able to login until you've received and confirmed your email address."
|
||||
Notifier::deliver_signup_confirm(@user, token)
|
||||
Notifier.deliver_signup_confirm(@user, @user.tokens.create)
|
||||
redirect_to :action => 'login'
|
||||
else
|
||||
render :action => 'new'
|
||||
|
@ -28,21 +29,28 @@ class UserController < ApplicationController
|
|||
def account
|
||||
@title = 'edit account'
|
||||
if params[:user] and params[:user][:display_name] and params[:user][:description]
|
||||
home_lat = params[:user][:home_lat]
|
||||
home_lon = params[:user][:home_lon]
|
||||
if params[:user][:email] != @user.email
|
||||
@user.new_email = params[:user][:email]
|
||||
end
|
||||
|
||||
@user.display_name = params[:user][:display_name]
|
||||
|
||||
if params[:user][:pass_crypt].length > 0 or params[:user][:pass_crypt_confirmation].length > 0
|
||||
@user.pass_crypt = params[:user][:pass_crypt]
|
||||
@user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
|
||||
end
|
||||
|
||||
@user.description = params[:user][:description]
|
||||
@user.home_lat = home_lat
|
||||
@user.home_lon = home_lon
|
||||
@user.home_lat = params[:user][:home_lat]
|
||||
@user.home_lon = params[:user][:home_lon]
|
||||
|
||||
if @user.save
|
||||
flash[:notice] = "User information updated successfully."
|
||||
else
|
||||
flash.delete(:notice)
|
||||
if params[:user][:email] == @user.new_email
|
||||
@notice = "User information updated successfully. Check your email for a note to confirm your new email address."
|
||||
Notifier.deliver_email_confirm(@user, @user.tokens.create)
|
||||
else
|
||||
@notice = "User information updated successfully."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -68,16 +76,15 @@ class UserController < ApplicationController
|
|||
def lost_password
|
||||
@title = 'lost password'
|
||||
if params[:user] and params[:user][:email]
|
||||
user = User.find_by_email(params[:user][:email])
|
||||
user = User.find_by_email(params[:user][:email], :conditions => "visible = 1")
|
||||
|
||||
if user
|
||||
token = user.tokens.create
|
||||
Notifier::deliver_lost_password(user, token)
|
||||
flash[:notice] = "Sorry you lost it :-( but an email is on its way so you can reset it soon."
|
||||
Notifier.deliver_lost_password(user, token)
|
||||
@notice = "Sorry you lost it :-( but an email is on its way so you can reset it soon."
|
||||
else
|
||||
flash[:notice] = "Couldn't find that email address, sorry."
|
||||
@notice = "Couldn't find that email address, sorry."
|
||||
end
|
||||
else
|
||||
render :action => 'lost_password'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -91,14 +98,16 @@ class UserController < ApplicationController
|
|||
user.pass_crypt = pass
|
||||
user.pass_crypt_confirmation = pass
|
||||
user.active = true
|
||||
user.email_valid = true
|
||||
user.save!
|
||||
token.destroy
|
||||
Notifier::deliver_reset_password(user, pass)
|
||||
Notifier.deliver_reset_password(user, pass)
|
||||
flash[:notice] = "Your password has been changed and is on its way to your mailbox :-)"
|
||||
else
|
||||
flash[:notice] = "Didn't find that token, check the URL maybe?"
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
|
||||
|
@ -121,9 +130,9 @@ class UserController < ApplicationController
|
|||
end
|
||||
return
|
||||
elsif User.authenticate(:username => email_or_display_name, :password => pass, :inactive => true)
|
||||
flash[:notice] = "Sorry, your account is not active yet.<br>Please click on the link in the account confirmation email to activate your account."
|
||||
@notice = "Sorry, your account is not active yet.<br>Please click on the link in the account confirmation email to activate your account."
|
||||
else
|
||||
flash[:notice] = "Sorry, couldn't log in with those details."
|
||||
@notice = "Sorry, couldn't log in with those details."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -150,13 +159,34 @@ class UserController < ApplicationController
|
|||
if token and !token.user.active?
|
||||
@user = token.user
|
||||
@user.active = true
|
||||
@user.email_valid = true
|
||||
@user.save!
|
||||
token.destroy
|
||||
flash[:notice] = 'Confirmed your account, thanks for signing up!'
|
||||
session[:user] = @user.id
|
||||
redirect_to :action => 'account', :display_name => @user.display_name
|
||||
else
|
||||
flash[:notice] = 'Something went wrong confirming that user.'
|
||||
@notice = 'Something went wrong confirming that user.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def confirm_email
|
||||
if params[:confirm_action]
|
||||
token = UserToken.find_by_token(params[:confirm_string])
|
||||
if token and token.user.new_email?
|
||||
@user = token.user
|
||||
@user.email = @user.new_email
|
||||
@user.new_email = nil
|
||||
@user.active = true
|
||||
@user.email_valid = true
|
||||
@user.save!
|
||||
token.destroy
|
||||
flash[:notice] = 'Confirmed your email address, thanks for signing up!'
|
||||
session[:user] = @user.id
|
||||
redirect_to :action => 'account', :display_name => @user.display_name
|
||||
else
|
||||
@notice = 'Something went wrong confirming that email address.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -167,6 +197,12 @@ class UserController < ApplicationController
|
|||
redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name
|
||||
end
|
||||
|
||||
def delete_image
|
||||
@user.image = nil
|
||||
@user.save!
|
||||
redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name
|
||||
end
|
||||
|
||||
def api_details
|
||||
render :text => @user.to_xml.to_s, :content_type => "text/xml"
|
||||
end
|
||||
|
@ -180,7 +216,7 @@ class UserController < ApplicationController
|
|||
end
|
||||
|
||||
def view
|
||||
@this_user = User.find_by_display_name(params[:display_name])
|
||||
@this_user = User.find_by_display_name(params[:display_name], :conditions => "visible = 1")
|
||||
|
||||
if @this_user
|
||||
@title = @this_user.display_name
|
||||
|
@ -193,20 +229,21 @@ class UserController < ApplicationController
|
|||
def make_friend
|
||||
if params[:display_name]
|
||||
name = params[:display_name]
|
||||
new_friend = User.find_by_display_name(name)
|
||||
new_friend = User.find_by_display_name(name, :conditions => "visible = 1")
|
||||
friend = Friend.new
|
||||
friend.user_id = @user.id
|
||||
friend.friend_user_id = new_friend.id
|
||||
unless @user.is_friends_with?(new_friend)
|
||||
if friend.save
|
||||
flash[:notice] = "#{name} is now your friend."
|
||||
Notifier::deliver_friend_notification(friend)
|
||||
Notifier.deliver_friend_notification(friend)
|
||||
else
|
||||
friend.add_error("Sorry, failed to add #{name} as a friend.")
|
||||
end
|
||||
else
|
||||
flash[:notice] = "You are already friends with #{name}."
|
||||
end
|
||||
|
||||
redirect_to :controller => 'user', :action => 'view'
|
||||
end
|
||||
end
|
||||
|
@ -214,16 +251,15 @@ class UserController < ApplicationController
|
|||
def remove_friend
|
||||
if params[:display_name]
|
||||
name = params[:display_name]
|
||||
friend = User.find_by_display_name(name)
|
||||
friend = User.find_by_display_name(name, :conditions => "visible = 1")
|
||||
if @user.is_friends_with?(friend)
|
||||
Friend.delete_all "user_id = #{@user.id} AND friend_user_id = #{friend.id}"
|
||||
flash[:notice] = "#{friend.display_name} was removed from your friends."
|
||||
else
|
||||
flash[:notice] = "#{friend.display_name} was not already one of your friends."
|
||||
flash[:notice] = "#{friend.display_name} is not one of your friends."
|
||||
end
|
||||
|
||||
redirect_to :controller => 'user', :action => 'view'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Friend < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
belongs_to :befriender, :class_name => "User", :foreign_key => :user_id
|
||||
belongs_to :befriendee, :class_name => "User", :foreign_key => :friend_user_id
|
||||
end
|
||||
|
|
|
@ -19,6 +19,9 @@ class Node < ActiveRecord::Base
|
|||
|
||||
has_many :node_tags, :foreign_key => :id
|
||||
|
||||
has_many :old_way_nodes
|
||||
has_many :ways_via_history, :class_name=> "Way", :through => :old_way_nodes, :source => :way
|
||||
|
||||
has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
|
||||
has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation, :extend => ObjectFinder
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
class Notifier < ActionMailer::Base
|
||||
def signup_confirm(user, token)
|
||||
recipients user.email
|
||||
|
@ -10,6 +9,17 @@ class Notifier < ActionMailer::Base
|
|||
:confirm_string => token.token)
|
||||
end
|
||||
|
||||
def email_confirm(user, token)
|
||||
recipients user.new_email
|
||||
from "webmaster@openstreetmap.org"
|
||||
subject "[OpenStreetMap] Confirm your email address"
|
||||
headers "Auto-Submitted" => "auto-generated"
|
||||
body :address => user.new_email,
|
||||
:url => url_for(:host => SERVER_URL,
|
||||
:controller => "user", :action => "confirm_email",
|
||||
:confirm_string => token.token)
|
||||
end
|
||||
|
||||
def lost_password(user, token)
|
||||
recipients user.email
|
||||
from "webmaster@openstreetmap.org"
|
||||
|
@ -29,7 +39,7 @@ class Notifier < ActionMailer::Base
|
|||
end
|
||||
|
||||
def gpx_success(trace, possible_points)
|
||||
recipients trace.user.email
|
||||
recipients trace.user.email if trace.user.email_valid
|
||||
from "webmaster@openstreetmap.org"
|
||||
subject "[OpenStreetMap] GPX Import success"
|
||||
headers "Auto-Submitted" => "auto-generated"
|
||||
|
@ -41,7 +51,7 @@ class Notifier < ActionMailer::Base
|
|||
end
|
||||
|
||||
def gpx_failure(trace, error)
|
||||
recipients trace.user.email
|
||||
recipients trace.user.email if trace.user.email_valid
|
||||
from "webmaster@openstreetmap.org"
|
||||
subject "[OpenStreetMap] GPX Import failure"
|
||||
headers "Auto-Submitted" => "auto-generated"
|
||||
|
@ -52,7 +62,7 @@ class Notifier < ActionMailer::Base
|
|||
end
|
||||
|
||||
def message_notification(message)
|
||||
recipients message.recipient.email
|
||||
recipients message.recipient.email if message.recipient.email_valid
|
||||
from "webmaster@openstreetmap.org"
|
||||
subject "[OpenStreetMap] #{message.sender.display_name} sent you a new message"
|
||||
headers "Auto-Submitted" => "auto-generated"
|
||||
|
@ -69,7 +79,7 @@ class Notifier < ActionMailer::Base
|
|||
end
|
||||
|
||||
def diary_comment_notification(comment)
|
||||
recipients comment.diary_entry.user.email
|
||||
recipients comment.diary_entry.user.email if comment.diary_entry.user.email_valid
|
||||
from "webmaster@openstreetmap.org"
|
||||
subject "[OpenStreetMap] #{comment.user.display_name} commented on your diary entry"
|
||||
headers "Auto-Submitted" => "auto-generated"
|
||||
|
@ -100,7 +110,7 @@ class Notifier < ActionMailer::Base
|
|||
befriender = User.find_by_id(friend.user_id)
|
||||
befriendee = User.find_by_id(friend.friend_user_id)
|
||||
|
||||
recipients befriendee.email
|
||||
recipients befriendee.email if befriendee.email_valid
|
||||
from "webmaster@openstreetmap.org"
|
||||
subject "[OpenStreetMap] #{befriender.display_name} added you as a friend"
|
||||
headers "Auto-Submitted" => "auto-generated"
|
||||
|
|
|
@ -112,6 +112,35 @@ class OldWay < ActiveRecord::Base
|
|||
return el1
|
||||
end
|
||||
|
||||
# Read full version of old way
|
||||
# For get_nodes_undelete, uses same nodes, even if they've moved since
|
||||
# For get_nodes_revert, allocates new ids
|
||||
# Currently returns Potlatch-style array
|
||||
|
||||
def get_nodes_undelete
|
||||
points = []
|
||||
self.nds.each do |n|
|
||||
node=Node.find(n)
|
||||
points << [node.lon, node.lat, n, node.visible ? 1 : 0, node.tags_as_hash]
|
||||
end
|
||||
points
|
||||
end
|
||||
|
||||
def get_nodes_revert
|
||||
points=[]
|
||||
self.nds.each do |n|
|
||||
oldnode=OldNode.find(:first, :conditions=>['id=? AND timestamp<=?',n,self.timestamp], :order=>"timestamp DESC")
|
||||
curnode=Node.find(n)
|
||||
id=n; v=curnode.visible ? 1 : 0
|
||||
if oldnode.lat!=curnode.lat or oldnode.lon!=curnode.lon or oldnode.tags!=curnode.tags then
|
||||
# node has changed: if it's in other ways, give it a new id
|
||||
if curnode.ways-[self.id] then id=-1; v=nil end
|
||||
end
|
||||
points << [oldnode.lon, oldnode.lat, id, v, oldnode.tags_as_hash]
|
||||
end
|
||||
points
|
||||
end
|
||||
|
||||
# Temporary method to match interface to nodes
|
||||
def tags_as_hash
|
||||
return self.tags
|
||||
|
|
|
@ -2,4 +2,6 @@ class OldWayNode < ActiveRecord::Base
|
|||
set_table_name 'way_nodes'
|
||||
|
||||
set_primary_keys :id, :version, :sequence_id
|
||||
|
||||
belongs_to :way, :foreign_key=> :id
|
||||
end
|
||||
|
|
|
@ -112,6 +112,36 @@ class Relation < ActiveRecord::Base
|
|||
return el1
|
||||
end
|
||||
|
||||
def self.find_for_nodes(ids, options = {})
|
||||
if ids.empty?
|
||||
return []
|
||||
else
|
||||
self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'node' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
|
||||
return self.find(:all, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_for_ways(ids, options = {})
|
||||
if ids.empty?
|
||||
return []
|
||||
else
|
||||
self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'way' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
|
||||
return self.find(:all, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.find_for_relations(ids, options = {})
|
||||
if ids.empty?
|
||||
return []
|
||||
else
|
||||
self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'relation' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
|
||||
return self.find(:all, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# FIXME is this really needed?
|
||||
def members
|
||||
unless @members
|
||||
|
|
|
@ -58,18 +58,16 @@ class Trace < ActiveRecord::Base
|
|||
data
|
||||
end
|
||||
|
||||
# FIXME change to permanent filestore area
|
||||
def large_picture_name
|
||||
"/home/osm/icons/#{id}.gif"
|
||||
"#{GPX_IMAGE_DIR}/#{id}.gif"
|
||||
end
|
||||
|
||||
# FIXME change to permanent filestore area
|
||||
def icon_picture_name
|
||||
"/home/osm/icons/#{id}_icon.gif"
|
||||
"#{GPX_IMAGE_DIR}/#{id}_icon.gif"
|
||||
end
|
||||
|
||||
def trace_name
|
||||
"/home/osm/gpx/#{id}.gpx"
|
||||
"#{GPX_TRACE_DIR}/#{id}.gpx"
|
||||
end
|
||||
|
||||
def mime_type
|
||||
|
@ -158,7 +156,7 @@ class Trace < ActiveRecord::Base
|
|||
elsif bzipped
|
||||
system("bunzip2 -c #{trace_name} > #{tmpfile.path}")
|
||||
elsif zipped
|
||||
system("unzip -p #{trace_name} > #{tmpfile.path}")
|
||||
system("unzip -p #{trace_name} -x '__MACOSX/*' > #{tmpfile.path}")
|
||||
end
|
||||
|
||||
tmpfile.unlink
|
||||
|
@ -174,7 +172,7 @@ class Trace < ActiveRecord::Base
|
|||
def import
|
||||
logger.info("GPX Import importing #{name} (#{id}) from #{user.email}")
|
||||
|
||||
gpx = OSM::GPXImporter.new(self.xml_file)
|
||||
gpx = GPX::File.new(self.xml_file)
|
||||
|
||||
f_lat = 0
|
||||
f_lon = 0
|
||||
|
@ -189,18 +187,18 @@ class Trace < ActiveRecord::Base
|
|||
|
||||
gpx.points do |point|
|
||||
if first
|
||||
f_lat = point['latitude']
|
||||
f_lon = point['longitude']
|
||||
f_lat = point.latitude
|
||||
f_lon = point.longitude
|
||||
first = false
|
||||
end
|
||||
|
||||
tp = Tracepoint.new
|
||||
tp.lat = point['latitude'].to_f
|
||||
tp.lon = point['longitude'].to_f
|
||||
tp.altitude = point['altitude'].to_f
|
||||
tp.timestamp = point['timestamp']
|
||||
tp.lat = point.latitude
|
||||
tp.lon = point.longitude
|
||||
tp.altitude = point.altitude
|
||||
tp.timestamp = point.timestamp
|
||||
tp.gpx_id = id
|
||||
tp.trackid = point['segment'].to_i
|
||||
tp.trackid = point.segment
|
||||
tp.save!
|
||||
end
|
||||
|
||||
|
@ -217,8 +215,8 @@ class Trace < ActiveRecord::Base
|
|||
|
||||
self.latitude = f_lat
|
||||
self.longitude = f_lon
|
||||
self.large_picture = gpx.get_picture(min_lat, min_lon, max_lat, max_lon, gpx.actual_points)
|
||||
self.icon_picture = gpx.get_icon(min_lat, min_lon, max_lat, max_lon)
|
||||
self.large_picture = gpx.picture(min_lat, min_lon, max_lat, max_lon, gpx.actual_points)
|
||||
self.icon_picture = gpx.icon(min_lat, min_lon, max_lat, max_lon)
|
||||
self.size = gpx.actual_points
|
||||
self.inserted = true
|
||||
self.save!
|
||||
|
|
|
@ -6,7 +6,7 @@ class User < ActiveRecord::Base
|
|||
has_many :messages, :foreign_key => :to_user_id, :order => 'sent_on DESC'
|
||||
has_many :new_messages, :class_name => "Message", :foreign_key => :to_user_id, :conditions => "message_read = 0", :order => 'sent_on DESC'
|
||||
has_many :sent_messages, :class_name => "Message", :foreign_key => :from_user_id, :order => 'sent_on DESC'
|
||||
has_many :friends
|
||||
has_many :friends, :include => :befriendee, :conditions => "users.visible = 1"
|
||||
has_many :tokens, :class_name => "UserToken"
|
||||
has_many :preferences, :class_name => "UserPreference"
|
||||
|
||||
|
@ -48,7 +48,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
if user
|
||||
user = nil unless user.active? or options[:inactive]
|
||||
user = nil unless user.visible? and (user.active? or options[:inactive])
|
||||
end
|
||||
|
||||
token.update_attribute(:expiry, 1.week.from_now) if token and user
|
||||
|
@ -80,7 +80,7 @@ class User < ActiveRecord::Base
|
|||
if self.home_lon and self.home_lat
|
||||
gc = OSM::GreatCircle.new(self.home_lat, self.home_lon)
|
||||
bounds = gc.bounds(radius)
|
||||
nearby = User.find(:all, :conditions => "home_lat between #{bounds[:minlat]} and #{bounds[:maxlat]} and home_lon between #{bounds[:minlon]} and #{bounds[:maxlon]} and data_public = 1 and id != #{self.id}")
|
||||
nearby = User.find(:all, :conditions => "visible = 1 and home_lat between #{bounds[:minlat]} and #{bounds[:maxlat]} and home_lon between #{bounds[:minlon]} and #{bounds[:maxlon]} and data_public = 1 and id != #{self.id}")
|
||||
nearby.delete_if { |u| gc.distance(u.home_lat, u.home_lon) > radius }
|
||||
nearby.sort! { |u1,u2| gc.distance(u1.home_lat, u1.home_lon) <=> gc.distance(u2.home_lat, u2.home_lon) }
|
||||
else
|
||||
|
|
|
@ -252,17 +252,8 @@ class Way < ActiveRecord::Base
|
|||
|
||||
# FIXME: merge the potlatch code to delete the relations
|
||||
def delete_with_relations_and_nodes_and_history(user)
|
||||
|
||||
node_ids = self.nodes.collect {|node| node.id }
|
||||
node_ids_not_to_delete = []
|
||||
way_nodes = WayNode.find(:all, :conditions => "node_id in (#{node_ids.join(',')}) and id != #{self.id}")
|
||||
|
||||
node_ids_not_to_delete = way_nodes.collect {|way_node| way_node.node_id}
|
||||
|
||||
node_ids_to_delete = node_ids - node_ids_not_to_delete
|
||||
|
||||
# delete the nodes not used by other ways
|
||||
node_ids_to_delete.each do |node_id|
|
||||
self.unshared_node_ids.each do |node_id|
|
||||
n = Node.find(node_id)
|
||||
n.user_id = user.id
|
||||
n.visible = false
|
||||
|
@ -272,7 +263,18 @@ class Way < ActiveRecord::Base
|
|||
self.user_id = user.id
|
||||
|
||||
self.delete_with_history(user)
|
||||
end
|
||||
|
||||
# Find nodes that belong to this way only
|
||||
def unshared_node_ids
|
||||
node_ids = self.nodes.collect { |node| node.id }
|
||||
|
||||
unless node_ids.empty?
|
||||
way_nodes = WayNode.find(:all, :conditions => "node_id in (#{node_ids.join(',')}) and id != #{self.id}")
|
||||
node_ids = node_ids - way_nodes.collect { |way_node| way_node.node_id }
|
||||
end
|
||||
|
||||
return node_ids
|
||||
end
|
||||
|
||||
# Temporary method to match interface to nodes
|
||||
|
|
|
@ -3,13 +3,17 @@
|
|||
<% if diary_entry.latitude and diary_entry.longitude %>
|
||||
Coordinates: <div class="geo" style="display: inline"><span class="latitude"><%= diary_entry.latitude %></span>; <span class="longitude"><%= diary_entry.longitude %></span></div> (<%=link_to 'map', :controller => 'site', :action => 'index', :lat => diary_entry.latitude, :lon => diary_entry.longitude, :zoom => 14 %> / <%=link_to 'edit', :controller => 'site', :action => 'edit', :lat => diary_entry.latitude, :lon => diary_entry.longitude, :zoom => 14 %>)<br/>
|
||||
<% end %>
|
||||
Posted by <b><%= link_to h(diary_entry.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name %></b> at <%= diary_entry.created_at %><br />
|
||||
Posted by <b><%= link_to h(diary_entry.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_entry.user.display_name %></b> at <%= diary_entry.created_at %>
|
||||
<% if params[:action] == 'list' %>
|
||||
<br />
|
||||
<%= link_to 'Comment on this entry', :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'newcomment' %>
|
||||
|
|
||||
<%= link_to 'Reply to this entry', :controller => 'message', :action => 'new', :user_id => diary_entry.user.id, :title => "Re: #{diary_entry.title}" %>
|
||||
|
|
||||
<%= link_to pluralize(diary_entry.diary_comments.count, "comment"), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %>
|
||||
<% end %>
|
||||
<% if @user == diary_entry.user %>
|
||||
| <%= link_to 'Edit this entry', :action => 'edit', :display_name => @user.display_name, :id => diary_entry.id %>
|
||||
<% end %>
|
||||
<br />
|
||||
<hr />
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<h1><%= @title %></h1>
|
||||
|
||||
<%= error_messages_for 'diary_entry' %>
|
||||
|
||||
<% form_for :diary_entry do |f| %>
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
<% if @this_user %>
|
||||
<% if @user == @this_user %>
|
||||
<%= link_to 'New diary post', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
|
||||
<%= link_to 'New diary entry', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if @user %>
|
||||
<%= link_to 'New diary post', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
|
||||
<%= link_to 'New diary entry', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<% if flash[:notice] %>
|
||||
<div id="notice"><%= flash[:notice] %></div>
|
||||
<% if @notice || flash[:notice] %>
|
||||
<div id="notice"><%= @notice || flash[:notice] %></div>
|
||||
<% end %>
|
||||
|
||||
<%= yield %>
|
||||
|
@ -95,12 +95,6 @@
|
|||
<%= yield :left_menu %>
|
||||
</div>
|
||||
|
||||
<div id="sotm" class="left_menu">
|
||||
<div id="sotminfo">
|
||||
Come to the second OpenStreetMap Conference, <a href="http://www.stateofthemap.org">The State of the Map</a>: 12th-13th July 2008, Limerick, Ireland.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= yield :optionals %>
|
||||
<div id="cclogo">
|
||||
<center>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Use the OpenStreetMap web site to reply. *
|
||||
* *
|
||||
* Bitte antworten Sie nicht auf diese E-Mail. *
|
||||
* Verwenden Sie die OpenStreetMap Website zum antworten. *
|
||||
* Verwenden Sie die OpenStreetMap Website zum Antworten. *
|
||||
* *
|
||||
* Por favor, no responda a este mensaje. *
|
||||
* Utilice el OpenStreetMap sitio web para responder. *
|
||||
|
@ -33,7 +33,7 @@ or reply at <%= @replyurl %>
|
|||
* Use the OpenStreetMap web site to reply. *
|
||||
* *
|
||||
* Bitte antworten Sie nicht auf diese E-Mail. *
|
||||
* Verwenden Sie die OpenStreetMap Website zum antworten. *
|
||||
* Verwenden Sie die OpenStreetMap Website zum Antworten. *
|
||||
* *
|
||||
* Por favor, no responda a este mensaje. *
|
||||
* Utilice el OpenStreetMap sitio web para responder. *
|
||||
|
|
8
app/views/notifier/email_confirm.text.html.rhtml
Normal file
8
app/views/notifier/email_confirm.text.html.rhtml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<p>Hi,</p>
|
||||
|
||||
<p>Someone (hopefully you) would like to change their email address over at
|
||||
<%= SERVER_URL %> to <%= @address %>.</p>
|
||||
|
||||
<p>If this is you, please click the link below to confirm the change.</p>
|
||||
|
||||
<p><a href="<%= @url %>"><%= @url %></a></p>
|
8
app/views/notifier/email_confirm.text.plain.rhtml
Normal file
8
app/views/notifier/email_confirm.text.plain.rhtml
Normal file
|
@ -0,0 +1,8 @@
|
|||
Hi,
|
||||
|
||||
Someone (hopefully you) would like to change their email address over at
|
||||
<%= SERVER_URL %> to <%= @address %>.
|
||||
|
||||
If this is you, please click the link below to confirm the change.
|
||||
|
||||
<%= @url %>
|
|
@ -4,7 +4,7 @@
|
|||
* Use the OpenStreetMap web site to reply. *
|
||||
* *
|
||||
* Bitte antworten Sie nicht auf diese E-Mail. *
|
||||
* Verwenden Sie die OpenStreetMap Website zum antworten. *
|
||||
* Verwenden Sie die OpenStreetMap Website zum Antworten. *
|
||||
* *
|
||||
* Por favor, no responda a este mensaje. *
|
||||
* Utilice el OpenStreetMap sitio web para responder. *
|
||||
|
@ -31,7 +31,7 @@ and you can reply at <%= @replyurl %>
|
|||
* Use the OpenStreetMap web site to reply. *
|
||||
* *
|
||||
* Bitte antworten Sie nicht auf diese E-Mail. *
|
||||
* Verwenden Sie die OpenStreetMap Website zum antworten. *
|
||||
* Verwenden Sie die OpenStreetMap Website zum Antworten. *
|
||||
* *
|
||||
* Por favor, no responda a este mensaje. *
|
||||
* Utilice el OpenStreetMap sitio web para responder. *
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<%= javascript_include_tag 'swfobject.js' %>
|
||||
<script type="text/javascript" defer="defer">
|
||||
var brokenContentSize = $("content").offsetWidth == 0;
|
||||
var fo = new SWFObject("/potlatch/potlatch.swf?d="+Math.round(Math.random()*1000), "potlatch", "100%", "100%", "6", "#FFFFFF");
|
||||
var fo = new SWFObject("<%= compute_public_path("potlatch.swf", "potlatch") %>", "potlatch", "100%", "100%", "6", "#FFFFFF");
|
||||
// 700,600 for fixed size, 100%,100% for resizable
|
||||
var changesaved=true;
|
||||
var winie=false; if (document.all && window.print) { winie=true; }
|
||||
|
@ -65,9 +65,9 @@
|
|||
fo.addVariable('token','<%= session[:token] %>');
|
||||
if (lat) { fo.addVariable('lat',lat); }
|
||||
if (lon) { fo.addVariable('long',lon); }
|
||||
<% if params['gpx'] %>
|
||||
fo.addVariable('gpx','<%= h(params['gpx']) %>');
|
||||
<% end %>
|
||||
<% if params['gpx'] %>fo.addVariable('gpx' ,'<%= h(params['gpx'] ) %>');<% end %>
|
||||
<% if params['way'] %>fo.addVariable('way' ,'<%= h(params['way'] ) %>');<% end %>
|
||||
<% if params['node'] %>fo.addVariable('node','<%= h(params['node']) %>');<% end %>
|
||||
fo.write("map");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,26 +2,31 @@
|
|||
<% cl = cycle('table0', 'table1') %>
|
||||
<td class="<%= cl %>">
|
||||
<% if trace.inserted %>
|
||||
<a href="<%= url_for :controller => 'trace', :action => 'view', :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => 'trace', :action => 'icon', :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
|
||||
<a href="<%= url_for :controller => 'trace', :action => 'view', :id => trace.id, :display_name => trace.user.display_name %>"><img src="<%= url_for :controller => 'trace', :action => 'icon', :id => trace.id, :display_name => trace.user.display_name %>" border="0" alt="" /></a>
|
||||
<% else %>
|
||||
<span style="color:red">PENDING</span>
|
||||
<span style="color:red">PENDING</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="<%= cl %>"><%= link_to trace.name, {:controller => 'trace', :action => 'view', :display_name => trace.user.display_name, :id => trace.id} %>
|
||||
<span class="gpxsummary" title="<%= trace.timestamp %>"> ...
|
||||
<% if trace.inserted %>
|
||||
(<%= trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %> points)
|
||||
(<%= trace.size.to_s.gsub(/(\d)(?=(\d{3})+$)/,'\1,') %> points)
|
||||
<% end %>
|
||||
... <%= time_ago_in_words( trace.timestamp ) %> ago</span>
|
||||
<%= link_to 'more', {:controller => 'trace', :action => 'view', :display_name => trace.user.display_name, :id => trace.id}, {:title => 'View Trace Details'} %> /
|
||||
<%= link_to_if trace.inserted?, 'map', {:controller => 'site', :action => 'index', :lat => trace.latitude, :lon => trace.longitude, :zoom => 14}, {:title => 'View Map'} %> /
|
||||
<%= link_to 'edit', {:controller => 'site', :action => 'edit', :gpx => trace.id }, {:title => 'Edit Map'} %>
|
||||
<% if trace.public? %>
|
||||
<span style="color:green">PUBLIC</span>
|
||||
<% else %>
|
||||
<span style="color:red">PRIVATE</span>
|
||||
<% end %>
|
||||
<br />
|
||||
<%= h(trace.description) %>
|
||||
<br />
|
||||
by <%= link_to h(trace.user.display_name), {:controller => 'user', :action => 'view', :display_name => trace.user.display_name} %>
|
||||
in
|
||||
<% if trace.tags %>
|
||||
<% if !trace.tags.empty? %>
|
||||
in
|
||||
<% trace.tags.each do |tag| %>
|
||||
<%= link_to_tag tag.tag %>
|
||||
<% end %>
|
||||
|
|
|
@ -53,10 +53,10 @@
|
|||
<% unless @trace.public? %>
|
||||
<td><%= button_to 'Make this track public permanently', :controller => 'trace', :action => 'make_public', :id => @trace.id %></td>
|
||||
<% end %>
|
||||
<% if @trace.user.id == @user.id %>
|
||||
<% if @trace.user == @user %>
|
||||
<td><%= button_to 'Edit this track', :controller => 'trace', :action => 'edit', :id => @trace.id %></td>
|
||||
<% end %>
|
||||
<% if @trace.user.id == @user.id %>
|
||||
<% if @trace.user == @user %>
|
||||
<td><%= button_to 'Delete this track', :controller => 'trace', :action => 'delete', :id => @trace.id %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<%= error_messages_for 'user' %>
|
||||
<% form_for :user, @user do |f| %>
|
||||
<table style="width : 100%">
|
||||
<tr><td>Email</td><td><%= @user.email %></td></tr>
|
||||
<tr><td>Email</td><td><%= f.text_field :email %></td></tr>
|
||||
<tr><td>Mapper since</td><td><%= @user.creation_time %> (<%= time_ago_in_words(@user.creation_time) %> ago)</td></tr>
|
||||
<tr><td>Display Name</td><td><%= f.text_field :display_name %></td></tr>
|
||||
<tr><td>Password</td><td><%= f.password_field :pass_crypt, {:value => '', :size => 50, :maxlength => 255} %></td></tr>
|
||||
|
|
8
app/views/user/confirm_email.rhtml
Normal file
8
app/views/user/confirm_email.rhtml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<h1>Confirm a change of email address</h1>
|
||||
|
||||
<p>Press the confirm button below to confirm your new email address.</p>
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" name="confirm_string" value="<%= params[:confirm_string] %>">
|
||||
<input type="submit" name="confirm_action" value="Confrm">
|
||||
</form>
|
|
@ -1,7 +1,7 @@
|
|||
<h1>Create a user account</h1><br>
|
||||
Fill in the form and we'll send you a quick email to activate your account.<br><br>
|
||||
|
||||
By creating an account, you agree that all work uploaded to openstreetmap.org and all data created by use of any tools which connect to openstreetmap.org is to be licensed under <a href="http://creativecommons.org/licenses/by-sa/2.0/">this Creative Commons license (by-sa)</a>.<br><br>
|
||||
By creating an account, you agree that all work uploaded to openstreetmap.org and all data created by use of any tools which connect to openstreetmap.org is to be (non-exclusively) licensed under <a href="http://creativecommons.org/licenses/by-sa/2.0/">this Creative Commons license (by-sa)</a>.<br><br>
|
||||
|
||||
<%= error_messages_for 'user' %>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div id="userinformation">
|
||||
<% if @user and @this_user.id == @user.id %>
|
||||
<%= link_to 'my diary', :controller => 'diary_entry', :action => 'list', :display_name => @user.display_name %>
|
||||
| <%= link_to 'new diary post', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
|
||||
| <%= link_to 'new diary entry', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
|
||||
| <%= link_to 'my traces', :controller => 'trace', :action=>'mine' %>
|
||||
| <%= link_to 'my settings', :controller => 'user', :action => 'account', :display_name => @user.display_name %>
|
||||
<% else %>
|
||||
|
@ -20,7 +20,10 @@
|
|||
|
||||
<h3>User image</h3>
|
||||
<% if @this_user.image %>
|
||||
<%= image_tag url_for_file_column(@this_user, "image") %>
|
||||
<%= image_tag url_for_file_column(@this_user, "image") %>
|
||||
<% if @user and @this_user.id == @user.id %>
|
||||
<%= button_to 'Delete Image', :action => 'delete_image' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<br />
|
||||
|
||||
|
@ -28,12 +31,12 @@
|
|||
Upload an image<br />
|
||||
<%= form_tag({:action=>'upload_image'}, :multipart => true)%>
|
||||
<%= file_column_field 'user', 'image' %>
|
||||
<input type="submit" name="Upload" />
|
||||
<%= submit_tag 'Add Image' %>
|
||||
</form>
|
||||
<% end %>
|
||||
|
||||
<h3>Description</h3>
|
||||
<div id="description"><%= simple_format(@this_user.description) %></div>
|
||||
<div id="description"><%= htmlize(@this_user.description) %></div>
|
||||
|
||||
<% if @this_user.home_lat.nil? or @this_user.home_lon.nil? %>
|
||||
<h3>User location</h3>
|
||||
|
|
|
@ -74,8 +74,3 @@ Rails::Initializer.run do |config|
|
|||
# Make Active Record use UTC-base instead of local time
|
||||
# config.active_record.default_timezone = :utc
|
||||
end
|
||||
|
||||
# This has to be after the above block for some reason (doesnt pull in /lib/osm.rb?)
|
||||
POTLATCH_PRESETS = Potlatch::Potlatch.get_presets()
|
||||
|
||||
|
||||
|
|
5
config/initializers/gpx.rb
Normal file
5
config/initializers/gpx.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Set location of GPX trace files
|
||||
GPX_TRACE_DIR = "/home/osm/traces"
|
||||
|
||||
# Set location of GPX image files
|
||||
GPX_IMAGE_DIR = "/home/osm/images"
|
7
config/initializers/libxml.rb
Normal file
7
config/initializers/libxml.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'rubygems'
|
||||
gem 'libxml-ruby', '>= 0.8.3'
|
||||
require 'libxml'
|
||||
|
||||
LibXML::XML::Parser.register_error_handler do |message|
|
||||
raise message
|
||||
end
|
6
config/initializers/potlatch.rb
Normal file
6
config/initializers/potlatch.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Load presets
|
||||
POTLATCH_PRESETS = Potlatch::Potlatch.get_presets()
|
||||
|
||||
# Use SQL (faster) or Rails (more elegant) for common Potlatch reads
|
||||
# getway speedup is approximately x2, whichways approximately x7
|
||||
POTLATCH_USE_SQL = false
|
1069
config/potlatch/localised.yaml
Normal file
1069
config/potlatch/localised.yaml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -4,4 +4,5 @@
|
|||
lcn 0x0000ff 50 10
|
||||
rcn 0x28c9fe 50 10
|
||||
ncn 0xff3333 50 10
|
||||
ldp 0x228022 50 10
|
||||
foot 0x228022 50 10
|
||||
trail 0x228022 50 10
|
||||
|
|
|
@ -84,9 +84,11 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.connect '/user/new', :controller => 'user', :action => 'new'
|
||||
map.connect '/user/save', :controller => 'user', :action => 'save'
|
||||
map.connect '/user/confirm', :controller => 'user', :action => 'confirm'
|
||||
map.connect '/user/confirm-email', :controller => 'user', :action => 'confirm_email'
|
||||
map.connect '/user/go_public', :controller => 'user', :action => 'go_public'
|
||||
map.connect '/user/reset-password', :controller => 'user', :action => 'reset_password'
|
||||
map.connect '/user/upload-image', :controller => 'user', :action => 'upload_image'
|
||||
map.connect '/user/delete-image', :controller => 'user', :action => 'delete_image'
|
||||
map.connect '/user/forgot-password', :controller => 'user', :action => 'lost_password'
|
||||
|
||||
map.connect '/index.html', :controller => 'site', :action => 'index'
|
||||
|
@ -133,7 +135,8 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.connect '/user/:display_name/diary/:id', :controller => 'diary_entry', :action => 'view', :id => /\d+/
|
||||
map.connect '/user/:display_name/diary/:id/newcomment', :controller => 'diary_entry', :action => 'comment', :id => /\d+/
|
||||
map.connect '/user/:display_name/diary/rss', :controller => 'diary_entry', :action => 'rss'
|
||||
map.connect '/user/:display_name/diary/newpost', :controller => 'diary_entry', :action => 'new'
|
||||
map.connect '/user/:display_name/diary/new', :controller => 'diary_entry', :action => 'new'
|
||||
map.connect '/user/:display_name/diary/:id/edit', :controller => 'diary_entry', :action => 'edit', :id => /\d+/
|
||||
map.connect '/user/:display_name/account', :controller => 'user', :action => 'account'
|
||||
map.connect '/user/:display_name/set_home', :controller => 'user', :action => 'set_home'
|
||||
map.connect '/diary', :controller => 'diary_entry', :action => 'list'
|
||||
|
|
9
db/migrate/012_add_admin_flag.rb
Normal file
9
db/migrate/012_add_admin_flag.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class AddAdminFlag < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column "users", "administrator", :boolean, :default => false, :null => false
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column "users", "administrator"
|
||||
end
|
||||
end
|
10
db/migrate/013_add_email_valid.rb
Normal file
10
db/migrate/013_add_email_valid.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class AddEmailValid < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column "users", "email_valid", :boolean, :default => false, :null => false
|
||||
User.update_all("email_valid = active")
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column "users", "email_valid"
|
||||
end
|
||||
end
|
9
db/migrate/014_add_new_email.rb
Normal file
9
db/migrate/014_add_new_email.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class AddNewEmail < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column "users", "new_email", :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column "users", "new_email"
|
||||
end
|
||||
end
|
10
db/migrate/015_add_user_visible.rb
Normal file
10
db/migrate/015_add_user_visible.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class AddUserVisible < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column "users", "visible", :boolean, :default => true, :null => false
|
||||
User.update_all("visible = 1")
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column "users", "visible"
|
||||
end
|
||||
end
|
|
@ -42,15 +42,6 @@ module GeoRecord
|
|||
return self.longitude.to_f / SCALE
|
||||
end
|
||||
|
||||
# Potlatch projections
|
||||
def lon_potlatch(baselong,masterscale)
|
||||
(self.lon-baselong)*masterscale
|
||||
end
|
||||
|
||||
def lat_potlatch(basey,masterscale)
|
||||
-(lat2y(self.lat)-basey)*masterscale
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def lat2y(a)
|
||||
|
|
168
lib/gpx.rb
Normal file
168
lib/gpx.rb
Normal file
|
@ -0,0 +1,168 @@
|
|||
module GPX
|
||||
class File
|
||||
require "libxml"
|
||||
|
||||
include LibXML
|
||||
|
||||
attr_reader :possible_points
|
||||
attr_reader :actual_points
|
||||
attr_reader :tracksegs
|
||||
|
||||
def initialize(file)
|
||||
@file = file
|
||||
end
|
||||
|
||||
def points
|
||||
@possible_points = 0
|
||||
@actual_points = 0
|
||||
@tracksegs = 0
|
||||
|
||||
@file.rewind
|
||||
|
||||
reader = XML::Reader.io(@file)
|
||||
|
||||
point = nil
|
||||
|
||||
while reader.read > 0
|
||||
if reader.node_type == XML::Reader::TYPE_ELEMENT
|
||||
if reader.name == "trkpt"
|
||||
point = TrkPt.new(@tracksegs, reader["lat"].to_f, reader["lon"].to_f)
|
||||
@possible_points += 1
|
||||
elsif reader.name == "ele" and point
|
||||
point.altitude = reader.read_string.to_f
|
||||
elsif reader.name == "time" and point
|
||||
point.timestamp = DateTime.parse(reader.read_string)
|
||||
end
|
||||
elsif reader.node_type == XML::Reader::TYPE_END_ELEMENT
|
||||
if reader.name == "trkpt" and point and point.valid?
|
||||
point.altitude ||= 0
|
||||
yield point
|
||||
@actual_points += 1
|
||||
elsif reader.name == "trkseg"
|
||||
@tracksegs += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def picture(min_lat, min_lon, max_lat, max_lon, num_points)
|
||||
frames = 10
|
||||
width = 250
|
||||
height = 250
|
||||
proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
|
||||
|
||||
linegc = Magick::Draw.new
|
||||
linegc.stroke_linejoin('miter')
|
||||
linegc.stroke_width(1)
|
||||
linegc.stroke('#BBBBBB')
|
||||
linegc.fill('#BBBBBB')
|
||||
|
||||
highlightgc = Magick::Draw.new
|
||||
highlightgc.stroke_linejoin('miter')
|
||||
highlightgc.stroke_width(3)
|
||||
highlightgc.stroke('#000000')
|
||||
highlightgc.fill('#000000')
|
||||
|
||||
images = []
|
||||
|
||||
frames.times do
|
||||
image = Magick::Image.new(width, height) do |image|
|
||||
image.background_color = 'white'
|
||||
image.format = 'GIF'
|
||||
end
|
||||
|
||||
images << image
|
||||
end
|
||||
|
||||
oldpx = 0.0
|
||||
oldpy = 0.0
|
||||
|
||||
first = true
|
||||
|
||||
m = 0
|
||||
mm = 0
|
||||
points do |p|
|
||||
px = proj.x(p.longitude)
|
||||
py = proj.y(p.latitude)
|
||||
|
||||
if m > 0
|
||||
frames.times do |n|
|
||||
if n == mm
|
||||
gc = highlightgc.dup
|
||||
else
|
||||
gc = linegc.dup
|
||||
end
|
||||
|
||||
gc.line(px, py, oldpx, oldpy)
|
||||
|
||||
gc.draw(images[n])
|
||||
end
|
||||
end
|
||||
|
||||
m += 1
|
||||
if m > num_points.to_f / frames.to_f * (mm+1)
|
||||
mm += 1
|
||||
end
|
||||
|
||||
oldpy = py
|
||||
oldpx = px
|
||||
end
|
||||
|
||||
il = Magick::ImageList.new
|
||||
|
||||
images.each do |f|
|
||||
il << f
|
||||
end
|
||||
|
||||
il.delay = 50
|
||||
il.format = 'GIF'
|
||||
|
||||
return il.to_blob
|
||||
end
|
||||
|
||||
def icon(min_lat, min_lon, max_lat, max_lon)
|
||||
width = 50
|
||||
height = 50
|
||||
proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
|
||||
|
||||
gc = Magick::Draw.new
|
||||
gc.stroke_linejoin('miter')
|
||||
gc.stroke_width(1)
|
||||
gc.stroke('#000000')
|
||||
gc.fill('#000000')
|
||||
|
||||
image = Magick::Image.new(width, height) do |image|
|
||||
image.background_color = 'white'
|
||||
image.format = 'GIF'
|
||||
end
|
||||
|
||||
oldpx = 0.0
|
||||
oldpy = 0.0
|
||||
|
||||
first = true
|
||||
|
||||
points do |p|
|
||||
px = proj.x(p.longitude)
|
||||
py = proj.y(p.latitude)
|
||||
|
||||
gc.dup.line(px, py, oldpx, oldpy).draw(image) unless first
|
||||
|
||||
first = false
|
||||
oldpy = py
|
||||
oldpx = px
|
||||
end
|
||||
|
||||
return image.to_blob
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
class TrkPt < Struct.new(:segment, :latitude, :longitude, :altitude, :timestamp)
|
||||
def valid?
|
||||
self.latitude and self.longitude and self.timestamp and
|
||||
self.latitude >= -90 and self.latitude <= 90 and
|
||||
self.longitude >= -180 and self.longitude <= 180
|
||||
end
|
||||
end
|
||||
end
|
193
lib/osm.rb
193
lib/osm.rb
|
@ -93,199 +93,6 @@ module OSM
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
# This piece of magic reads a GPX with SAX and spits out
|
||||
# lat/lng and stuff
|
||||
#
|
||||
# This would print every latitude value:
|
||||
#
|
||||
# gpx = OSM::GPXImporter.new('somefile.gpx')
|
||||
# gpx.points {|p| puts p['latitude']}
|
||||
class GPXImporter
|
||||
# FIXME swap REXML for libXML
|
||||
attr_reader :possible_points
|
||||
attr_reader :actual_points
|
||||
attr_reader :tracksegs
|
||||
|
||||
def initialize(file)
|
||||
@file = file
|
||||
end
|
||||
|
||||
def points
|
||||
@possible_points = 0
|
||||
@actual_points = 0
|
||||
@tracksegs = 0
|
||||
|
||||
lat = -1
|
||||
lon = -1
|
||||
ele = -1
|
||||
date = DateTime.now();
|
||||
gotlatlon = false
|
||||
gotele = false
|
||||
gotdate = false
|
||||
|
||||
@file.rewind
|
||||
|
||||
parser = REXML::Parsers::SAX2Parser.new(@file)
|
||||
|
||||
parser.listen( :start_element, %w{ trkpt }) do |uri,localname,qname,attributes|
|
||||
lat = attributes['lat'].to_f
|
||||
lon = attributes['lon'].to_f
|
||||
gotlatlon = true
|
||||
gotele = false
|
||||
gotdate = false
|
||||
@possible_points += 1
|
||||
end
|
||||
|
||||
parser.listen( :characters, %w{ ele } ) do |text|
|
||||
ele = text
|
||||
gotele = true
|
||||
end
|
||||
|
||||
parser.listen( :characters, %w{ time } ) do |text|
|
||||
if text && text != ''
|
||||
begin
|
||||
date = DateTime.parse(text)
|
||||
gotdate = true
|
||||
rescue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
parser.listen( :end_element, %w{ trkseg } ) do |uri, localname, qname|
|
||||
@tracksegs += 1
|
||||
end
|
||||
|
||||
parser.listen( :end_element, %w{ trkpt } ) do |uri,localname,qname|
|
||||
if gotlatlon && gotdate
|
||||
ele = '0' unless gotele
|
||||
if lat < 90 && lat > -90 && lon > -180 && lon < 180
|
||||
@actual_points += 1
|
||||
yield Hash['latitude' => lat, 'longitude' => lon, 'timestamp' => date, 'altitude' => ele, 'segment' => @tracksegs]
|
||||
end
|
||||
end
|
||||
gotlatlon = false
|
||||
gotele = false
|
||||
gotdate = false
|
||||
end
|
||||
|
||||
parser.parse
|
||||
end
|
||||
|
||||
def get_picture(min_lat, min_lon, max_lat, max_lon, num_points)
|
||||
#puts "getting picfor bbox #{min_lat},#{min_lon} - #{max_lat},#{max_lon}"
|
||||
frames = 10
|
||||
width = 250
|
||||
height = 250
|
||||
proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
|
||||
|
||||
linegc = Magick::Draw.new
|
||||
linegc.stroke_linejoin('miter')
|
||||
linegc.stroke_width(1)
|
||||
linegc.stroke('#BBBBBB')
|
||||
linegc.fill('#BBBBBB')
|
||||
|
||||
highlightgc = Magick::Draw.new
|
||||
highlightgc.stroke_linejoin('miter')
|
||||
highlightgc.stroke_width(3)
|
||||
highlightgc.stroke('#000000')
|
||||
highlightgc.fill('#000000')
|
||||
|
||||
images = []
|
||||
|
||||
frames.times do
|
||||
image = Magick::Image.new(width, height) do |image|
|
||||
image.background_color = 'white'
|
||||
image.format = 'GIF'
|
||||
end
|
||||
|
||||
images << image
|
||||
end
|
||||
|
||||
oldpx = 0.0
|
||||
oldpy = 0.0
|
||||
|
||||
first = true
|
||||
|
||||
m = 0
|
||||
mm = 0
|
||||
points do |p|
|
||||
px = proj.x(p['longitude'])
|
||||
py = proj.y(p['latitude'])
|
||||
|
||||
if m > 0
|
||||
frames.times do |n|
|
||||
if n == mm
|
||||
gc = highlightgc.dup
|
||||
else
|
||||
gc = linegc.dup
|
||||
end
|
||||
|
||||
gc.line(px, py, oldpx, oldpy)
|
||||
|
||||
gc.draw(images[n])
|
||||
end
|
||||
end
|
||||
|
||||
m += 1
|
||||
if m > num_points.to_f / frames.to_f * (mm+1)
|
||||
mm += 1
|
||||
end
|
||||
|
||||
oldpy = py
|
||||
oldpx = px
|
||||
end
|
||||
|
||||
il = Magick::ImageList.new
|
||||
|
||||
images.each do |f|
|
||||
il << f
|
||||
end
|
||||
|
||||
il.delay = 50
|
||||
il.format = 'GIF'
|
||||
|
||||
return il.to_blob
|
||||
end
|
||||
|
||||
def get_icon(min_lat, min_lon, max_lat, max_lon)
|
||||
#puts "getting icon for bbox #{min_lat},#{min_lon} - #{max_lat},#{max_lon}"
|
||||
width = 50
|
||||
height = 50
|
||||
proj = OSM::Mercator.new(min_lat, min_lon, max_lat, max_lon, width, height)
|
||||
|
||||
gc = Magick::Draw.new
|
||||
gc.stroke_linejoin('miter')
|
||||
gc.stroke_width(1)
|
||||
gc.stroke('#000000')
|
||||
gc.fill('#000000')
|
||||
|
||||
image = Magick::Image.new(width, height) do |image|
|
||||
image.background_color = 'white'
|
||||
image.format = 'GIF'
|
||||
end
|
||||
|
||||
oldpx = 0.0
|
||||
oldpy = 0.0
|
||||
|
||||
first = true
|
||||
|
||||
points do |p|
|
||||
px = proj.x(p['longitude'])
|
||||
py = proj.y(p['latitude'])
|
||||
|
||||
gc.dup.line(px, py, oldpx, oldpy).draw(image) unless first
|
||||
|
||||
first = false
|
||||
oldpy = py
|
||||
oldpx = px
|
||||
end
|
||||
|
||||
return image.to_blob
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class GreatCircle
|
||||
include Math
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ module Potlatch
|
|||
when 'Hash'
|
||||
a=3.chr
|
||||
n.each do |k,v|
|
||||
a+=encodestring(k)+encodevalue(v)
|
||||
a+=encodestring(k.to_s)+encodevalue(v)
|
||||
end
|
||||
a+0.chr+0.chr+9.chr
|
||||
when 'String'
|
||||
|
@ -195,7 +195,10 @@ module Potlatch
|
|||
}
|
||||
end
|
||||
|
||||
[presets,presetmenus,presetnames,colours,casing,areas,autotags,relcolours,relalphas,relwidths]
|
||||
# Read internationalisation
|
||||
localised = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/localised.yaml"))
|
||||
|
||||
[presets,presetmenus,presetnames,colours,casing,areas,autotags,relcolours,relalphas,relwidths,localised]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 32 KiB |
Binary file not shown.
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 39 KiB |
|
@ -3,6 +3,15 @@ var map;
|
|||
var markers;
|
||||
var popup;
|
||||
|
||||
var nonamekeys = {
|
||||
'openstreetmap.org': '2f59745a6b525b4ebdb100891d5b6711',
|
||||
'www.openstreetmap.org': 'fd093e52f0965d46bb1c6c6281022199',
|
||||
'openstreetmap.com': '4c60e7f5f31c576a9bb8da71c8d61152',
|
||||
'www.openstreetmap.com': '142f25a0770a51a9a400b3513834a199',
|
||||
'openstreetmap.net': '687c58fd1d715596bfc94abe653d8ac0',
|
||||
'www.openstreetmap.net': '0bd1654141c85d30b9c2ccdb5302f2e4'
|
||||
};
|
||||
|
||||
OpenLayers._getScriptLocation = function () {
|
||||
return "/openlayers/";
|
||||
}
|
||||
|
@ -42,6 +51,18 @@ function createMap(divName, options) {
|
|||
});
|
||||
map.addLayer(cyclemap);
|
||||
|
||||
var nonamekey = nonamekeys[document.domain];
|
||||
var noname = new OpenLayers.Layer.OSM("NoName", [
|
||||
"http://a.tile.cloudmade.com/" + nonamekey + "/3/256/",
|
||||
"http://b.tile.cloudmade.com/" + nonamekey + "/3/256/",
|
||||
"http://c.tile.cloudmade.com/" + nonamekey + "/3/256/"
|
||||
], {
|
||||
displayOutsideMaxExtent: true,
|
||||
wrapDateLine: true,
|
||||
numZoomLevels: 19
|
||||
});
|
||||
map.addLayer(noname);
|
||||
|
||||
var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", {
|
||||
displayOutsideMaxExtent: true,
|
||||
wrapDateLine: true
|
||||
|
|
|
@ -143,9 +143,9 @@ OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
|||
*/
|
||||
initialize: function(name, options) {
|
||||
var url = [
|
||||
"http://a.tah.openstreetmap.org/Tiles/tile.php/",
|
||||
"http://b.tah.openstreetmap.org/Tiles/tile.php/",
|
||||
"http://c.tah.openstreetmap.org/Tiles/tile.php/"
|
||||
"http://a.tah.openstreetmap.org/Tiles/tile/",
|
||||
"http://b.tah.openstreetmap.org/Tiles/tile/",
|
||||
"http://c.tah.openstreetmap.org/Tiles/tile/"
|
||||
];
|
||||
options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options);
|
||||
var newArguments = [name, url, options];
|
||||
|
@ -171,11 +171,11 @@ OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
|||
*/
|
||||
initialize: function(name, options) {
|
||||
var url = [
|
||||
"http://a.thunderflames.org/tiles/cycle/",
|
||||
"http://b.thunderflames.org/tiles/cycle/",
|
||||
"http://c.thunderflames.org/tiles/cycle/"
|
||||
"http://a.andy.sandbox.cloudmade.com/tiles/cycle/",
|
||||
"http://b.andy.sandbox.cloudmade.com/tiles/cycle/",
|
||||
"http://c.andy.sandbox.cloudmade.com/tiles/cycle/"
|
||||
];
|
||||
options = OpenLayers.Util.extend({ numZoomLevels: 17 }, options);
|
||||
options = OpenLayers.Util.extend({ numZoomLevels: 18 }, options);
|
||||
var newArguments = [name, url, options];
|
||||
OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
||||
},
|
||||
|
@ -199,9 +199,9 @@ OpenLayers.Layer.OSM.Maplint = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
|||
*/
|
||||
initialize: function(name, options) {
|
||||
var url = [
|
||||
"http://d.tah.openstreetmap.org/Tiles/maplint.php/",
|
||||
"http://e.tah.openstreetmap.org/Tiles/maplint.php/",
|
||||
"http://f.tah.openstreetmap.org/Tiles/maplint.php/"
|
||||
"http://d.tah.openstreetmap.org/Tiles/maplint/",
|
||||
"http://e.tah.openstreetmap.org/Tiles/maplint/",
|
||||
"http://f.tah.openstreetmap.org/Tiles/maplint/"
|
||||
];
|
||||
options = OpenLayers.Util.extend({ numZoomLevels: 18, isBaseLayer: false, visibility: false }, options);
|
||||
var newArguments = [name, url, options];
|
||||
|
|
BIN
public/potlatch/beep.mp3
Normal file
BIN
public/potlatch/beep.mp3
Normal file
Binary file not shown.
Binary file not shown.
|
@ -2,17 +2,27 @@
|
|||
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
|
||||
Session.find(:all, :conditions => ["updated_at < ?", 1.week.ago]).each do |session|
|
||||
begin
|
||||
if session[:user] and User.find(session[:user])
|
||||
session.destroy if session.updated_at < 1.month.ago
|
||||
else
|
||||
last_session_id = 0
|
||||
|
||||
begin
|
||||
sessions = Session.find(:all,
|
||||
:conditions => ["updated_at < ? and id > ?", 1.week.ago, last_session_id],
|
||||
:order => :id, :limit => 1000)
|
||||
|
||||
sessions.each do |session|
|
||||
last_session_id = session.id
|
||||
|
||||
begin
|
||||
if session[:user] and User.find(session[:user])
|
||||
session.destroy if session.updated_at < 1.month.ago
|
||||
else
|
||||
session.destroy
|
||||
end
|
||||
rescue Exception => ex
|
||||
puts "Invalid session #{session.session_id}: #{ex.to_s}"
|
||||
session.destroy
|
||||
end
|
||||
rescue Exception => ex
|
||||
puts "Invalid session #{session.session_id}: #{ex.to_s}"
|
||||
session.destroy
|
||||
end
|
||||
end
|
||||
end while sessions.length > 0
|
||||
|
||||
UserToken.delete_all("expiry < NOW()")
|
||||
|
|
|
@ -35,7 +35,7 @@ begin
|
|||
|
||||
Trace.sum(:size, :group => :user_id, :order => "sum_size DESC", :limit => 50).each do |user, count|
|
||||
display_name = User.find(user).display_name.gsub('@', ' at ').gsub('.', ' dot ')
|
||||
puts "<tr><td>#{display_name}</td><td>#{count}</td></tr>"
|
||||
puts "<tr><td><a href=\"/user/#{display_name}\">#{display_name}</a></td><td>#{count}</td></tr>"
|
||||
end
|
||||
|
||||
puts "</table>"
|
||||
|
@ -83,7 +83,7 @@ begin
|
|||
else
|
||||
display_name = User.find(column[0]).display_name.gsub('@', ' at ').gsub('.', ' dot ')
|
||||
count = column[1]
|
||||
puts "<td>#{count} #{display_name}</td>"
|
||||
puts "<td>#{count} <a href=\"/user/#{display_name}\">#{display_name}</a></td>"
|
||||
end
|
||||
end
|
||||
puts "</tr>"
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
module ApiMapHelpers
|
||||
def self.included(klass)
|
||||
klass.extend(ClassMethods)
|
||||
end
|
||||
|
||||
def boundary_params(key)
|
||||
case key
|
||||
when :valid
|
||||
'-0.3565352711206896,51.464740877658045,-0.2686446461206896,51.508686190158045'
|
||||
when :min_lat_more_than_max_lat
|
||||
'-0.3565352711206896,51.508686190158045,-0.2686446461206896,51.464740877658045'
|
||||
when :min_lon_more_than_max_lon
|
||||
'51.464740877658045,-0.2686446461206896,51.508686190158045,-0.3565352711206896'
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def otherasdfa
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "When accessing /api/0.5/map" do
|
||||
controller_name :api
|
||||
include ApiMapHelpers
|
||||
|
||||
before(:each) do
|
||||
end
|
||||
|
||||
it "should _return success_ with _correct boundary longitudes/latitudes_" do
|
||||
get :map, :bbox => boundary_params(:valid)
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it "should return an _error_ when _minimum longitude more than or equal to maximum longitude_" do
|
||||
get :map, :bbox => boundary_params(:min_lat_more_than_max_lat)
|
||||
response.should_not be_success
|
||||
end
|
||||
|
||||
it "should return an error unless minimum latitude less than maximum latitude" do
|
||||
get :map, :bbox => boundary_params(:min_lon_more_than_max_lon)
|
||||
response.should_not be_success
|
||||
end
|
||||
|
||||
it "should return an error unless latitudes are between -90 and 90 degrees" do
|
||||
pending
|
||||
end
|
||||
|
||||
it "should return an error unless longitudes are between -180 and 180 degrees" do
|
||||
pending
|
||||
end
|
||||
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe ApiHelper do
|
||||
|
||||
#Delete this example and add some real ones or delete this file
|
||||
it "should include the ApiHelper" do
|
||||
included_modules = self.metaclass.send :included_modules
|
||||
included_modules.should include(ApiHelper)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
--exclude "spec/*,gems/*"
|
||||
--rails
|
|
@ -1,7 +0,0 @@
|
|||
--colour
|
||||
--format
|
||||
progress
|
||||
--loadby
|
||||
mtime
|
||||
--reverse
|
||||
--backtrace
|
|
@ -1,41 +0,0 @@
|
|||
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
||||
# from the project root directory.
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
||||
require 'spec'
|
||||
require 'spec/rails'
|
||||
|
||||
require 'ruby-debug'
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
# If you're not using ActiveRecord you should remove these
|
||||
# lines, delete config/database.yml and disable :active_record
|
||||
# in your config/boot.rb
|
||||
config.use_transactional_fixtures = true
|
||||
config.use_instantiated_fixtures = false
|
||||
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
||||
|
||||
# == Fixtures
|
||||
#
|
||||
# You can declare fixtures for each example_group like this:
|
||||
# describe "...." do
|
||||
# fixtures :table_a, :table_b
|
||||
#
|
||||
# Alternatively, if you prefer to declare them only once, you can
|
||||
# do so right here. Just uncomment the next line and replace the fixture
|
||||
# names with your fixtures.
|
||||
#
|
||||
# config.global_fixtures = :table_a, :table_b
|
||||
#
|
||||
# If you declare global fixtures, be aware that they will be declared
|
||||
# for all of your examples, even those that don't use them.
|
||||
#
|
||||
# == Mock Framework
|
||||
#
|
||||
# RSpec uses it's own mocking framework by default. If you prefer to
|
||||
# use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
end
|
|
@ -1,4 +0,0 @@
|
|||
dir = File.dirname(__FILE__)
|
||||
Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
|
||||
require file
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
||||
require 'spec/rails/story_adapter'
|
1028
vendor/gems/rspec-1.1.2/CHANGES
vendored
1028
vendor/gems/rspec-1.1.2/CHANGES
vendored
File diff suppressed because it is too large
Load diff
20
vendor/gems/rspec-1.1.2/MIT-LICENSE
vendored
20
vendor/gems/rspec-1.1.2/MIT-LICENSE
vendored
|
@ -1,20 +0,0 @@
|
|||
Copyright (c) 2005-2007 The RSpec Development Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
71
vendor/gems/rspec-1.1.2/README
vendored
71
vendor/gems/rspec-1.1.2/README
vendored
|
@ -1,71 +0,0 @@
|
|||
== RSpec
|
||||
|
||||
RSpec is a Behaviour Driven Development framework with tools to express User Stories
|
||||
with Executable Scenarios and Executable Examples at the code level.
|
||||
|
||||
RSpec ships with several modules:
|
||||
|
||||
Spec::Story provides a framework for expressing User Stories
|
||||
|
||||
Spec::Example provides a framework for expressing code Examples
|
||||
|
||||
Spec::Matchers provides Expression Matchers for use with Spec::Expectations
|
||||
and Spec::Mocks.
|
||||
|
||||
Spec::Expectations supports setting expectations on your objects so you
|
||||
can do things like:
|
||||
|
||||
result.should equal(expected_result)
|
||||
|
||||
Spec::Mocks supports creating Mock Objects, Stubs, and adding Mock/Stub
|
||||
behaviour to your existing objects.
|
||||
|
||||
== Installation
|
||||
|
||||
The simplest approach is to install the gem:
|
||||
|
||||
gem install -r rspec #mac users must sudo
|
||||
|
||||
== Building the RSpec gem
|
||||
If you prefer to build the gem locally, check out source from svn://rubyforge.org/var/svn/rspec/trunk. Then
|
||||
do the following:
|
||||
|
||||
rake gem
|
||||
gem install pkg/rspec-0.x.x.gem (you may have to sudo)
|
||||
|
||||
== Running RSpec's specs
|
||||
In order to run RSpec's full suite of specs (rake pre_commit) you must install the following gems:
|
||||
|
||||
* rake # Runs the build script
|
||||
* rcov # Verifies that the code is 100% covered by specs
|
||||
* webby # Generates the static HTML website
|
||||
* syntax # Required to highlight ruby code
|
||||
* diff-lcs # Required if you use the --diff switch
|
||||
* win32console # Required by the --colour switch if you're on Windows
|
||||
* meta_project # Required in order to make releases at RubyForge
|
||||
* heckle # Required if you use the --heckle switch
|
||||
* hpricot # Used for parsing HTML from the HTML output formatter in RSpec's own specs
|
||||
|
||||
Once those are all installed, you should be able to run the suite with the following steps:
|
||||
|
||||
* svn co svn://rubyforge.org/var/svn/rspec/trunk rspec
|
||||
* cd rspec
|
||||
* rake install_dependencies
|
||||
* cd example_rails_app
|
||||
* export RSPEC_RAILS_VERSION=1.2.3
|
||||
* rake rspec:generate_mysql_config
|
||||
* mysql -u root < db/mysql_setup.sql
|
||||
* cd ..
|
||||
* rake pre_commit
|
||||
|
||||
Note that RSpec itself - once built - doesn't have any dependencies outside the Ruby core
|
||||
and stdlib - with a few exceptions:
|
||||
|
||||
* The spec command line uses diff-lcs when --diff is specified.
|
||||
* The spec command line uses heckle when --heckle is specified.
|
||||
* The Spec::Rake::SpecTask needs RCov if RCov is enabled in the task.
|
||||
|
||||
See http://rspec.rubyforge.org for further documentation.
|
||||
|
||||
== Contributing
|
||||
|
276
vendor/gems/rspec-1.1.2/Rakefile
vendored
276
vendor/gems/rspec-1.1.2/Rakefile
vendored
|
@ -1,276 +0,0 @@
|
|||
$:.unshift('lib')
|
||||
require 'rubygems'
|
||||
require 'rake/gempackagetask'
|
||||
require 'rake/contrib/rubyforgepublisher'
|
||||
require 'rake/clean'
|
||||
require 'rake/rdoctask'
|
||||
require 'rake/testtask'
|
||||
require 'spec/version'
|
||||
dir = File.dirname(__FILE__)
|
||||
$LOAD_PATH.unshift(File.expand_path("#{dir}/../pre_commit/lib"))
|
||||
require "pre_commit"
|
||||
|
||||
# Some of the tasks are in separate files since they are also part of the website documentation
|
||||
load File.dirname(__FILE__) + '/rake_tasks/examples.rake'
|
||||
load File.dirname(__FILE__) + '/rake_tasks/examples_with_rcov.rake'
|
||||
load File.dirname(__FILE__) + '/rake_tasks/failing_examples_with_html.rake'
|
||||
load File.dirname(__FILE__) + '/rake_tasks/verify_rcov.rake'
|
||||
|
||||
PKG_NAME = "rspec"
|
||||
PKG_VERSION = Spec::VERSION::STRING
|
||||
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
||||
PKG_FILES = FileList[
|
||||
'[A-Z]*',
|
||||
'lib/**/*.rb',
|
||||
'spec/**/*.rb',
|
||||
'examples/**/*',
|
||||
'plugins/**/*',
|
||||
'stories/**/*'
|
||||
]
|
||||
|
||||
task :default => [:verify_rcov]
|
||||
task :verify_rcov => [:spec, :stories]
|
||||
|
||||
desc "Run all specs"
|
||||
Spec::Rake::SpecTask.new do |t|
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
t.spec_opts = ['--options', 'spec.opts']
|
||||
unless ENV['NO_RCOV']
|
||||
t.rcov = true
|
||||
t.rcov_dir = '../doc/output/coverage'
|
||||
t.rcov_opts = ['--exclude', 'spec\/spec,bin\/spec,examples,\/var\/lib\/gems,\/Library\/Ruby,\.autotest']
|
||||
end
|
||||
end
|
||||
|
||||
desc "Run all stories"
|
||||
task :stories do
|
||||
html = 'story_server/prototype/rspec_stories.html'
|
||||
ruby "stories/all.rb --colour --format plain --format html:#{html}"
|
||||
unless IO.read(html) =~ /<span class="param">/m
|
||||
raise 'highlighted parameters are broken in story HTML'
|
||||
end
|
||||
end
|
||||
|
||||
desc "Run all specs and store html output in doc/output/report.html"
|
||||
Spec::Rake::SpecTask.new('spec_html') do |t|
|
||||
t.spec_files = FileList['spec/**/*_spec.rb', '../../RSpec.tmbundle/Support/spec/*_spec.rb']
|
||||
t.spec_opts = ['--format html:../doc/output/report.html','--backtrace']
|
||||
end
|
||||
|
||||
desc "Run all failing examples"
|
||||
Spec::Rake::SpecTask.new('failing_examples') do |t|
|
||||
t.spec_files = FileList['failing_examples/**/*_spec.rb']
|
||||
end
|
||||
|
||||
desc 'Generate RDoc'
|
||||
rd = Rake::RDocTask.new do |rdoc|
|
||||
rdoc.rdoc_dir = '../doc/output/rdoc'
|
||||
rdoc.options << '--title' << 'RSpec' << '--line-numbers' << '--inline-source' << '--main' << 'README'
|
||||
rdoc.rdoc_files.include('README', 'CHANGES', 'MIT-LICENSE', 'UPGRADE', 'lib/**/*.rb')
|
||||
end
|
||||
|
||||
spec = Gem::Specification.new do |s|
|
||||
s.name = PKG_NAME
|
||||
s.version = PKG_VERSION
|
||||
s.summary = Spec::VERSION::DESCRIPTION
|
||||
s.description = <<-EOF
|
||||
RSpec is a behaviour driven development (BDD) framework for Ruby. RSpec was
|
||||
created in response to Dave Astels' article _A New Look at Test Driven Development_
|
||||
which can be read at: http://daveastels.com/index.php?p=5 RSpec is intended to
|
||||
provide the features discussed in Dave's article.
|
||||
EOF
|
||||
|
||||
s.files = PKG_FILES.to_a
|
||||
s.require_path = 'lib'
|
||||
|
||||
s.has_rdoc = true
|
||||
s.rdoc_options = rd.options
|
||||
s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$|^EXAMPLES.rd$/ }.to_a
|
||||
|
||||
s.bindir = 'bin'
|
||||
s.executables = ['spec', 'spec_translator']
|
||||
s.default_executable = 'spec'
|
||||
s.author = "RSpec Development Team"
|
||||
s.email = "rspec-devel@rubyforge.org"
|
||||
s.homepage = "http://rspec.rubyforge.org"
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.rubyforge_project = "rspec"
|
||||
end
|
||||
|
||||
Rake::GemPackageTask.new(spec) do |pkg|
|
||||
pkg.need_zip = true
|
||||
pkg.need_tar = true
|
||||
end
|
||||
|
||||
def egrep(pattern)
|
||||
Dir['**/*.rb'].each do |fn|
|
||||
count = 0
|
||||
open(fn) do |f|
|
||||
while line = f.gets
|
||||
count += 1
|
||||
if line =~ pattern
|
||||
puts "#{fn}:#{count}:#{line}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Look for TODO and FIXME tags in the code"
|
||||
task :todo do
|
||||
egrep /(FIXME|TODO|TBD)/
|
||||
end
|
||||
|
||||
task :clobber do
|
||||
core.clobber
|
||||
end
|
||||
|
||||
task :release => [:clobber, :verify_committed, :verify_user, :spec, :publish_packages, :tag, :publish_news]
|
||||
|
||||
desc "Verifies that there is no uncommitted code"
|
||||
task :verify_committed do
|
||||
IO.popen('svn stat') do |io|
|
||||
io.each_line do |line|
|
||||
raise "\n!!! Do a svn commit first !!!\n\n" if line =~ /^\s*M\s*/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Creates a tag in svn"
|
||||
task :tag do
|
||||
from = `svn info #{File.dirname(__FILE__)}`.match(/URL: (.*)\/rspec/n)[1]
|
||||
to = from.gsub(/trunk/, "tags/#{Spec::VERSION::TAG}")
|
||||
current = from.gsub(/trunk/, "tags/CURRENT")
|
||||
|
||||
puts "Creating tag in SVN"
|
||||
tag_cmd = "svn cp #{from} #{to} -m \"Tag release #{Spec::VERSION::FULL_VERSION}\""
|
||||
`#{tag_cmd}` ; raise "ERROR: #{tag_cmd}" unless $? == 0
|
||||
|
||||
puts "Removing CURRENT"
|
||||
remove_current_cmd = "svn rm #{current} -m \"Remove tags/CURRENT\""
|
||||
`#{remove_current_cmd}` ; raise "ERROR: #{remove_current_cmd}" unless $? == 0
|
||||
|
||||
puts "Re-Creating CURRENT"
|
||||
create_current_cmd = "svn cp #{to} #{current} -m \"Copy #{Spec::VERSION::TAG} to tags/CURRENT\""
|
||||
`#{create_current_cmd}` ; "ERROR: #{create_current_cmd}" unless $? == 0
|
||||
end
|
||||
|
||||
desc "Run this task before you commit. You should see 'OK TO COMMIT'"
|
||||
task(:pre_commit) {core.pre_commit}
|
||||
|
||||
desc "Build the website, but do not publish it"
|
||||
task(:website) {core.website}
|
||||
|
||||
task(:rdoc_rails) {core.rdoc_rails}
|
||||
|
||||
task :verify_user do
|
||||
raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
|
||||
end
|
||||
|
||||
desc "Upload Website to RubyForge"
|
||||
task :publish_website => [:verify_user, :website] do
|
||||
unless Spec::VERSION::RELEASE_CANDIDATE
|
||||
publisher = Rake::SshDirPublisher.new(
|
||||
"rspec-website@rubyforge.org",
|
||||
"/var/www/gforge-projects/#{PKG_NAME}",
|
||||
"../doc/output"
|
||||
)
|
||||
publisher.upload
|
||||
else
|
||||
puts "** Not publishing packages to RubyForge - this is a prerelease"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Upload Website archive to RubyForge"
|
||||
task :archive_website => [:verify_user, :website] do
|
||||
publisher = Rake::SshDirPublisher.new(
|
||||
"rspec-website@rubyforge.org",
|
||||
"/var/www/gforge-projects/#{PKG_NAME}/#{Spec::VERSION::TAG}",
|
||||
"../doc/output"
|
||||
)
|
||||
publisher.upload
|
||||
end
|
||||
|
||||
desc "Package the Rails plugin"
|
||||
task :package_rspec_on_rails do
|
||||
mkdir 'pkg' rescue nil
|
||||
rm_rf 'pkg/rspec_on_rails' rescue nil
|
||||
`svn export ../rspec_on_rails pkg/rspec_on_rails-#{PKG_VERSION}`
|
||||
Dir.chdir 'pkg' do
|
||||
`tar cvzf rspec_on_rails-#{PKG_VERSION}.tgz rspec_on_rails-#{PKG_VERSION}`
|
||||
end
|
||||
end
|
||||
task :pkg => :package_rspec_on_rails
|
||||
|
||||
desc "Package the RSpec.tmbundle"
|
||||
task :package_tmbundle do
|
||||
mkdir 'pkg' rescue nil
|
||||
rm_rf 'pkg/RSpec.tmbundle' rescue nil
|
||||
`svn export ../RSpec.tmbundle pkg/RSpec.tmbundle`
|
||||
Dir.chdir 'pkg' do
|
||||
`tar cvzf RSpec-#{PKG_VERSION}.tmbundle.tgz RSpec.tmbundle`
|
||||
end
|
||||
end
|
||||
task :pkg => :package_tmbundle
|
||||
|
||||
desc "Publish gem+tgz+zip on RubyForge. You must make sure lib/version.rb is aligned with the CHANGELOG file"
|
||||
task :publish_packages => [:verify_user, :package] do
|
||||
release_files = FileList[
|
||||
"pkg/#{PKG_FILE_NAME}.gem",
|
||||
"pkg/#{PKG_FILE_NAME}.tgz",
|
||||
"pkg/rspec_on_rails-#{PKG_VERSION}.tgz",
|
||||
"pkg/#{PKG_FILE_NAME}.zip",
|
||||
"pkg/RSpec-#{PKG_VERSION}.tmbundle.tgz"
|
||||
]
|
||||
unless Spec::VERSION::RELEASE_CANDIDATE
|
||||
require 'meta_project'
|
||||
require 'rake/contrib/xforge'
|
||||
|
||||
Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |xf|
|
||||
# Never hardcode user name and password in the Rakefile!
|
||||
xf.user_name = ENV['RUBYFORGE_USER']
|
||||
xf.files = release_files.to_a
|
||||
xf.release_name = "RSpec #{PKG_VERSION}"
|
||||
end
|
||||
else
|
||||
puts "SINCE THIS IS A PRERELEASE, FILES ARE UPLOADED WITH SSH, NOT TO THE RUBYFORGE FILE SECTION"
|
||||
puts "YOU MUST TYPE THE PASSWORD #{release_files.length} TIMES..."
|
||||
|
||||
host = "rspec-website@rubyforge.org"
|
||||
remote_dir = "/var/www/gforge-projects/#{PKG_NAME}"
|
||||
|
||||
publisher = Rake::SshFilePublisher.new(
|
||||
host,
|
||||
remote_dir,
|
||||
File.dirname(__FILE__),
|
||||
*release_files
|
||||
)
|
||||
publisher.upload
|
||||
|
||||
puts "UPLADED THE FOLLOWING FILES:"
|
||||
release_files.each do |file|
|
||||
name = file.match(/pkg\/(.*)/)[1]
|
||||
puts "* http://rspec.rubyforge.org/#{name}"
|
||||
end
|
||||
|
||||
puts "They are not linked to anywhere, so don't forget to tell people!"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Publish news on RubyForge"
|
||||
task :publish_news => [:verify_user] do
|
||||
unless Spec::VERSION::RELEASE_CANDIDATE
|
||||
require 'meta_project'
|
||||
require 'rake/contrib/xforge'
|
||||
Rake::XForge::NewsPublisher.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |news|
|
||||
# Never hardcode user name and password in the Rakefile!
|
||||
news.user_name = ENV['RUBYFORGE_USER']
|
||||
end
|
||||
else
|
||||
puts "** Not publishing news to RubyForge - this is a prerelease"
|
||||
end
|
||||
end
|
||||
|
||||
def core
|
||||
PreCommit::Core.new(self)
|
||||
end
|
2
vendor/gems/rspec-1.1.2/TODO
vendored
2
vendor/gems/rspec-1.1.2/TODO
vendored
|
@ -1,2 +0,0 @@
|
|||
=== Before releasing 1.1.0:
|
||||
|
31
vendor/gems/rspec-1.1.2/UPGRADE
vendored
31
vendor/gems/rspec-1.1.2/UPGRADE
vendored
|
@ -1,31 +0,0 @@
|
|||
= Upgrading existing code to RSpec-0.9
|
||||
|
||||
== General (see below for Spec::Rails specifics)
|
||||
|
||||
=== New Syntax for should and should_not
|
||||
|
||||
* Use translator (should get 90% of your code)
|
||||
* Manually fix "parenthesis" warnings
|
||||
|
||||
=== Change before_context_eval to before_eval
|
||||
|
||||
before_context_eval is an un-published hook used by
|
||||
Spec::Rails to create specialized behaviour contexts.
|
||||
Most of you don't need to change this, but for those
|
||||
who have exploited it, you'll need to change it to
|
||||
before_eval.
|
||||
|
||||
== Spec::Rails
|
||||
|
||||
=== spec_helper.rb
|
||||
|
||||
We've added a new way to configure Spec::Runner to do
|
||||
things like use_transactional_fixtures and use_instantiated_fixtures.
|
||||
You'll need to update spec/spec_helper.rb accordingly. You can either
|
||||
just re-generate it:
|
||||
|
||||
script/generate rspec
|
||||
|
||||
Or modify spec_helper.rb based on the template, which can be found at:
|
||||
|
||||
vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
|
4
vendor/gems/rspec-1.1.2/bin/spec
vendored
4
vendor/gems/rspec-1.1.2/bin/spec
vendored
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
||||
require 'spec'
|
||||
exit ::Spec::Runner::CommandLine.run(rspec_options)
|
8
vendor/gems/rspec-1.1.2/bin/spec_translator
vendored
8
vendor/gems/rspec-1.1.2/bin/spec_translator
vendored
|
@ -1,8 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
raise "\n\nUsage: spec_translator from_dir to_dir\n\n" if ARGV.size != 2
|
||||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
||||
require 'spec/translator'
|
||||
t = ::Spec::Translator.new
|
||||
from = ARGV[0]
|
||||
to = ARGV[1]
|
||||
t.translate(from, to)
|
|
@ -1,19 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
# Run spec w/ -fs to see the output of this file
|
||||
|
||||
describe "Examples with no descriptions" do
|
||||
|
||||
# description is auto-generated as "should equal(5)" based on the last #should
|
||||
it do
|
||||
3.should equal(3)
|
||||
5.should equal(5)
|
||||
end
|
||||
|
||||
it { 3.should be < 5 }
|
||||
|
||||
it { ["a"].should include("a") }
|
||||
|
||||
it { [1,2,3].should respond_to(:size) }
|
||||
|
||||
end
|
|
@ -1,40 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
$global = 0
|
||||
|
||||
describe "State created in before(:all)" do
|
||||
before :all do
|
||||
@sideeffect = 1
|
||||
$global +=1
|
||||
end
|
||||
|
||||
before :each do
|
||||
@isolated = 1
|
||||
end
|
||||
|
||||
it "should be accessible from example" do
|
||||
@sideeffect.should == 1
|
||||
$global.should == 1
|
||||
@isolated.should == 1
|
||||
|
||||
@sideeffect += 1
|
||||
@isolated += 1
|
||||
end
|
||||
|
||||
it "should not have sideffects" do
|
||||
@sideeffect.should == 1
|
||||
$global.should == 2
|
||||
@isolated.should == 1
|
||||
|
||||
@sideeffect += 1
|
||||
@isolated += 1
|
||||
end
|
||||
|
||||
after :each do
|
||||
$global += 1
|
||||
end
|
||||
|
||||
after :all do
|
||||
$global.should == 3
|
||||
$global = 0
|
||||
end
|
||||
end
|
|
@ -1,45 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
def behave_as_electric_musician
|
||||
respond_to(:read_notes, :turn_down_amp)
|
||||
end
|
||||
|
||||
def behave_as_musician
|
||||
respond_to(:read_notes)
|
||||
end
|
||||
|
||||
module BehaveAsExample
|
||||
|
||||
class BluesGuitarist
|
||||
def read_notes; end
|
||||
def turn_down_amp; end
|
||||
end
|
||||
|
||||
class RockGuitarist
|
||||
def read_notes; end
|
||||
def turn_down_amp; end
|
||||
end
|
||||
|
||||
class ClassicGuitarist
|
||||
def read_notes; end
|
||||
end
|
||||
|
||||
describe BluesGuitarist do
|
||||
it "should behave as guitarist" do
|
||||
BluesGuitarist.new.should behave_as_electric_musician
|
||||
end
|
||||
end
|
||||
|
||||
describe RockGuitarist do
|
||||
it "should behave as guitarist" do
|
||||
RockGuitarist.new.should behave_as_electric_musician
|
||||
end
|
||||
end
|
||||
|
||||
describe ClassicGuitarist do
|
||||
it "should not behave as guitarist" do
|
||||
ClassicGuitarist.new.should behave_as_musician
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,54 +0,0 @@
|
|||
module AnimalSpecHelper
|
||||
class Eat
|
||||
def initialize(food)
|
||||
@food = food
|
||||
end
|
||||
|
||||
def matches?(animal)
|
||||
@animal = animal
|
||||
@animal.eats?(@food)
|
||||
end
|
||||
|
||||
def failure_message
|
||||
"expected #{@animal} to eat #{@food}, but it does not"
|
||||
end
|
||||
|
||||
def negative_failure_message
|
||||
"expected #{@animal} not to eat #{@food}, but it does"
|
||||
end
|
||||
end
|
||||
|
||||
def eat(food)
|
||||
Eat.new(food)
|
||||
end
|
||||
end
|
||||
|
||||
module Animals
|
||||
class Animal
|
||||
def eats?(food)
|
||||
return foods_i_eat.include?(food)
|
||||
end
|
||||
end
|
||||
|
||||
class Mouse < Animal
|
||||
def foods_i_eat
|
||||
[:cheese]
|
||||
end
|
||||
end
|
||||
|
||||
describe Mouse do
|
||||
include AnimalSpecHelper
|
||||
before(:each) do
|
||||
@mouse = Animals::Mouse.new
|
||||
end
|
||||
|
||||
it "should eat cheese" do
|
||||
@mouse.should eat(:cheese)
|
||||
end
|
||||
|
||||
it "should not eat cat" do
|
||||
@mouse.should_not eat(:cat)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
require 'spec/runner/formatter/progress_bar_formatter'
|
||||
|
||||
# Example of a formatter with custom bactrace printing. Run me with:
|
||||
# ruby bin/spec failing_examples -r examples/custom_formatter.rb -f CustomFormatter
|
||||
class CustomFormatter < Spec::Runner::Formatter::ProgressBarFormatter
|
||||
def backtrace_line(line)
|
||||
line.gsub(/([^:]*\.rb):(\d*)/) do
|
||||
"<a href=\"file://#{File.expand_path($1)}\">#{$1}:#{$2}</a> "
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
describe "Some integers" do
|
||||
(1..10).each do |n|
|
||||
it "The root of #{n} square should be #{n}" do
|
||||
Math.sqrt(n*n).should == n
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,19 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
class FileAccessor
|
||||
def open_and_handle_with(pathname, processor)
|
||||
pathname.open do |io|
|
||||
processor.process(io)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
require File.dirname(__FILE__) + '/io_processor'
|
||||
require 'pathname'
|
||||
|
||||
accessor = FileAccessor.new
|
||||
io_processor = IoProcessor.new
|
||||
file = Pathname.new ARGV[0]
|
||||
|
||||
accessor.open_and_handle_with(file, io_processor)
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
require File.dirname(__FILE__) + '/file_accessor'
|
||||
require 'stringio'
|
||||
|
||||
describe "A FileAccessor" do
|
||||
# This sequence diagram illustrates what this spec specifies.
|
||||
#
|
||||
# +--------------+ +----------+ +-------------+
|
||||
# | FileAccessor | | Pathname | | IoProcessor |
|
||||
# +--------------+ +----------+ +-------------+
|
||||
# | | |
|
||||
# open_and_handle_with | | |
|
||||
# -------------------->| | open | |
|
||||
# | |--------------->| | |
|
||||
# | | io | | |
|
||||
# | |<...............| | |
|
||||
# | | | process(io) |
|
||||
# | |---------------------------------->| |
|
||||
# | | | | |
|
||||
# | |<..................................| |
|
||||
# | | |
|
||||
#
|
||||
it "should open a file and pass it to the processor's process method" do
|
||||
# This is the primary actor
|
||||
accessor = FileAccessor.new
|
||||
|
||||
# These are the primary actor's neighbours, which we mock.
|
||||
file = mock "Pathname"
|
||||
io_processor = mock "IoProcessor"
|
||||
|
||||
io = StringIO.new "whatever"
|
||||
file.should_receive(:open).and_yield io
|
||||
io_processor.should_receive(:process).with(io)
|
||||
|
||||
accessor.open_and_handle_with(file, io_processor)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
# greeter.rb
|
||||
#
|
||||
# Based on http://glu.ttono.us/articles/2006/12/19/tormenting-your-tests-with-heckle
|
||||
#
|
||||
# Run with:
|
||||
#
|
||||
# spec greeter_spec.rb --heckle Greeter
|
||||
#
|
||||
class Greeter
|
||||
def initialize(person = nil)
|
||||
@person = person
|
||||
end
|
||||
|
||||
def greet
|
||||
@person.nil? ? "Hi there!" : "Hi #{@person}!"
|
||||
end
|
||||
end
|
||||
|
||||
describe "Greeter" do
|
||||
it "should say Hi to person" do
|
||||
greeter = Greeter.new("Kevin")
|
||||
greeter.greet.should == "Hi Kevin!"
|
||||
end
|
||||
|
||||
it "should say Hi to nobody" do
|
||||
greeter = Greeter.new
|
||||
# Uncomment the next line to make Heckle happy
|
||||
#greeter.greet.should == "Hi there!"
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
module HelperMethodExample
|
||||
describe "an example group with helper a method" do
|
||||
def helper_method
|
||||
"received call"
|
||||
end
|
||||
|
||||
it "should make that method available to specs" do
|
||||
helper_method.should == "received call"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
class DataTooShort < StandardError; end
|
||||
|
||||
class IoProcessor
|
||||
# Does some fancy stuff unless the length of +io+ is shorter than 32
|
||||
def process(io)
|
||||
raise DataTooShort if io.read.length < 32
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
require File.dirname(__FILE__) + '/io_processor'
|
||||
require 'stringio'
|
||||
|
||||
describe "An IoProcessor" do
|
||||
before(:each) do
|
||||
@processor = IoProcessor.new
|
||||
end
|
||||
|
||||
it "should raise nothing when the file is exactly 32 bytes" do
|
||||
lambda {
|
||||
@processor.process(StringIO.new("z"*32))
|
||||
}.should_not raise_error
|
||||
end
|
||||
|
||||
it "should raise an exception when the file length is less than 32 bytes" do
|
||||
lambda {
|
||||
@processor.process(StringIO.new("z"*31))
|
||||
}.should raise_error(DataTooShort)
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
context "A legacy spec" do
|
||||
setup do
|
||||
end
|
||||
|
||||
specify "should work fine" do
|
||||
end
|
||||
|
||||
teardown do
|
||||
end
|
||||
end
|
|
@ -1,27 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
describe "A consumer of a mock" do
|
||||
it "should be able to send messages to the mock" do
|
||||
mock = mock("poke me")
|
||||
mock.should_receive(:poke)
|
||||
mock.poke
|
||||
end
|
||||
end
|
||||
|
||||
describe "a mock" do
|
||||
it "should be able to mock the same message twice w/ different args" do
|
||||
mock = mock("mock")
|
||||
mock.should_receive(:msg).with(:arg1).and_return(:val1)
|
||||
mock.should_receive(:msg).with(:arg2).and_return(:val2)
|
||||
mock.msg(:arg1).should eql(:val1)
|
||||
mock.msg(:arg2).should eql(:val2)
|
||||
end
|
||||
|
||||
it "should be able to mock the same message twice w/ different args in reverse order" do
|
||||
mock = mock("mock")
|
||||
mock.should_receive(:msg).with(:arg1).and_return(:val1)
|
||||
mock.should_receive(:msg).with(:arg2).and_return(:val2)
|
||||
mock.msg(:arg2).should eql(:val2)
|
||||
mock.msg(:arg1).should eql(:val1)
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
class MultiThreadedExampleGroupRunner < Spec::Runner::ExampleGroupRunner
|
||||
def initialize(options, arg)
|
||||
super(options)
|
||||
# configure these
|
||||
@thread_count = 4
|
||||
@thread_wait = 0
|
||||
end
|
||||
|
||||
def run
|
||||
@threads = []
|
||||
q = Queue.new
|
||||
example_groups.each { |b| q << b}
|
||||
success = true
|
||||
@thread_count.times do
|
||||
@threads << Thread.new(q) do |queue|
|
||||
while not queue.empty?
|
||||
example_group = queue.pop
|
||||
success &= example_group.suite.run(nil)
|
||||
end
|
||||
end
|
||||
sleep @thread_wait
|
||||
end
|
||||
@threads.each {|t| t.join}
|
||||
success
|
||||
end
|
||||
end
|
||||
|
||||
MultiThreadedBehaviourRunner = MultiThreadedExampleGroupRunner
|
|
@ -1,36 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
require File.dirname(__FILE__) + '/stack'
|
||||
|
||||
class StackExamples < Spec::ExampleGroup
|
||||
describe(Stack)
|
||||
before(:each) do
|
||||
@stack = Stack.new
|
||||
end
|
||||
end
|
||||
|
||||
class EmptyStackExamples < StackExamples
|
||||
describe("when empty")
|
||||
it "should be empty" do
|
||||
@stack.should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
class AlmostFullStackExamples < StackExamples
|
||||
describe("when almost full")
|
||||
before(:each) do
|
||||
(1..9).each {|n| @stack.push n}
|
||||
end
|
||||
it "should be full" do
|
||||
@stack.should_not be_full
|
||||
end
|
||||
end
|
||||
|
||||
class FullStackExamples < StackExamples
|
||||
describe("when full")
|
||||
before(:each) do
|
||||
(1..10).each {|n| @stack.push n}
|
||||
end
|
||||
it "should be full" do
|
||||
@stack.should be_full
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
class MockableClass
|
||||
def self.find id
|
||||
return :original_return
|
||||
end
|
||||
end
|
||||
|
||||
describe "A partial mock" do
|
||||
|
||||
it "should work at the class level" do
|
||||
MockableClass.should_receive(:find).with(1).and_return {:stub_return}
|
||||
MockableClass.find(1).should equal(:stub_return)
|
||||
end
|
||||
|
||||
it "should revert to the original after each spec" do
|
||||
MockableClass.find(1).should equal(:original_return)
|
||||
end
|
||||
|
||||
it "can be mocked w/ ordering" do
|
||||
MockableClass.should_receive(:msg_1).ordered
|
||||
MockableClass.should_receive(:msg_2).ordered
|
||||
MockableClass.should_receive(:msg_3).ordered
|
||||
MockableClass.msg_1
|
||||
MockableClass.msg_2
|
||||
MockableClass.msg_3
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
describe "pending example (using pending method)" do
|
||||
it %Q|should be reported as "PENDING: for some reason"| do
|
||||
pending("for some reason")
|
||||
end
|
||||
end
|
||||
|
||||
describe "pending example (with no block)" do
|
||||
it %Q|should be reported as "PENDING: Not Yet Implemented"|
|
||||
end
|
||||
|
||||
describe "pending example (with block for pending)" do
|
||||
it %Q|should have a failing block, passed to pending, reported as "PENDING: for some reason"| do
|
||||
pending("for some reason") do
|
||||
raise "some reason"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
class BddFramework
|
||||
def intuitive?
|
||||
true
|
||||
end
|
||||
|
||||
def adopted_quickly?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
describe "BDD framework" do
|
||||
|
||||
before(:each) do
|
||||
@bdd_framework = BddFramework.new
|
||||
end
|
||||
|
||||
it "should be adopted quickly" do
|
||||
@bdd_framework.should be_adopted_quickly
|
||||
end
|
||||
|
||||
it "should be intuitive" do
|
||||
@bdd_framework.should be_intuitive
|
||||
end
|
||||
|
||||
end
|
|
@ -1 +0,0 @@
|
|||
examples/custom_expectation_matchers.rb
|
|
@ -1,81 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
module SharedExampleGroupExample
|
||||
class OneThing
|
||||
def what_things_do
|
||||
"stuff"
|
||||
end
|
||||
end
|
||||
|
||||
class AnotherThing
|
||||
def what_things_do
|
||||
"stuff"
|
||||
end
|
||||
end
|
||||
|
||||
class YetAnotherThing
|
||||
def what_things_do
|
||||
"stuff"
|
||||
end
|
||||
end
|
||||
|
||||
# A SharedExampleGroup is an example group that doesn't get run.
|
||||
# You can create one like this:
|
||||
share_examples_for "most things" do
|
||||
def helper_method
|
||||
"helper method"
|
||||
end
|
||||
|
||||
it "should do what things do" do
|
||||
@thing.what_things_do.should == "stuff"
|
||||
end
|
||||
end
|
||||
|
||||
# A SharedExampleGroup is also module. If you create one like this
|
||||
# it gets assigned to the constant AllThings
|
||||
share_as :MostThings do
|
||||
def helper_method
|
||||
"helper method"
|
||||
end
|
||||
|
||||
it "should do what things do" do
|
||||
@thing.what_things_do.should == "stuff"
|
||||
end
|
||||
end
|
||||
|
||||
describe OneThing do
|
||||
# Now you can include the shared example group like this, which
|
||||
# feels more like what you might say ...
|
||||
it_should_behave_like "most things"
|
||||
|
||||
before(:each) { @thing = OneThing.new }
|
||||
|
||||
it "should have access to helper methods defined in the shared example group" do
|
||||
helper_method.should == "helper method"
|
||||
end
|
||||
end
|
||||
|
||||
describe AnotherThing do
|
||||
# ... or you can include the example group like this, which
|
||||
# feels more like the programming language we love.
|
||||
it_should_behave_like MostThings
|
||||
|
||||
before(:each) { @thing = AnotherThing.new }
|
||||
|
||||
it "should have access to helper methods defined in the shared example group" do
|
||||
helper_method.should == "helper method"
|
||||
end
|
||||
end
|
||||
|
||||
describe YetAnotherThing do
|
||||
# ... or you can include the example group like this, which
|
||||
# feels more like the programming language we love.
|
||||
include MostThings
|
||||
|
||||
before(:each) { @thing = AnotherThing.new }
|
||||
|
||||
it "should have access to helper methods defined in the shared example group" do
|
||||
helper_method.should == "helper method"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
require File.join(File.dirname(__FILE__), *%w[spec_helper])
|
||||
|
||||
shared_examples_for "non-empty Stack" do
|
||||
|
||||
it { @stack.should_not be_empty }
|
||||
|
||||
it "should return the top item when sent #peek" do
|
||||
@stack.peek.should == @last_item_added
|
||||
end
|
||||
|
||||
it "should NOT remove the top item when sent #peek" do
|
||||
@stack.peek.should == @last_item_added
|
||||
@stack.peek.should == @last_item_added
|
||||
end
|
||||
|
||||
it "should return the top item when sent #pop" do
|
||||
@stack.pop.should == @last_item_added
|
||||
end
|
||||
|
||||
it "should remove the top item when sent #pop" do
|
||||
@stack.pop.should == @last_item_added
|
||||
unless @stack.empty?
|
||||
@stack.pop.should_not == @last_item_added
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for "non-full Stack" do
|
||||
|
||||
it { @stack.should_not be_full }
|
||||
|
||||
it "should add to the top when sent #push" do
|
||||
@stack.push "newly added top item"
|
||||
@stack.peek.should == "newly added top item"
|
||||
end
|
||||
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
lib_path = File.expand_path("#{File.dirname(__FILE__)}/../../lib")
|
||||
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
||||
require 'spec'
|
36
vendor/gems/rspec-1.1.2/examples/pure/stack.rb
vendored
36
vendor/gems/rspec-1.1.2/examples/pure/stack.rb
vendored
|
@ -1,36 +0,0 @@
|
|||
class StackUnderflowError < RuntimeError
|
||||
end
|
||||
|
||||
class StackOverflowError < RuntimeError
|
||||
end
|
||||
|
||||
class Stack
|
||||
|
||||
def initialize
|
||||
@items = []
|
||||
end
|
||||
|
||||
def push object
|
||||
raise StackOverflowError if @items.length == 10
|
||||
@items.push object
|
||||
end
|
||||
|
||||
def pop
|
||||
raise StackUnderflowError if @items.empty?
|
||||
@items.delete @items.last
|
||||
end
|
||||
|
||||
def peek
|
||||
raise StackUnderflowError if @items.empty?
|
||||
@items.last
|
||||
end
|
||||
|
||||
def empty?
|
||||
@items.empty?
|
||||
end
|
||||
|
||||
def full?
|
||||
@items.length == 10
|
||||
end
|
||||
|
||||
end
|
|
@ -1,63 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
require File.dirname(__FILE__) + "/stack"
|
||||
require File.dirname(__FILE__) + '/shared_stack_examples'
|
||||
|
||||
describe Stack, " (empty)" do
|
||||
before(:each) do
|
||||
@stack = Stack.new
|
||||
end
|
||||
|
||||
# NOTE that this one auto-generates the description "should be empty"
|
||||
it { @stack.should be_empty }
|
||||
|
||||
it_should_behave_like "non-full Stack"
|
||||
|
||||
it "should complain when sent #peek" do
|
||||
lambda { @stack.peek }.should raise_error(StackUnderflowError)
|
||||
end
|
||||
|
||||
it "should complain when sent #pop" do
|
||||
lambda { @stack.pop }.should raise_error(StackUnderflowError)
|
||||
end
|
||||
end
|
||||
|
||||
describe Stack, " (with one item)" do
|
||||
before(:each) do
|
||||
@stack = Stack.new
|
||||
@stack.push 3
|
||||
@last_item_added = 3
|
||||
end
|
||||
|
||||
it_should_behave_like "non-empty Stack"
|
||||
it_should_behave_like "non-full Stack"
|
||||
|
||||
end
|
||||
|
||||
describe Stack, " (with one item less than capacity)" do
|
||||
before(:each) do
|
||||
@stack = Stack.new
|
||||
(1..9).each { |i| @stack.push i }
|
||||
@last_item_added = 9
|
||||
end
|
||||
|
||||
it_should_behave_like "non-empty Stack"
|
||||
it_should_behave_like "non-full Stack"
|
||||
end
|
||||
|
||||
describe Stack, " (full)" do
|
||||
before(:each) do
|
||||
@stack = Stack.new
|
||||
(1..10).each { |i| @stack.push i }
|
||||
@last_item_added = 10
|
||||
end
|
||||
|
||||
# NOTE that this one auto-generates the description "should be full"
|
||||
it { @stack.should be_full }
|
||||
|
||||
it_should_behave_like "non-empty Stack"
|
||||
|
||||
it "should complain on #push" do
|
||||
lambda { @stack.push Object.new }.should raise_error(StackOverflowError)
|
||||
end
|
||||
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue