Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Remove backports, fix Ruby 1.8 support #46

Merged
merged 4 commits into from

2 participants

@mperham

require_relative is not necessary and backports has a huge negative effect on our application performance. Test suite passes in Ruby 1.9 and 1.8.

Also did some general project cleanup:

  • Gemfile.lock is not supposed to be checked in for library development.
  • Updated dependencies in gemspec.
  • Cleaned up test/helper.rb.
@troessner troessner merged commit 0764688 into from
@troessner
Owner

Looks great, merged, thanks!

@mperham listed you as author: 932bdcf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  .rvmrc
@@ -1 +1 @@
-rvm ruby-1.9.2-p290@transitions
+rvm 1.9.3@transitions --create
View
41 Gemfile.lock
@@ -1,41 +0,0 @@
-PATH
- remote: .
- specs:
- transitions (0.0.15)
- backports
-
-GEM
- remote: http://rubygems.org/
- specs:
- activemodel (3.0.0)
- activesupport (= 3.0.0)
- builder (~> 2.1.2)
- i18n (~> 0.4.1)
- activerecord (3.0.0)
- activemodel (= 3.0.0)
- activesupport (= 3.0.0)
- arel (~> 1.0.0)
- tzinfo (~> 0.3.23)
- activesupport (3.0.0)
- arel (1.0.1)
- activesupport (~> 3.0.0)
- backports (2.5.1)
- builder (2.1.2)
- i18n (0.4.1)
- mocha (0.9.8)
- rake
- rake (0.8.7)
- sqlite3-ruby (1.3.1)
- test-unit (2.4.1)
- tzinfo (0.3.23)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- activerecord (~> 3)
- bundler (~> 1)
- mocha
- sqlite3-ruby
- test-unit (~> 2.2)
- transitions!
View
2  Rakefile
@@ -4,7 +4,7 @@ Bundler.setup
require "rake/testtask"
Rake::TestTask.new(:test) do |test|
- test.libs << "lib" << "test"
+ test.libs = %w(lib test)
test.pattern = "test/**/test_*.rb"
test.verbose = true
end
View
4 lib/active_record/transitions.rb
@@ -1,5 +1,5 @@
-require_relative '../active_model/transitions'
+require 'active_model/transitions'
module ActiveRecord
Transitions = ActiveModel::Transitions
-end
+end
View
5 lib/transitions.rb
@@ -20,7 +20,6 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-require 'backports'
require "transitions/event"
require "transitions/machine"
require "transitions/state"
@@ -55,8 +54,8 @@ def state_machine(name = nil, options = {}, &block)
block ? state_machines[name].update(options, &block) : state_machines[name]
end
- def available_states name = :default
- state_machines[name].states.map(&:name).sort
+ def available_states(name = :default)
+ state_machines[name].states.map(&:name).sort_by {|x| x.to_s}
end
def define_state_query_method(state_name)
View
6 lib/transitions/event.rb
@@ -40,7 +40,7 @@ def initialize(machine, name, options = {}, &block)
def fire(obj, to_state = nil, *args)
transitions = @transitions.select { |t| t.from == obj.current_state(@machine ? @machine.name : nil) }
- raise InvalidTransition, error_message_for_invalid_transitions(obj) if transitions.size == 0
+ raise InvalidTransition, error_message_for_invalid_transitions(obj, to_state) if transitions.size == 0
next_state = nil
transitions.each do |transition|
@@ -134,8 +134,8 @@ def build_sucess_callback(callback_symbol_or_proc)
end
end
- def error_message_for_invalid_transitions(obj)
- "No transitions present for `#{obj.class.name}` #{obj.class < ActiveRecord::Base && obj.persisted? ? "with ID #{obj.id} " : nil}with current state `#{obj.current_state}`"
+ def error_message_for_invalid_transitions(obj, to_state)
+ "Canno transition to #{to_state || 'default'} from #{obj.current_state} for `#{obj.class.name}` #{obj.class < ActiveRecord::Base && obj.persisted? ? "with ID #{obj.id} " : nil}"
end
end
end
View
6 test/helper.rb
@@ -5,15 +5,9 @@
require "mocha"
require "db/create_db"
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
-$LOAD_PATH.unshift(File.dirname(__FILE__))
require "transitions"
require "active_model/transitions"
-class Test::Unit::TestCase
-
-end
-
def create_database
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Migration.verbose = false
View
6 transitions.gemspec
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
s.name = "transitions"
s.version = Transitions::VERSION
s.platform = Gem::Platform::RUBY
- s.authors = ["Jakub Kuźma", "Timo Rößner"]
+ s.authors = ["Jakub Kuzma", "Timo Roessner"]
s.email = "timo.roessner@googlemail.com"
s.homepage = "http://github.com/troessner/transitions"
s.summary = "State machine extracted from ActiveModel"
@@ -14,11 +14,11 @@ Gem::Specification.new do |s|
s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "transitions"
- s.add_dependency "backports"
s.add_development_dependency "bundler", "~> 1"
s.add_development_dependency "test-unit", "~> 2.2"
s.add_development_dependency "mocha"
- s.add_development_dependency "sqlite3-ruby"
+ s.add_development_dependency "rake"
+ s.add_development_dependency "sqlite3"
s.add_development_dependency "activerecord", "~> 3"
s.files = `git ls-files`.split("\n")
Something went wrong with that request. Please try again.