Skip to content

Commit

Permalink
Drop Jeweler; using Bundler instead. Changed exception constants naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Jan 10, 2011
1 parent d9b3adf commit 3823bfc
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 155 deletions.
15 changes: 1 addition & 14 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
source :rubygems

gem "rails", "3.0.3"
gem "fakeweb"
gem "rspec-rails", "2.4.1"
gem "faker"
gem "nokogiri"
gem "sqlite3-ruby"

platforms :mri_19 do
gem "ruby-debug19", :require => "ruby-debug"
end

platforms :mri_18 do
gem "ruby-debug"
end
gemspec
32 changes: 8 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
PATH
remote: .
specs:
pagseguro (0.1.2)

GEM
remote: http://rubygems.org/
specs:
Expand Down Expand Up @@ -28,19 +33,14 @@ GEM
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
archive-tar-minitar (0.5.2)
arel (2.0.6)
builder (2.1.2)
columnize (0.3.1)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
faker (0.3.1)
fakeweb (1.3.0)
i18n (0.5.0)
linecache (0.43)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
mail (2.2.14)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
Expand Down Expand Up @@ -81,21 +81,6 @@ GEM
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.4.0)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
ruby-debug-base19 (0.11.24)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2)
sqlite3-ruby (1.3.1)
thor (0.14.6)
treetop (1.4.9)
Expand All @@ -109,8 +94,7 @@ DEPENDENCIES
faker
fakeweb
nokogiri
rails (= 3.0.3)
rspec-rails (= 2.4.1)
ruby-debug
ruby-debug19
pagseguro!
rails (~> 3.0.3)
rspec-rails (~> 2.4.1)
sqlite3-ruby
26 changes: 3 additions & 23 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
require "rspec/core/rake_task"
require File.dirname(__FILE__) + "/lib/pagseguro/version"
require "bundler"
Bundler::GemHelper.install_tasks

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new

begin
require "jeweler"

JEWEL = Jeweler::Tasks.new do |gem|
gem.name = "pagseguro"
gem.version = PagSeguro::Version::STRING
gem.summary = "A wrapper for the PagSeguro payment gateway."
gem.description = ""
gem.authors = ["Nando Vieira"]
gem.email = "[email protected]"
gem.homepage = "http://github.com/fnando/pagseguro"
gem.has_rdoc = false
gem.files = FileList["{.rspec,Gemfile,Gemfile.lock,Rakefile,README.markdown,pagseguro.gemspec}", "{lib,spec,templates,test}/**/*"]
gem.add_development_dependency "rspec", ">= 2.0.0"
end

Jeweler::GemcutterTasks.new
rescue LoadError => e
puts "You don't have Jeweler installed, so you won't be able to build gems."
end
8 changes: 4 additions & 4 deletions lib/pagseguro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def config?

# Load configuration file.
def config
raise MissingConfigurationException, "file not found on #{config_file.inspect}" unless config?
raise MissingConfigurationError, "file not found on #{config_file.inspect}" unless config?

# load file if is not loaded yet
@@config ||= YAML.load_file(config_file)

# raise an exception if the environment hasn't been set
# or if file is empty
if @@config == false || !@@config[Rails.env]
raise MissingEnvironmentException, ":#{Rails.env} environment not set on #{config_file.inspect}"
raise MissingEnvironmentError, ":#{Rails.env} environment not set on #{config_file.inspect}"
end

# retrieve the environment settings
Expand All @@ -61,6 +61,6 @@ def developer?
config? && config["developer"] == true
end

class MissingEnvironmentException < StandardError; end
class MissingConfigurationException < StandardError; end
class MissingEnvironmentError < StandardError; end
class MissingConfigurationError < StandardError; end
end
106 changes: 19 additions & 87 deletions pagseguro.gemspec
Original file line number Diff line number Diff line change
@@ -1,94 +1,26 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "pagseguro/version"

Gem::Specification.new do |s|
s.name = %q{pagseguro}
s.version = "0.1.2"
s.name = "pagseguro"
s.version = PagSeguro::Version::STRING
s.platform = Gem::Platform::RUBY
s.authors = ["Nando Vieira"]
s.email = ["[email protected]"]
s.homepage = "http://rubygems.org/gems/pagseguro"
s.summary = "The official PagSeguro library"
s.description = s.summary

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nando Vieira"]
s.date = %q{2010-10-16}
s.description = %q{}
s.email = %q{[email protected]}
s.extra_rdoc_files = [
"README.markdown"
]
s.files = [
".rspec",
"Gemfile",
"Gemfile.lock",
"README.markdown",
"Rakefile",
"lib/pagseguro.rb",
"lib/pagseguro/action_controller.rb",
"lib/pagseguro/developer_controller.rb",
"lib/pagseguro/generator.rb",
"lib/pagseguro/helper.rb",
"lib/pagseguro/notification.rb",
"lib/pagseguro/order.rb",
"lib/pagseguro/railtie.rb",
"lib/pagseguro/rake.rb",
"lib/pagseguro/routes.rb",
"lib/pagseguro/version.rb",
"lib/pagseguro/views/_form.html.erb",
"lib/tasks/pagseguro.rake",
"pagseguro.gemspec",
"spec/controllers/developer_controller_spec.rb",
"spec/helpers/helper_spec.rb",
"spec/pagseguro/notification_spec.rb",
"spec/pagseguro/order_spec.rb",
"spec/pagseguro/pagseguro_spec.rb",
"spec/pagseguro/rake_spec.rb",
"spec/spec_helper.rb",
"spec/support/app/controllers/application_controller.rb",
"spec/support/app/models/account.rb",
"spec/support/app/models/user.rb",
"spec/support/app/views/dashboard/index.erb",
"spec/support/app/views/session/new.erb",
"spec/support/config/boot.rb",
"spec/support/config/database.yml",
"spec/support/config/pagseguro.yml",
"spec/support/config/routes.rb",
"spec/support/log/test.log",
"spec/support/matcher.rb",
"spec/support/pagseguro-test.yml",
"spec/support/tmp/pagseguro-test.yml",
"templates/config.yml"
]
s.homepage = %q{http://github.com/fnando/pagseguro}
s.rdoc_options = ["--charset=UTF-8"]
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{A wrapper for the PagSeguro payment gateway.}
s.test_files = [
"spec/controllers/developer_controller_spec.rb",
"spec/helpers/helper_spec.rb",
"spec/pagseguro/notification_spec.rb",
"spec/pagseguro/order_spec.rb",
"spec/pagseguro/pagseguro_spec.rb",
"spec/pagseguro/rake_spec.rb",
"spec/spec_helper.rb",
"spec/support/app/controllers/application_controller.rb",
"spec/support/app/models/account.rb",
"spec/support/app/models/user.rb",
"spec/support/config/boot.rb",
"spec/support/config/routes.rb",
"spec/support/matcher.rb"
]

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
else
s.add_dependency(%q<rspec>, [">= 2.0.0"])
end
else
s.add_dependency(%q<rspec>, [">= 2.0.0"])
end
s.add_development_dependency "rails", "~> 3.0.3"
s.add_development_dependency "fakeweb"
s.add_development_dependency "rspec-rails", "~> 2.4.1"
s.add_development_dependency "faker"
s.add_development_dependency "nokogiri"
s.add_development_dependency "sqlite3-ruby"
end

6 changes: 3 additions & 3 deletions spec/pagseguro/pagseguro_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ module PagSeguro; @@config = nil; end

it "should raise error if configuration is not found" do
File.should_receive(:exist?).with(@config_file).and_return(false)
expect { PagSeguro.config }.to raise_error(PagSeguro::MissingConfigurationException)
expect { PagSeguro.config }.to raise_error(PagSeguro::MissingConfigurationError)
end

it "should raise error if no environment is set on config file" do
YAML.should_receive(:load_file).with(@config_file).and_return({})
expect { PagSeguro.config }.to raise_error(PagSeguro::MissingEnvironmentException)
expect { PagSeguro.config }.to raise_error(PagSeguro::MissingEnvironmentError)
end

it "should raise error if config file is empty" do
# YAML.load_file return false when file is zero-byte
YAML.should_receive(:load_file).with(@config_file).and_return(false)
expect { PagSeguro.config }.to raise_error(PagSeguro::MissingEnvironmentException)
expect { PagSeguro.config }.to raise_error(PagSeguro::MissingEnvironmentError)
end

it "should return local url if developer mode is enabled" do
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "bigdecimal"
require "support/config/boot"
require "rspec/rails"
require "nokogiri"
require "support/matcher"

FakeWeb.allow_net_connect = false

0 comments on commit 3823bfc

Please sign in to comment.