Skip to content

Commit

Permalink
Switched path management over to use Bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiwren committed Sep 3, 2011
1 parent c5a4012 commit 44eaffe
Show file tree
Hide file tree
Showing 29 changed files with 167 additions and 201 deletions.
6 changes: 5 additions & 1 deletion Gemfile
@@ -1,7 +1,11 @@
source "http://rubygems.org"

gem 'hanna'
gem 'rubyforge'
gem 'simplecov', :platforms => :mri_19

group :multipart_support do
gem 'multipart-post', '~> 1.0'
gem 'multipart-post', '~> 1'
end

group :libcurl_support do
Expand Down
89 changes: 29 additions & 60 deletions Rakefile
Expand Up @@ -10,26 +10,22 @@
# Note that some optional libraries/gems that the build (not Wrest itself) uses may not be available on all implementations of Ruby.
puts "Building on Ruby #{RUBY_VERSION}, #{RUBY_RELEASE_DATE}, #{RUBY_PLATFORM}"

require 'rubygems'
require 'bundler'
Bundler::GemHelper.install_tasks

if Object.const_defined?('RAILS_ROOT') || Object.const_defined?('Rails')
require File.dirname(__FILE__) + '/../../../config/environment'
else
require 'rubygems'
require 'rake'
require 'rspec'
require 'rspec/core/rake_task'

begin
require 'metric_fu'
MetricFu::Configuration.run do |config|
config.rcov[:test_files] = ['spec/**/*_spec.rb']
config.rcov[:rcov_opts] << "-Ispec" # Needed to find spec_helper
end
rescue LoadError
puts 'metric_fu is not available. Install it with: gem install jscruggs-metric_fu -s http://gems.github.com'
Bundler.setup

require 'rspec/core/rake_task'
require 'hanna/rdoctask'
require 'rake/contrib/sshpublisher'

begin
require 'metric_fu'
MetricFu::Configuration.run do |config|
config.rcov[:test_files] = ['spec/**/*_spec.rb']
config.rcov[:rcov_opts] << "-Ispec" # Needed to find spec_helper
end
rescue LoadError
puts 'metric_fu is not available. Install it with: gem install jscruggs-metric_fu -s http://gems.github.com'
end

desc 'Default: run spec tests.'
Expand All @@ -56,12 +52,7 @@ namespace :rspec do
end
end

begin
require 'hanna/rdoctask'
rescue LoadError
puts 'Hanna not available, using standard Rake rdoctask. Install it with: gem install mislav-hanna.'
require 'rake/rdoctask'
end

desc 'Generate documentation for Wrest'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
Expand All @@ -71,50 +62,28 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end

begin
require 'rcov'
require 'rcov/rcovtask'
desc "Run all specs in spec directory with RCov"
RSpec::Core::RakeTask.new(:rcov) do |t|
#t.rspec_opts = ['--options', "spec/spec.opts"]
t.pattern = "spec/unit/wrest/**/*_spec.rb"
t.rcov = true
t.rcov_opts = lambda do
IO.readlines("spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
end
# t.verbose = true
end
rescue LoadError
puts "Rcov not available."
end

begin
require 'rake/contrib/sshpublisher'
namespace :rubyforge do

namespace :rubyforge do

desc "Release gem and RDoc documentation to RubyForge"
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
desc "Release gem and RDoc documentation to RubyForge"
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]

namespace :release do
desc "Publish RDoc to RubyForge."
task :docs => [:rdoc] do
config = YAML.load(
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
)
namespace :release do
desc "Publish RDoc to RubyForge."
task :docs => [:rdoc] do
config = YAML.load(
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
)

host = "#{config['username']}@rubyforge.org"
remote_dir = "/var/www/gforge-projects/wrest/"
local_dir = 'rdoc'
host = "#{config['username']}@rubyforge.org"
remote_dir = "/var/www/gforge-projects/wrest/"
local_dir = 'rdoc'

Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
end
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
end
end
rescue LoadError
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
end


namespace (:benchmark) do
desc "Create classes to be used in Wrest::Resource vs. ActiveResource"
task :setup_test_classes do
Expand Down
40 changes: 20 additions & 20 deletions lib/wrest.rb
Expand Up @@ -35,7 +35,7 @@ def self.logger
end

def self.enable_evented_requests!
require "#{Wrest::Root}/wrest/event_machine_backend"
require "wrest/event_machine_backend"
end

# Switch Wrest to using Net::HTTP.
Expand All @@ -45,40 +45,40 @@ def self.use_native!

# Switch Wrest to using libcurl.
def self.use_curl!
require "#{Wrest::Root}/wrest/curl"
require "wrest/curl"
silence_warnings{ Wrest.const_set('Http', Wrest::Curl) }
end
end

Wrest.logger = ActiveSupport::BufferedLogger.new(STDOUT)
Wrest.logger.level = Logger::DEBUG

require "#{Wrest::Root}/wrest/core_ext/string"
require "#{Wrest::Root}/wrest/hash_with_case_insensitive_access"
require "wrest/core_ext/string"
require "wrest/hash_with_case_insensitive_access"

# Load XmlMini Extensions
require "#{Wrest::Root}/wrest/xml_mini"
require "wrest/xml_mini"

# Load Wrest Core
require "#{Wrest::Root}/wrest/version"
require "#{Wrest::Root}/wrest/cache_proxy"
require "#{Wrest::Root}/wrest/http_shared"
require "#{Wrest::Root}/wrest/http_codes"
require "#{Wrest::Root}/wrest/callback"
require "#{Wrest::Root}/wrest/native"
require "wrest/version"
require "wrest/cache_proxy"
require "wrest/http_shared"
require "wrest/http_codes"
require "wrest/callback"
require "wrest/native"

require "#{Wrest::Root}/wrest/async_request"
require "#{Wrest::Root}/wrest/async_request/thread_backend"
require "wrest/async_request"
require "wrest/async_request/thread_backend"
Wrest::AsyncRequest.default_to_threads!

require "#{Wrest::Root}/wrest/caching"
require "wrest/caching"

# Load Wrest Wrappers
require "#{Wrest::Root}/wrest/uri/builders"
require "#{Wrest::Root}/wrest/uri"
require "#{Wrest::Root}/wrest/uri_template"
require "#{Wrest::Root}/wrest/exceptions"
require "#{Wrest::Root}/wrest/components"
require "wrest/uri/builders"
require "wrest/uri"
require "wrest/uri_template"
require "wrest/exceptions"
require "wrest/components"

# Load Wrest::Resource
# require "#{Wrest::Root}/wrest/resource"
# require "wrest/resource"
2 changes: 1 addition & 1 deletion lib/wrest/async_request.rb
Expand Up @@ -12,7 +12,7 @@ module Wrest
module AsyncRequest
# Loads Wrest eventmachine backend alongwith eventmachine gem
def self.enable_em
require "#{Wrest::Root}/wrest/async_request/event_machine_backend"
require "wrest/async_request/event_machine_backend"
end

# Assign default backend to be used for asynchronous request. Default is to use threads
Expand Down
2 changes: 1 addition & 1 deletion lib/wrest/caching.rb
Expand Up @@ -11,7 +11,7 @@ module Wrest
module Caching
# Loads the Memcached caching back-end and the Dalli gem
def self.enable_memcached
require "#{Wrest::Root}/wrest/caching/memcached"
require "wrest/caching/memcached"
end

# Configures Wrest to cache all requests. This will use a Ruby Hash.
Expand Down
4 changes: 2 additions & 2 deletions lib/wrest/components.rb
Expand Up @@ -15,5 +15,5 @@ module Components
end
end

require "#{Wrest::Root}/wrest/components/container"
require "#{Wrest::Root}/wrest/components/translators"
require "wrest/components/container"
require "wrest/components/translators"
4 changes: 2 additions & 2 deletions lib/wrest/components/container.rb
Expand Up @@ -12,8 +12,8 @@ module Components::Container
end
end

require "#{Wrest::Root}/wrest/components/container/typecaster"
require "#{Wrest::Root}/wrest/components/container/alias_accessors"
require "wrest/components/container/typecaster"
require "wrest/components/container/alias_accessors"

module Wrest::Components

Expand Down
10 changes: 5 additions & 5 deletions lib/wrest/components/mutators.rb
Expand Up @@ -32,9 +32,9 @@ def self.chain(*mutator_keys)
end
end
end
require "#{Wrest::Root}/wrest/core_ext/hash"
require "#{Wrest::Root}/wrest/components/mutators/base"
require "#{Wrest::Root}/wrest/components/mutators/xml_simple_type_caster"
require "#{Wrest::Root}/wrest/components/mutators/xml_mini_type_caster"
require "#{Wrest::Root}/wrest/components/mutators/camel_to_snake_case"
require "wrest/core_ext/hash"
require "wrest/components/mutators/base"
require "wrest/components/mutators/xml_simple_type_caster"
require "wrest/components/mutators/xml_mini_type_caster"
require "wrest/components/mutators/camel_to_snake_case"

6 changes: 3 additions & 3 deletions lib/wrest/components/translators.rb
Expand Up @@ -23,6 +23,6 @@ def self.lookup(content_type)
end
end

require "#{Wrest::Root}/wrest/components/translators/xml"
require "#{Wrest::Root}/wrest/components/translators/json"
require "#{Wrest::Root}/wrest/components/translators/content_types"
require "wrest/components/translators/xml"
require "wrest/components/translators/json"
require "wrest/components/translators/content_types"
2 changes: 1 addition & 1 deletion lib/wrest/core_ext/hash.rb
@@ -1,4 +1,4 @@
require "#{Wrest::Root}/wrest/core_ext/hash/conversions"
require "wrest/core_ext/hash/conversions"

class Hash #:nodoc:
include Wrest::CoreExt::Hash::Conversions
Expand Down
2 changes: 1 addition & 1 deletion lib/wrest/core_ext/string.rb
@@ -1,4 +1,4 @@
require "#{Wrest::Root}/wrest/core_ext/string/conversions"
require "wrest/core_ext/string/conversions"

class String #:nodoc:
include Wrest::CoreExt::String::Conversions unless Wrest.const_defined?('NoStringExtensions')
Expand Down
24 changes: 12 additions & 12 deletions lib/wrest/curl.rb
Expand Up @@ -8,9 +8,9 @@
# See the License for the specific language governing permissions and limitations under the License.

begin
gem 'patron', '~> 0.4.11'
gem 'patron', '~> 0.4'
rescue Gem::LoadError => e
Wrest.logger.debug "Patron ~> 0.4.11 not found. Patron is necessary to use libcurl. To install Patron run `sudo gem install patron` (patron is not available on JRuby, but you shouldn't need it anyway)."
Wrest.logger.debug "Patron ~> 0.4.x not found. Patron is necessary to use libcurl. To install Patron run `sudo gem install patron` (patron is not available on JRuby, but you shouldn't need it anyway)."
raise e
end
require 'patron'
Expand Down Expand Up @@ -39,13 +39,13 @@ class Session
end
end

require "#{Wrest::Root}/wrest/curl/response"
require "#{Wrest::Root}/wrest/curl/request"
require "#{Wrest::Root}/wrest/curl/get"
require "#{Wrest::Root}/wrest/curl/put"
require "#{Wrest::Root}/wrest/curl/post"
require "#{Wrest::Root}/wrest/curl/delete"
require "#{Wrest::Root}/wrest/curl/options"
require "#{Wrest::Root}/wrest/curl/post_multipart"
require "#{Wrest::Root}/wrest/curl/put_multipart"
# require "#{Wrest::Root}/wrest/curl/session"
require "wrest/curl/response"
require "wrest/curl/request"
require "wrest/curl/get"
require "wrest/curl/put"
require "wrest/curl/post"
require "wrest/curl/delete"
require "wrest/curl/options"
require "wrest/curl/post_multipart"
require "wrest/curl/put_multipart"
# require "wrest/curl/session"
6 changes: 3 additions & 3 deletions lib/wrest/http_shared.rb
Expand Up @@ -14,9 +14,9 @@ module HttpShared
end
end

require "#{Wrest::Root}/wrest/http_shared/headers"
require "#{Wrest::Root}/wrest/http_shared/standard_headers"
require "#{Wrest::Root}/wrest/http_shared/standard_tokens"
require "wrest/http_shared/headers"
require "wrest/http_shared/standard_headers"
require "wrest/http_shared/standard_tokens"

# Set up a shorter convenience API for constants
Wrest::H = Wrest::HttpShared::StandardHeaders
Expand Down
20 changes: 10 additions & 10 deletions lib/wrest/native.rb
Expand Up @@ -18,16 +18,16 @@ module Native
end
end

require "#{Wrest::Root}/wrest/native/connection_factory"
require "#{Wrest::Root}/wrest/native/response"
require "#{Wrest::Root}/wrest/native/redirection"
require "#{Wrest::Root}/wrest/native/request"
require "#{Wrest::Root}/wrest/native/get"
require "#{Wrest::Root}/wrest/native/put"
require "#{Wrest::Root}/wrest/native/post"
require "#{Wrest::Root}/wrest/native/delete"
require "#{Wrest::Root}/wrest/native/options"
require "#{Wrest::Root}/wrest/native/session"
require "wrest/native/connection_factory"
require "wrest/native/response"
require "wrest/native/redirection"
require "wrest/native/request"
require "wrest/native/get"
require "wrest/native/put"
require "wrest/native/post"
require "wrest/native/delete"
require "wrest/native/options"
require "wrest/native/session"

# default to using Native libs
Wrest::Http = Wrest::Native
2 changes: 1 addition & 1 deletion lib/wrest/test.rb
@@ -1 +1 @@
require "#{Wrest::Root}/wrest/test/request_patches"
require "wrest/test/request_patches"

0 comments on commit 44eaffe

Please sign in to comment.