diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb index 36a5ef2f8f028208cfb9dad3294e40577c9dd7d4..e8b0a0aa6eba514dd9880f960531e5d848e46a3b 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admins_controller.rb @@ -1,5 +1,3 @@ -require Rails.root.join('lib', 'statistics') - class AdminsController < ApplicationController before_filter :authenticate_user! before_filter :redirect_unless_admin diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index 984c6ff5e5607ae4315948ea861c452257bd5c9d..3754d1b22d1f9b363940e5189d8609a8d56cfa48 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -2,8 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join('lib', 'email_inviter') - class InvitationsController < ApplicationController before_filter :authenticate_user!, :only => [:new, :create] diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 7be46c16618de6cee5ce31472ac3a963114c6089..8ab65b6caec688940c5221aaa84c2dc08db76013 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -2,8 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join("app", "presenters", "post_presenter") - class LikesController < ApplicationController include ApplicationHelper before_filter :authenticate_user! diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 3115f1f1b7e97b2170cb7734d656dcf664566721..d11742ec34245a5b1f0b25140151d3b4b3db1e47 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -2,8 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join("lib", 'stream', "person") - class PeopleController < ApplicationController before_filter :authenticate_user!, :except => [:show, :last_post] before_filter :redirect_if_tag_search, :only => [:index] diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index e901da938ec18e454eb5f9140beb81fcd0e9a594..10c5793376fa8ac60f329207844d78b09ab8c8a8 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -2,8 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join("app", "presenters", "post_presenter") - class PostsController < ApplicationController include PostsHelper diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 31942988ef39956dc423a27dba108537871e66a5..646e684802e92d5a28f07f2706f754bfbe34fdcf 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -2,11 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join('lib', 'stream', 'public') class PublicsController < ApplicationController - require Rails.root.join('lib', 'diaspora', 'parser') - require Rails.root.join('lib', 'postzord', 'receiver', 'public') - require Rails.root.join('lib', 'postzord', 'receiver', 'private') include Diaspora::Parser skip_before_filter :set_header_data diff --git a/app/controllers/streams_controller.rb b/app/controllers/streams_controller.rb index de510d1ed78999edce4f33189dd2231face83621..7c4484f512cfb38ce5a9573c0de7d06f821ce3cd 100644 --- a/app/controllers/streams_controller.rb +++ b/app/controllers/streams_controller.rb @@ -2,15 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join("lib", "stream", "aspect") -require Rails.root.join("lib", "stream", "multi") -require Rails.root.join("lib", "stream", "comments") -require Rails.root.join("lib", "stream", "likes") -require Rails.root.join("lib", "stream", "mention") -require Rails.root.join("lib", "stream", "followed_tag") -require Rails.root.join("lib", "stream", "activity") - - class StreamsController < ApplicationController before_filter :authenticate_user! before_filter :save_selected_aspects, :only => :aspects diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 13766ac13cee7eba56e486941eb9eb9f09aa5602..9d86638faf374cc2166f8fa57a98902626829937 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,8 +1,6 @@ # Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join('app', 'models', 'acts_as_taggable_on', 'tag') -require Rails.root.join('lib', 'stream', 'tag') class TagsController < ApplicationController skip_before_filter :set_grammatical_gender diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f3fb55e4b388156cb5401c08fa220d0603c4694a..528baa33f0828722605f08826c1785c584612c2c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,9 +3,6 @@ # the COPYRIGHT file. class UsersController < ApplicationController - require Rails.root.join('lib', 'diaspora', 'exporter') - require Rails.root.join('lib', 'collect_user_photos') - before_filter :authenticate_user!, :except => [:new, :create, :public, :user_photo] respond_to :html diff --git a/app/helpers/markdownify_helper.rb b/app/helpers/markdownify_helper.rb index 926029077d3ce04c1779d59fbe805e8bce745da4..f9ff0f73c3381dd1da08a35430da6a799843140d 100644 --- a/app/helpers/markdownify_helper.rb +++ b/app/helpers/markdownify_helper.rb @@ -2,9 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join('lib', 'diaspora', 'markdownify') -require 'redcarpet/render_strip' - module MarkdownifyHelper def markdownify(target, render_options={}) diff --git a/app/models/jobs/http_multi.rb b/app/models/jobs/http_multi.rb index 8d686c2339e86a4c438bb4f9553652612462908f..1132fcbe460a0371eff48c212030ee08b505a1f0 100644 --- a/app/models/jobs/http_multi.rb +++ b/app/models/jobs/http_multi.rb @@ -17,7 +17,7 @@ module Jobs people = Person.where(:id => person_ids) dispatcher = dispatcher_class_as_string.constantize - hydra = HydraWrapper.new(user, people, encoded_object_xml, dispatcher) + hydra = ::HydraWrapper.new(user, people, encoded_object_xml, dispatcher) hydra.enqueue_batch hydra.run diff --git a/app/models/person.rb b/app/models/person.rb index 4fe1fd9fbb4b0c18428709b035495dfcd67f079a..0e1dbb40c77589f8b170ee578068992f45346892 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -2,9 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require 'uri' -require Rails.root.join('lib', 'hcard') - class Person < ActiveRecord::Base include ROXML include Encryptor::Public diff --git a/app/models/photo.rb b/app/models/photo.rb index 9741985a75c85eedd1a61215987fbf7047a5fb9c..fdcabedcc0a47394044207ca232cbdf700f554da 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -3,8 +3,6 @@ # the COPYRIGHT file. class Photo < ActiveRecord::Base - require 'carrierwave/orm/activerecord' - include Diaspora::Federated::Shareable include Diaspora::Commentable include Diaspora::Shareable diff --git a/app/models/service.rb b/app/models/service.rb index a4029a3707b6effb0e70b452ae736598f40c4f14..beb41fa96b449112196e96067b820dc939a62dae 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -4,7 +4,6 @@ class Service < ActiveRecord::Base include ActionView::Helpers::TextHelper - require Rails.root.join('app', 'helpers', 'markdownify_helper') include MarkdownifyHelper belongs_to :user @@ -39,5 +38,5 @@ class Service < ActiveRecord::Base end end -require Rails.root.join('app', 'models', 'services', 'facebook') -require Rails.root.join('app', 'models', 'services', 'twitter') +require 'services/facebook' +require 'services/twitter' diff --git a/app/models/services/facebook.rb b/app/models/services/facebook.rb index d5a6fb63324d7c82be6db86be1725ccb63ed6b00..93ba07ef5eb2504991b42c40253f8f6d8d99bdce 100644 --- a/app/models/services/facebook.rb +++ b/app/models/services/facebook.rb @@ -1,7 +1,5 @@ -require 'uri' class Services::Facebook < Service include Rails.application.routes.url_helpers - require Rails.root.join('app', 'helpers', 'markdownify_helper') include MarkdownifyHelper OVERRIDE_FIELDS_ON_FB_UPDATE = [:contact_id, :person_id, :request_id, :invitation_id, :photo_url, :name, :username] diff --git a/app/models/services/twitter.rb b/app/models/services/twitter.rb index 0fa79360deb37437b9a5367b399763058b557cf0..f874ecb48443c3edacd1c4ccab47302e1033d813 100644 --- a/app/models/services/twitter.rb +++ b/app/models/services/twitter.rb @@ -1,5 +1,3 @@ -require 'uri' - class Services::Twitter < Service MAX_CHARACTERS = 140 SHORTENED_URL_LENGTH = 21 diff --git a/app/models/status_message.rb b/app/models/status_message.rb index e6c46cd4de7394ea24028b5ef3b8087aff4012dc..03f00164377b10199413e980ecabad4d9480c04d 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -159,7 +159,6 @@ class StatusMessage < Post end def contains_oembed_url_in_text? - require 'uri' urls = URI.extract(self.raw_message, ['http', 'https']) self.oembed_url = urls.find{ |url| !TRUSTED_OEMBED_PROVIDERS.find(url).nil? } end diff --git a/app/models/user.rb b/app/models/user.rb index 4f356717b5606b8bfa01ecbc97b70f75c0f7ab9e..32656c0ed51269d915fb3a61f37be49aec048fb6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,9 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join('lib', 'salmon', 'salmon') -require Rails.root.join('lib', 'postzord', 'dispatcher') - class User < ActiveRecord::Base include Encryptor::Private include Connecting diff --git a/app/models/user/querying.rb b/app/models/user/querying.rb index 3816b434ab4a0495edcb1bc9781fab5907ce4b65..c849b13a7abfceb7340d5d001f3f07da40aa4dea 100644 --- a/app/models/user/querying.rb +++ b/app/models/user/querying.rb @@ -2,9 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join('lib', 'evil_query') - - #TODO: THIS FILE SHOULD NOT EXIST, EVIL SQL SHOULD BE ENCAPSULATED IN EvilQueries, #throwing all of this stuff in user violates demeter like WHOA module User::Querying diff --git a/app/presenters/o_embed_presenter.rb b/app/presenters/o_embed_presenter.rb index c8baf4752302454308555b645dccb44f970adf50..a3e875d30273ebed6b00e7b9d654e8a44676c89c 100644 --- a/app/presenters/o_embed_presenter.rb +++ b/app/presenters/o_embed_presenter.rb @@ -1,4 +1,3 @@ -require 'uri' class OEmbedPresenter include PostsHelper include ActionView::Helpers::TextHelper diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index a0558bc4efb3b7f66c96486a71b0171b4eab28d7..895ff9a4f8bd47af164f3e1dce4ea62c2bbd52b6 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -1,5 +1,3 @@ -require Rails.root.join('lib', 'template_picker') - class PostPresenter attr_accessor :post, :current_user diff --git a/config/application.rb b/config/application.rb index f8b35569c6e2201aefd7c4467d01b1ca57dd65a8..0a5e7c5103e7a1719ec958d1b36da37aa2f4a1b0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -32,8 +32,8 @@ module Diaspora # -- all .rb files in that directory are automatically loaded. # Add additional load paths for your own custom dirs - config.autoload_paths += %W(#{config.root}/app/presenters) - config.autoload_paths += %W(#{config.root}/lib) + config.autoload_paths += %W{#{config.root}/app/presenters} + config.autoload_once_paths += %W{#{config.root}/lib} # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named diff --git a/config/environment.rb b/config/environment.rb index 57ad7ff2e0b646c186c0d50164be4b1f9355d663..ad18fc67e5f90e6c579bc198d67074def473ca5b 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -13,7 +13,6 @@ end # Load the rails application require Pathname.new(__FILE__).dirname.expand_path.join('application') -require Rails.root.join("lib", "exceptions") # Load configuration system early require Rails.root.join('config', 'load_config') @@ -27,7 +26,6 @@ USERNAME_BLACKLIST = ['admin', 'administrator', 'hostmaster', 'info', 'postmaste # Initialize the rails application Diaspora::Application.initialize! -require Rails.root.join('lib', 'federation_logger') # allow token auth only for posting activitystream photos module Devise diff --git a/config/initializers/acts_as_taggable_on.rb b/config/initializers/acts_as_taggable_on.rb index 1160cfafdae895c8defca806d5eb1370295403f2..d42a381b1b7e4154e52dc45304aee8581f6777f3 100644 --- a/config/initializers/acts_as_taggable_on.rb +++ b/config/initializers/acts_as_taggable_on.rb @@ -1,3 +1,2 @@ - ActsAsTaggableOn.force_lowercase = true - +require Rails.root.join("app", "models", "acts_as_taggable_on", "tag") diff --git a/config/initializers/load_libraries.rb b/config/initializers/load_libraries.rb new file mode 100644 index 0000000000000000000000000000000000000000..4aaa7d6d540097fa89b264c17e4f2848afb51942 --- /dev/null +++ b/config/initializers/load_libraries.rb @@ -0,0 +1,36 @@ +# Stdlib +require 'cgi' +require 'uri' + +# Not auto required gems +require 'active_support/base64' +require 'builder/xchar' +require 'carrierwave/orm/activerecord' +require 'erb' +require 'redcarpet/render_strip' +require 'typhoeus' + +# Presenters +require 'post_presenter' + +# Helpers +require 'markdownify_helper' + +# Our libs +require 'collect_user_photos' +require 'diaspora' +require 'email_inviter' +require 'evil_query' +require 'federation_logger' +require 'h_card' +require 'hydra_wrapper' +require 'postzord' +require 'publisher' +require 'pubsubhubbub' +require 'salmon' +require 'statistics' +require 'stream' +require 'template_picker' +require 'webfinger' +require 'webfinger_profile' + diff --git a/features/step_definitions/debug_steps.rb b/features/step_definitions/debug_steps.rb index 58a36d533334561a920e78226a0fa983a924d404..bf255c63368bc2ce9f087f0639f159dab6954768 100644 --- a/features/step_definitions/debug_steps.rb +++ b/features/step_definitions/debug_steps.rb @@ -1,6 +1,6 @@ module DebuggingCukeHelpers def start_debugging - require 'ruby-debug' + require 'debug' debugger true end diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index 62fcebb623eff206caa9551edfc280d61d43837c..7be28c6cf2b743f021dbe56f8c5d31d658fca9e3 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -4,8 +4,6 @@ # instead of editing this one. Cucumber will automatically load all features/**/*.rb # files. -require 'uri' -require 'cgi' require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) module WithinHelpers diff --git a/lib/diaspora.rb b/lib/diaspora.rb index 18d8122474df8042e0cc0a0bd6d8b4b18e8cabb5..de8d1d003daffbaf9f6040069c0c9142cbf7c335 100644 --- a/lib/diaspora.rb +++ b/lib/diaspora.rb @@ -3,5 +3,9 @@ # the COPYRIGHT file. module Diaspora - autoload :Parser + require 'diaspora/exceptions' + require 'diaspora/parser' + require 'diaspora/fetcher' + require 'diaspora/markdownify' + require 'diaspora/exporter' end diff --git a/lib/exceptions.rb b/lib/diaspora/exceptions.rb similarity index 100% rename from lib/exceptions.rb rename to lib/diaspora/exceptions.rb diff --git a/lib/diaspora/federated/base.rb b/lib/diaspora/federated/base.rb index 32054cca6378a3da8aff778587ae858fcd5d1514..52ebcc85891dac750f663ee4fea87fed7008a476 100644 --- a/lib/diaspora/federated/base.rb +++ b/lib/diaspora/federated/base.rb @@ -9,8 +9,6 @@ #including this module lets you federate an object at the most basic of level -require 'builder/xchar' - module Diaspora module Federated module Base diff --git a/lib/diaspora/fetcher.rb b/lib/diaspora/fetcher.rb new file mode 100644 index 0000000000000000000000000000000000000000..adb82e55254d69e69abfba6bf960a17f58023de6 --- /dev/null +++ b/lib/diaspora/fetcher.rb @@ -0,0 +1,5 @@ +module Diaspora + module Fetcher + require 'diaspora/fetcher/public' + end +end diff --git a/lib/diaspora/fetcher/public.rb b/lib/diaspora/fetcher/public.rb index 501f3e5b73fc00ec3ac9345e7c5d8620095e6be9..409d3ffe894ec41d66cbd3f51eaac9204d7e0d11 100644 --- a/lib/diaspora/fetcher/public.rb +++ b/lib/diaspora/fetcher/public.rb @@ -1,8 +1,7 @@ # Copyright (c) 2010-2012, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. - -class PublicFetcher +module Diaspora; module Fetcher; class Public # various states that can be assigned to a person to describe where # in the process of fetching their public posts we're currently at @@ -23,11 +22,11 @@ class PublicFetcher begin retrieve_and_process_posts rescue => e - set_fetch_status PublicFetcher::Status_Failed + set_fetch_status Public::Status_Failed raise e end - set_fetch_status PublicFetcher::Status_Done + set_fetch_status Public::Status_Done end private @@ -35,20 +34,20 @@ class PublicFetcher # if it is reasonable to do so, and that they have not been fetched already def qualifies_for_fetching? raise ActiveRecord::RecordNotFound unless @person.present? - return false if @person.fetch_status == PublicFetcher::Status_Unfetchable + return false if @person.fetch_status == Public::Status_Unfetchable # local users don't need to be fetched if @person.local? - set_fetch_status PublicFetcher::Status_Unfetchable + set_fetch_status Public::Status_Unfetchable return false end # this record is already being worked on - return false if @person.fetch_status > PublicFetcher::Status_Initial + return false if @person.fetch_status > Public::Status_Initial # ok, let's go @person.remote? && - @person.fetch_status == PublicFetcher::Status_Initial + @person.fetch_status == Public::Status_Initial end # call the methods to fetch and process the public posts for the person @@ -72,24 +71,19 @@ class PublicFetcher # fetch the public posts of the person from their server and save the # JSON response to `@data` def retrieve_posts - set_fetch_status PublicFetcher::Status_Running + set_fetch_status Public::Status_Running FEDERATION_LOGGER.info "fetching public posts for #{@person.diaspora_handle}" - conn = Faraday.new(:url => @person.url) do |c| - c.request :json - c.response :json - c.adapter :net_http + resp = Faraday.get("#{@person.url}/people/#{@person.guid}") do |req| + req.headers[:accept] = 'application/json' + req.headers[:user_agent] = 'diaspora-fetcher' end - conn.headers[:user_agent] = 'diaspora-fetcher' - conn.headers[:accept] = 'application/json' - - resp = conn.get "/people/#{@person.guid}" FEDERATION_LOGGER.debug resp.body.to_s[0..250] - @data = resp.body - set_fetch_status PublicFetcher::Status_Fetched + @data = JSON.parse resp.body + set_fetch_status Public::Status_Fetched end # process the public posts that were previously fetched with `retrieve_posts` @@ -124,7 +118,7 @@ class PublicFetcher StatusMessage.set_callback :create, :set_guid end - set_fetch_status PublicFetcher::Status_Processed + set_fetch_status Public::Status_Processed end # set and save the fetch status for the current person @@ -182,4 +176,4 @@ class PublicFetcher type_ok end -end +end; end; end diff --git a/lib/diaspora/markdownify.rb b/lib/diaspora/markdownify.rb index e8001ba8f17f41021fdf685e9cc1a1bdd79183b4..c31ddbc0c648b0b5fd1f82bb4e831dc157eda58c 100644 --- a/lib/diaspora/markdownify.rb +++ b/lib/diaspora/markdownify.rb @@ -1,5 +1,3 @@ -require 'erb' - module Diaspora module Markdownify class HTML < Redcarpet::Render::HTML diff --git a/lib/diaspora/markdownify_email.rb b/lib/diaspora/markdownify_email.rb index bdc7983bad174ead92a37bb63e8a3ad626262f67..1e3263127db5f018d2172824c6f282f782e20d79 100644 --- a/lib/diaspora/markdownify_email.rb +++ b/lib/diaspora/markdownify_email.rb @@ -1,5 +1,3 @@ -require Rails.root.join("app", "models", "acts_as_taggable_on", "tag") - module Diaspora module Markdownify class Email < Redcarpet::Render::HTML @@ -26,4 +24,4 @@ module Diaspora end end end -end \ No newline at end of file +end diff --git a/lib/diaspora/taggable.rb b/lib/diaspora/taggable.rb index b55cb021a3819a656e9b302ebea6a8e6af9331b9..13c9bb81157a8bd67c50a86539f7b736d61ef51f 100644 --- a/lib/diaspora/taggable.rb +++ b/lib/diaspora/taggable.rb @@ -2,8 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join("app", "models", "acts_as_taggable_on", "tag") - module Diaspora module Taggable def self.included(model) diff --git a/lib/hcard.rb b/lib/h_card.rb similarity index 100% rename from lib/hcard.rb rename to lib/h_card.rb diff --git a/lib/hydra_wrapper.rb b/lib/hydra_wrapper.rb index 627ac3ba7c714508eef15a8a61d2da8510554d93..a2d02307a3048f21e6a71b540d0a4c7aaa9d0ba9 100644 --- a/lib/hydra_wrapper.rb +++ b/lib/hydra_wrapper.rb @@ -2,9 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require 'typhoeus' -require 'active_support/base64' - class HydraWrapper OPTS = {:max_redirects => 3, :timeout => 25000, :method => :post, diff --git a/lib/postzord.rb b/lib/postzord.rb index 2dfd25976203b7e5e5600173be475605f6c78615..438da2b28cf9feaf01a6aa3457734f374dd9eabf 100644 --- a/lib/postzord.rb +++ b/lib/postzord.rb @@ -3,5 +3,6 @@ # the COPYRIGHT file. module Postzord - + require 'postzord/receiver' + require 'postzord/dispatcher' end diff --git a/lib/postzord/dispatcher.rb b/lib/postzord/dispatcher.rb index 651087d5bf5aa7ee55f1014580fef707ebf8d257..ae6fa2687000da9370f0033591f99c819d5df91f 100644 --- a/lib/postzord/dispatcher.rb +++ b/lib/postzord/dispatcher.rb @@ -4,8 +4,8 @@ class Postzord::Dispatcher - require Rails.root.join('lib', 'postzord', 'dispatcher', 'private') - require Rails.root.join('lib', 'postzord', 'dispatcher', 'public') + require 'postzord/dispatcher/private' + require 'postzord/dispatcher/public' attr_reader :sender, :object, :xml, :subscribers, :opts diff --git a/lib/postzord/receiver.rb b/lib/postzord/receiver.rb index 9b0ad6408fc1dd686f2adef9a6cc9574fc721c73..f411de7c32715515cc76a6d2e0bdb1d061e6e879 100644 --- a/lib/postzord/receiver.rb +++ b/lib/postzord/receiver.rb @@ -4,8 +4,9 @@ class Postzord::Receiver - require Rails.root.join('lib', 'postzord', 'receiver', 'private') - require Rails.root.join('lib', 'postzord', 'receiver', 'public') + require 'postzord/receiver/private' + require 'postzord/receiver/public' + require 'postzord/receiver/local_batch' def perform! self.receive! diff --git a/lib/postzord/receiver/private.rb b/lib/postzord/receiver/private.rb index e966dae1807d7580f34d6f0a6e10e0dd985767fe..3e951707353a1f7959f4f523ac1612c214037dd3 100644 --- a/lib/postzord/receiver/private.rb +++ b/lib/postzord/receiver/private.rb @@ -2,9 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join('lib', 'webfinger') -require Rails.root.join('lib', 'diaspora', 'parser') - class Postzord::Receiver::Private < Postzord::Receiver def initialize(user, opts={}) diff --git a/lib/salmon/salmon.rb b/lib/salmon.rb similarity index 76% rename from lib/salmon/salmon.rb rename to lib/salmon.rb index c3ce02ae6fdc4260d9c29bccad13acb2297d3c1f..747190d6004890e692a353a04a9f787862e7ad77 100644 --- a/lib/salmon/salmon.rb +++ b/lib/salmon.rb @@ -24,7 +24,7 @@ end # Verify documents secured with Magic Signatures module Salmon - autoload :Slap, File.join(Rails.root, "lib", "salmon", "slap").to_s - autoload :EncryptedSlap, File.join(Rails.root, "lib", "salmon", "encrypted_slap").to_s - autoload :MagicSigEnvelope, File.join(Rails.root, "lib", "salmon", "magic_sig_envelope").to_s + require "salmon/slap" + require "salmon/encrypted_slap" + require "salmon/magic_sig_envelope" end diff --git a/lib/stream.rb b/lib/stream.rb index e778980cf48d46fd1655a82dbe0cae0901e54737..ae5c98f260828be3137dc1d079051cb39bdcacdc 100644 --- a/lib/stream.rb +++ b/lib/stream.rb @@ -1,3 +1,12 @@ module Stream - + require 'stream/activity' + require 'stream/aspect' + require 'stream/comments' + require 'stream/followed_tag' + require 'stream/likes' + require 'stream/mention' + require 'stream/multi' + require 'stream/person' + require 'stream/public' + require 'stream/tag' end diff --git a/lib/stream/base.rb b/lib/stream/base.rb index 47739a6bedbc0e4dc82889cef3396e46db2f5359..61eba6f93f1fb60fe234dcb26de939aba102d1e5 100644 --- a/lib/stream/base.rb +++ b/lib/stream/base.rb @@ -1,4 +1,3 @@ -require Rails.root.join("lib", "publisher") class Stream::Base TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo'] diff --git a/lib/webfinger.rb b/lib/webfinger.rb index d5d50b79f0df31be153ca3d10c52e42dd5db014b..c70cb7469b0d522892f4d09923f3b80f475c83f7 100644 --- a/lib/webfinger.rb +++ b/lib/webfinger.rb @@ -2,9 +2,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -require Rails.root.join('lib', 'hcard') -require Rails.root.join('lib', 'webfinger_profile') - class Webfinger attr_accessor :host_meta_xrd, :webfinger_profile_xrd, :webfinger_profile, :hcard, :hcard_xrd, :person, diff --git a/spec/lib/diaspora/fetcher/public_spec.rb b/spec/lib/diaspora/fetcher/public_spec.rb index 394b84c87b31d88beedba589f3a089bf27cdb3bf..5056e9c527c0721f6dbe96194000c70224fbeaae 100644 --- a/spec/lib/diaspora/fetcher/public_spec.rb +++ b/spec/lib/diaspora/fetcher/public_spec.rb @@ -3,24 +3,26 @@ # the COPYRIGHT file. require 'spec_helper' -require Rails.root.join('lib','diaspora','fetcher','public') # Tests fetching public posts of a person on a remote server -describe PublicFetcher do +describe Diaspora::Fetcher::Public do before do # the fixture is taken from an actual json request. # it contains 10 StatusMessages and 5 Reshares, all of them public # the guid of the person is "7445f9a0a6c28ebb" @fixture = File.open(Rails.root.join('spec', 'fixtures', 'public_posts.json')).read - @fetcher = PublicFetcher.new + @fetcher = Diaspora::Fetcher::Public.new @person = FactoryGirl.create(:person, {:guid => "7445f9a0a6c28ebb", :url => "https://remote-testpod.net", :diaspora_handle => "testuser@remote-testpod.net"}) stub_request(:get, /remote-testpod.net\/people\/.*/) - .with(:headers => {'Accept'=>'application/json'}) - .to_return(:body => @fixture) + .with(headers: { + 'Accept'=>'application/json', + 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', + 'User-Agent'=>'diaspora-fetcher' + }).to_return(:body => @fixture) end describe "#retrieve_posts" do @@ -34,8 +36,8 @@ describe PublicFetcher do it "sets the operation status on the person" do @person.reload - @person.fetch_status.should_not eql(PublicFetcher::Status_Initial) - @person.fetch_status.should eql(PublicFetcher::Status_Fetched) + @person.fetch_status.should_not eql(Diaspora::Fetcher::Public::Status_Initial) + @person.fetch_status.should eql(Diaspora::Fetcher::Public::Status_Fetched) end it "sets the @data variable to the parsed JSON data" do @@ -73,8 +75,8 @@ describe PublicFetcher do } @person.reload - @person.fetch_status.should_not eql(PublicFetcher::Status_Initial) - @person.fetch_status.should eql(PublicFetcher::Status_Processed) + @person.fetch_status.should_not eql(Diaspora::Fetcher::Public::Status_Initial) + @person.fetch_status.should eql(Diaspora::Fetcher::Public::Status_Processed) end context 'created post' do @@ -121,7 +123,7 @@ describe PublicFetcher do end context "private methods" do - let(:public_fetcher) { PublicFetcher.new } + let(:public_fetcher) { Diaspora::Fetcher::Public.new } describe '#qualifies_for_fetching?' do it "raises an error if the person doesn't exist" do @@ -135,7 +137,7 @@ describe PublicFetcher do it 'returns false if the person is unfetchable' do public_fetcher.instance_eval { - @person = FactoryGirl.create(:person, {:fetch_status => PublicFetcher::Status_Unfetchable}) + @person = FactoryGirl.create(:person, {:fetch_status => Diaspora::Fetcher::Public::Status_Unfetchable}) qualifies_for_fetching? }.should be_false end @@ -146,12 +148,12 @@ describe PublicFetcher do @person = user.person qualifies_for_fetching? }.should be_false - user.person.fetch_status.should eql PublicFetcher::Status_Unfetchable + user.person.fetch_status.should eql Diaspora::Fetcher::Public::Status_Unfetchable end it 'returns false if the person is processing already (or has been processed)' do person = FactoryGirl.create(:person) - person.fetch_status = PublicFetcher::Status_Fetched + person.fetch_status = Diaspora::Fetcher::Public::Status_Fetched person.save public_fetcher.instance_eval { @person = person @@ -173,14 +175,14 @@ describe PublicFetcher do person = @person public_fetcher.instance_eval { @person = person - set_fetch_status PublicFetcher::Status_Unfetchable + set_fetch_status Diaspora::Fetcher::Public::Status_Unfetchable } - @person.fetch_status.should eql PublicFetcher::Status_Unfetchable + @person.fetch_status.should eql Diaspora::Fetcher::Public::Status_Unfetchable public_fetcher.instance_eval { - set_fetch_status PublicFetcher::Status_Initial + set_fetch_status Diaspora::Fetcher::Public::Status_Initial } - @person.fetch_status.should eql PublicFetcher::Status_Initial + @person.fetch_status.should eql Diaspora::Fetcher::Public::Status_Initial end end diff --git a/spec/lib/email_inviter_spec.rb b/spec/lib/email_inviter_spec.rb index 3d423d36201ba0a2ce63820aba434461788c7e73..2de1282872d95dc700d2f502729ea0f1eff485c1 100644 --- a/spec/lib/email_inviter_spec.rb +++ b/spec/lib/email_inviter_spec.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'email_inviter') +require 'spec_helper' describe EmailInviter do before do @@ -53,4 +53,4 @@ describe EmailInviter do inviter.invitation_code.should == @user.invitation_code end end -end \ No newline at end of file +end diff --git a/spec/lib/hcard_spec.rb b/spec/lib/hcard_spec.rb index 4ab77030a3654140b73695db9284a213b6801b1e..4a898d9fb65a4fda99eca9fb93cd31f034efd851 100644 --- a/spec/lib/hcard_spec.rb +++ b/spec/lib/hcard_spec.rb @@ -3,7 +3,6 @@ # the COPYRIGHT file. require 'spec_helper' -require Rails.root.join('lib', 'hcard') describe HCard do it 'should parse an hcard' do diff --git a/spec/lib/postzord/dispatcher/private_spec.rb b/spec/lib/postzord/dispatcher/private_spec.rb index e09f12819c73bf2b4e50e549f9fd03c426c4fea7..84b69769509b0474a4dc64ad15c7c65629c7641e 100644 --- a/spec/lib/postzord/dispatcher/private_spec.rb +++ b/spec/lib/postzord/dispatcher/private_spec.rb @@ -3,7 +3,6 @@ # the COPYRIGHT file. require 'spec_helper' -require Rails.root.join('lib', 'postzord', 'dispatcher', 'private') describe Postzord::Dispatcher::Private do diff --git a/spec/lib/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index 7df98d97b361e6c6ebe2f0a893b121465f294b01..4e39a1d9582d20aeda1ed965d4edf6d7e5f838b7 100644 --- a/spec/lib/postzord/dispatcher_spec.rb +++ b/spec/lib/postzord/dispatcher_spec.rb @@ -4,8 +4,6 @@ require 'spec_helper' -require Rails.root.join('lib', 'postzord', 'dispatcher') - describe Postzord::Dispatcher do before do @sm = FactoryGirl.create(:status_message, :public => true, :author => alice.person) diff --git a/spec/lib/postzord/receiver/local_batch_spec.rb b/spec/lib/postzord/receiver/local_batch_spec.rb index 59867d710732ad8825d58fa78c7e70d50192737c..ad1ef7115dfee3e8938b61556ac1b43f0837a91d 100644 --- a/spec/lib/postzord/receiver/local_batch_spec.rb +++ b/spec/lib/postzord/receiver/local_batch_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -require Rails.root.join('lib', 'postzord', 'receiver', 'local_batch') describe Postzord::Receiver::LocalBatch do before do diff --git a/spec/lib/postzord/receiver/private_spec.rb b/spec/lib/postzord/receiver/private_spec.rb index 23734697608896846657af96ba02f40f1be37775..4b2bb653cdc1817df01742d55f00b005d9db2379 100644 --- a/spec/lib/postzord/receiver/private_spec.rb +++ b/spec/lib/postzord/receiver/private_spec.rb @@ -4,9 +4,6 @@ require 'spec_helper' -require Rails.root.join('lib', 'postzord') -require Rails.root.join('lib', 'postzord', 'receiver', 'private') - describe Postzord::Receiver::Private do before do diff --git a/spec/lib/postzord/receiver/public_spec.rb b/spec/lib/postzord/receiver/public_spec.rb index 188586416beacdf3711a6dfef3b9adadd23e4a83..766686677ee367dc5933690aef0c08cfac282738 100644 --- a/spec/lib/postzord/receiver/public_spec.rb +++ b/spec/lib/postzord/receiver/public_spec.rb @@ -4,9 +4,6 @@ require 'spec_helper' -require Rails.root.join('lib', 'postzord') -require Rails.root.join('lib', 'postzord', 'receiver', 'public') - describe Postzord::Receiver::Public do before do @post = FactoryGirl.build(:status_message, :author => alice.person, :public => true) diff --git a/spec/lib/postzord/receiver_spec.rb b/spec/lib/postzord/receiver_spec.rb index 8eb2a55bc9da5c350965be4b2f5a0b189b6cd456..5ac6dbf9aa0925f59753dc195afe8e12c491bb80 100644 --- a/spec/lib/postzord/receiver_spec.rb +++ b/spec/lib/postzord/receiver_spec.rb @@ -4,8 +4,6 @@ require 'spec_helper' -require Rails.root.join('lib', 'postzord', 'receiver') - describe Postzord::Receiver do before do @receiver = Postzord::Receiver.new diff --git a/spec/lib/publisher_spec.rb b/spec/lib/publisher_spec.rb index 129d4798323d96666b4372892e9321e3a008476b..c638235ff9df83212b6aa1a5b0decb0949227b17 100644 --- a/spec/lib/publisher_spec.rb +++ b/spec/lib/publisher_spec.rb @@ -1,9 +1,6 @@ require 'spec_helper' -#NOTE;why is it not auto loadeded? -require Rails.root.join('lib', 'publisher') - describe Publisher do before do @publisher = Publisher.new(alice) diff --git a/spec/lib/pubsubhubbub_spec.rb b/spec/lib/pubsubhubbub_spec.rb index bcbf8431a72bdab1b54012f0d540a3c10d5e7382..c486f0377e4000e200f178e82687b93841aaa02f 100644 --- a/spec/lib/pubsubhubbub_spec.rb +++ b/spec/lib/pubsubhubbub_spec.rb @@ -3,7 +3,6 @@ # the COPYRIGHT file. require 'spec_helper' -require Rails.root.join('lib', 'pubsubhubbub') describe Pubsubhubbub do describe '#publish' do @@ -16,4 +15,4 @@ describe Pubsubhubbub do Pubsubhubbub.new(hub).publish(feed).should be_success end end -end \ No newline at end of file +end diff --git a/spec/lib/rake_helper_spec.rb b/spec/lib/rake_helper_spec.rb index 77fd6e198f0d10bac026711725d1bd092cf1d525..58039173c380d5f5cc6554380e5d808729bb12b0 100644 --- a/spec/lib/rake_helper_spec.rb +++ b/spec/lib/rake_helper_spec.rb @@ -3,7 +3,8 @@ # the COPYRIGHT file. require 'spec_helper' -require Rails.root.join('lib', 'rake_helpers') +require 'rake_helpers' + include RakeHelpers describe RakeHelpers do before do diff --git a/spec/lib/statistics_spec.rb b/spec/lib/statistics_spec.rb index f626ccd578ed62d1db772bcd88e448b8c298ebf6..9720d263121ef8b5c9e0211fd5f0c9971055226d 100644 --- a/spec/lib/statistics_spec.rb +++ b/spec/lib/statistics_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -require Rails.root.join('lib', 'statistics') describe Statistics do diff --git a/spec/lib/stream/base_spec.rb b/spec/lib/stream/base_spec.rb index e89b3dadfb435e31f0b518200971a3b0d8673282..104e3699d37f8bc61fc21cf008ebf422bb348f6b 100644 --- a/spec/lib/stream/base_spec.rb +++ b/spec/lib/stream/base_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' require Rails.root.join('spec', 'shared_behaviors', 'stream') + describe Stream::Base do before do @stream = Stream::Base.new(alice) diff --git a/spec/lib/template_picker_spec.rb b/spec/lib/template_picker_spec.rb index 1e1570910fc5ce7fc4cfaabfd129d58cc2bd5f6c..119ce3ac7edbd4d82bb9dce6fcbcd2c777980348 100644 --- a/spec/lib/template_picker_spec.rb +++ b/spec/lib/template_picker_spec.rb @@ -1,5 +1,5 @@ -require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'template_picker') require 'spec_helper' + describe TemplatePicker do before do @post_stubs = {:type => 'StatusMessage', :photos => stub(:size => 2), diff --git a/spec/models/jobs/publish_to_hub_spec.rb b/spec/models/jobs/publish_to_hub_spec.rb index 38e5e622cdc182a993bd3adaa65a80d0d6e13716..27937cca57a93f6d8f107f5fba51747218d2a862 100644 --- a/spec/models/jobs/publish_to_hub_spec.rb +++ b/spec/models/jobs/publish_to_hub_spec.rb @@ -3,7 +3,6 @@ # the COPYRIGHT file. require 'spec_helper' -require Rails.root.join('lib', 'pubsubhubbub') describe Jobs::PublishToHub do describe '.perform' do