repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/rails.rb | lib/figaro/rails.rb | begin
require "rails"
rescue LoadError
else
require "figaro/rails/application"
require "figaro/rails/railtie"
Figaro.adapter = Figaro::Rails::Application
end
| ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/application.rb | lib/figaro/application.rb | require "erb"
require "yaml"
module Figaro
class Application
FIGARO_ENV_PREFIX = "_FIGARO_"
include Enumerable
def initialize(options = {})
@options = options.inject({}) { |m, (k, v)| m[k.to_sym] = v; m }
end
def path
@options.fetch(:path) { default_path }.to_s
end
def pat... | ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/env.rb | lib/figaro/env.rb | module Figaro
module ENV
extend self
def respond_to?(method, *)
key, punctuation = extract_key_from_method(method)
case punctuation
when "!" then has_key?(key) || super
when "?", nil then true
else super
end
end
private
def method_missing(method, *)
ke... | ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/cli.rb | lib/figaro/cli.rb | require "thor"
module Figaro
class CLI < Thor
# figaro install
desc "install", "Install Figaro"
method_option "path",
aliases: ["-p"],
default: "config/application.yml",
desc: "Specify a configuration file path"
def install
require "figaro/cli/install"
Install.start
... | ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/error.rb | lib/figaro/error.rb | module Figaro
class Error < StandardError; end
class RailsNotInitialized < Error; end
class MissingKey < Error
def initialize(key)
super("Missing required configuration key: #{key.inspect}")
end
end
class MissingKeys < Error
def initialize(keys)
super("Missing required configuration... | ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/rails/application.rb | lib/figaro/rails/application.rb | module Figaro
module Rails
class Application < Figaro::Application
private
def default_path
rails_not_initialized! unless ::Rails.root
::Rails.root.join("config", "application.yml")
end
def default_environment
::Rails.env
end
def rails_not_initialize... | ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/rails/railtie.rb | lib/figaro/rails/railtie.rb | module Figaro
module Rails
class Railtie < ::Rails::Railtie
config.before_configuration do
Figaro.load
end
end
end
end
| ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/cli/task.rb | lib/figaro/cli/task.rb | require "figaro/application"
module Figaro
class CLI < Thor
class Task
attr_reader :options
def self.run(options = {})
new(options).run
end
def initialize(options = {})
@options = options
end
private
def env
ENV.to_hash.update(configuration)
... | ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/cli/heroku_set.rb | lib/figaro/cli/heroku_set.rb | require "figaro/cli/task"
module Figaro
class CLI < Thor
class HerokuSet < Task
def run
system(env, command)
end
private
def command
"heroku config:set #{vars} #{for_app} #{for_remote}"
end
def for_app
options[:app] ? "--app=#{options[:app]}" : nil
... | ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
laserlemon/figaro | https://github.com/laserlemon/figaro/blob/a2d7dcb70c1af1e758089b7d529e0089177c5f51/lib/figaro/cli/install.rb | lib/figaro/cli/install.rb | require "thor/group"
module Figaro
class CLI < Thor
class Install < Thor::Group
include Thor::Actions
class_option "path",
aliases: ["-p"],
default: "config/application.yml",
desc: "Specify a configuration file path"
def self.source_root
File.expand_path("../in... | ruby | MIT | a2d7dcb70c1af1e758089b7d529e0089177c5f51 | 2026-01-04T15:48:55.875690Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/init.rb | init.rb | require 'state_machine'
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/test_helper.rb | test/test_helper.rb | if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start { add_filter '/test/' }
end
require 'test/unit'
require 'state_machine'
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/files/switch.rb | test/files/switch.rb | class Switch
def self.name
@name ||= "Switch_#{rand(1000000)}"
end
state_machine do
event :turn_on do
transition all => :on
end
event :turn_off do
transition all => :off
end
end
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/error_test.rb | test/unit/error_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class ErrorByDefaultTest < Test::Unit::TestCase
def setup
@machine = StateMachine::Machine.new(Class.new)
@collection = StateMachine::NodeCollection.new(@machine)
end
def test_should_not_have_any_nodes
assert_equal 0, @collection... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/helper_module_test.rb | test/unit/helper_module_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class HelperModuleTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = StateMachine::Machine.new(@klass)
@helper_module = StateMachine::HelperModule.new(@machine, :instance)
end
def test_should_not_have_a_name
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/invalid_transition_test.rb | test/unit/invalid_transition_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class InvalidTransitionTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = StateMachine::Machine.new(@klass)
@state = @machine.state :parked
@machine.event :ignite
@object = @klass.new
@object.state = 'p... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/graph_test.rb | test/unit/graph_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
begin
# Load library
require 'graphviz'
class GraphDefaultTest < Test::Unit::TestCase
def setup
@graph = StateMachine::Graph.new('test')
end
def test_should_have_a_default_font
assert_equal 'Arial', @graph.font
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/event_test.rb | test/unit/event_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class EventByDefaultTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = StateMachine::Machine.new(@klass)
@machine.events << @event = StateMachine::Event.new(@machine, :ignite)
@object = @klass.new
end
de... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/path_collection_test.rb | test/unit/path_collection_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class PathCollectionByDefaultTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = StateMachine::Machine.new(@klass)
@machine.state :parked
@object = @klass.new
@object.state = 'parked'
@paths = State... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/branch_test.rb | test/unit/branch_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class BranchTest < Test::Unit::TestCase
def setup
@branch = StateMachine::Branch.new(:from => :parked, :to => :idling)
end
def test_should_not_raise_exception_if_implicit_option_specified
assert_nothing_raised { StateMachine::Branch.... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/state_machine_test.rb | test/unit/state_machine_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class StateMachineByDefaultTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = @klass.state_machine
end
def test_should_use_state_attribute
assert_equal :state, @machine.attribute
end
end
class StateMachineTest... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/eval_helpers_test.rb | test/unit/eval_helpers_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class EvalHelpersBaseTest < Test::Unit::TestCase
include StateMachine::EvalHelpers
def default_test
end
end
class EvalHelpersTest < EvalHelpersBaseTest
def setup
@object = Object.new
end
def test_should_raise_exception_if_metho... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/path_test.rb | test/unit/path_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class PathByDefaultTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = StateMachine::Machine.new(@klass)
@object = @klass.new
@path = StateMachine::Path.new(@object, @machine)
end
def test_should_have_an_... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/assertions_test.rb | test/unit/assertions_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class AssertionsBaseTest < Test::Unit::TestCase
include StateMachine::Assertions
def default_test
end
end
class AssertValidKeysTest < AssertionsBaseTest
def test_should_not_raise_exception_if_key_is_valid
assert_nothing_raised { asser... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/invalid_parallel_transition_test.rb | test/unit/invalid_parallel_transition_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class InvalidParallelTransitionTest < Test::Unit::TestCase
def setup
@object = Object.new
@events = [:ignite, :disable_alarm]
@invalid_transition = StateMachine::InvalidParallelTransition.new(@object, @events)
end
def test_s... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/node_collection_test.rb | test/unit/node_collection_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class Node < Struct.new(:name, :value, :machine)
def context
yield
end
end
class NodeCollectionByDefaultTest < Test::Unit::TestCase
def setup
@machine = StateMachine::Machine.new(Class.new)
@collection = StateMachine::NodeCollectio... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/machine_collection_test.rb | test/unit/machine_collection_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class MachineCollectionByDefaultTest < Test::Unit::TestCase
def setup
@machines = StateMachine::MachineCollection.new
end
def test_should_not_have_any_machines
assert @machines.empty?
end
end
class MachineCollectionStateInitializa... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/callback_test.rb | test/unit/callback_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class CallbackTest < Test::Unit::TestCase
def test_should_raise_exception_if_invalid_type_specified
exception = assert_raise(ArgumentError) { StateMachine::Callback.new(:invalid) {} }
assert_equal 'Type must be :before, :after, :around, or ... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/event_collection_test.rb | test/unit/event_collection_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class EventCollectionByDefaultTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = StateMachine::Machine.new(@klass)
@events = StateMachine::EventCollection.new(@machine)
@object = @klass.new
end
def test_shoul... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/invalid_event_test.rb | test/unit/invalid_event_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class InvalidEventTest < Test::Unit::TestCase
def setup
@object = Object.new
@invalid_event = StateMachine::InvalidEvent.new(@object, :invalid)
end
def test_should_have_an_object
assert_equal @object, @invalid_event.object
end
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/state_context_test.rb | test/unit/state_context_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class Validateable
class << self
def validate(*args, &block)
args << block if block_given?
args
end
end
end
class StateContextTest < Test::Unit::TestCase
def setup
@klass = Class.new(Validateable)
@machine = StateMa... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/state_test.rb | test/unit/state_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class StateByDefaultTest < Test::Unit::TestCase
def setup
@machine = StateMachine::Machine.new(Class.new)
@machine.states << @state = StateMachine::State.new(@machine, :parked)
end
def test_should_have_a_machine
assert_equal @mac... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/machine_test.rb | test/unit/machine_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class MachineByDefaultTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = StateMachine::Machine.new(@klass)
@object = @klass.new
end
def test_should_have_an_owner_class
assert_equal @klass, @machine.owner_clas... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/integrations_test.rb | test/unit/integrations_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class IntegrationMatcherTest < Test::Unit::TestCase
def setup
superclass = Class.new
self.class.const_set('Vehicle', superclass)
@klass = Class.new(superclass)
end
def test_should_return_nil_if_no_match_found
assert_nil ... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/transition_test.rb | test/unit/transition_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class TransitionTest < Test::Unit::TestCase
def setup
@klass = Class.new
@machine = StateMachine::Machine.new(@klass)
@machine.state :parked, :idling
@machine.event :ignite
@object = @klass.new
@object.state = 'parked'
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/transition_collection_test.rb | test/unit/transition_collection_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class TransitionCollectionTest < Test::Unit::TestCase
def test_should_raise_exception_if_invalid_option_specified
exception = assert_raise(ArgumentError) {StateMachine::TransitionCollection.new([], :invalid => true)}
assert_equal 'Invalid k... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/matcher_helpers_test.rb | test/unit/matcher_helpers_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class MatcherHelpersAllTest < Test::Unit::TestCase
include StateMachine::MatcherHelpers
def setup
@matcher = all
end
def test_should_build_an_all_matcher
assert_equal StateMachine::AllMatcher.instance, @matcher
end
end
class ... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/matcher_test.rb | test/unit/matcher_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class MatcherByDefaultTest < Test::Unit::TestCase
def setup
@matcher = StateMachine::Matcher.new
end
def test_should_have_no_values
assert_equal [], @matcher.values
end
def test_should_filter_all_values
assert_equal [], @m... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/state_collection_test.rb | test/unit/state_collection_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class StateCollectionByDefaultTest < Test::Unit::TestCase
def setup
@machine = StateMachine::Machine.new(Class.new)
@states = StateMachine::StateCollection.new(@machine)
end
def test_should_not_have_any_nodes
assert_equal 0, @sta... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/integrations/active_record_test.rb | test/unit/integrations/active_record_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'active_record'
FIXTURES_ROOT = File.dirname(__FILE__) + '/../../fixtures/'
# Load TestCase helpers
require 'active_support/test_case'
require 'active_record/fixtures'
begin
require 'active_record/test_case'
rescue LoadError
class A... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/integrations/mongoid_test.rb | test/unit/integrations/mongoid_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'mongoid'
require 'mongoid/version'
# Establish database connection
Mongoid.configure do |config|
if Mongoid::VERSION =~ /^2\./
connection = Mongo::Connection.new('127.0.0.1', 27017, :slave_ok => true, :logger => Logger.new("#{File.... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/integrations/data_mapper_test.rb | test/unit/integrations/data_mapper_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'dm-core'
require 'dm-core/version' unless defined?(DataMapper::VERSION)
require 'dm-observer'
if Gem::Version.new(DataMapper::VERSION) >= Gem::Version.new('0.10.3')
require 'dm-migrations'
end
# Establish database connection
DataMappe... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/integrations/sequel_test.rb | test/unit/integrations/sequel_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'sequel'
require 'logger'
require 'stringio'
# Establish database connection
DB = Sequel.connect(RUBY_PLATFORM == 'java' ? 'jdbc:sqlite::memory:' : 'sqlite:///', :loggers => [Logger.new("#{File.dirname(__FILE__)}/../../sequel.log")])
mod... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/integrations/mongo_mapper_test.rb | test/unit/integrations/mongo_mapper_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'mongo_mapper'
# Establish database connection
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, {:logger => Logger.new("#{File.dirname(__FILE__)}/../../mongo_mapper.log"), :slave_ok => true})
MongoMapper.database = 'test... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/integrations/base_test.rb | test/unit/integrations/base_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
# Load library
require 'rubygems'
module BaseTest
class IntegrationTest < Test::Unit::TestCase
def test_should_have_an_integration_name
assert_equal :base, StateMachine::Integrations::Base.integration_name
end
def test_... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/unit/integrations/active_model_test.rb | test/unit/integrations/active_model_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'active_model'
if defined?(ActiveModel::VERSION) && ActiveModel::VERSION::MAJOR >= 4
require 'rails/observers/active_model/active_model'
require 'active_model/mass_assignment_security'
else
require 'active_model/observing'
end
requir... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/test/functional/state_machine_test.rb | test/functional/state_machine_test.rb | require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class AutoShop
attr_accessor :num_customers
def initialize
@num_customers = 0
super
end
state_machine :initial => :available do
after_transition :available => any, :do => :increment_customers
after_transition :busy => an... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/vehicle.rb | examples/vehicle.rb | require 'state_machine'
class Vehicle
state_machine :initial => :parked do
event :park do
transition [:idling, :first_gear] => :parked
end
event :ignite do
transition :stalled => same, :parked => :idling
end
event :idle do
transition :first_gear => :idling
end
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/traffic_light.rb | examples/traffic_light.rb | require 'state_machine'
class TrafficLight
state_machine :initial => :stop do
event :cycle do
transition :stop => :proceed, :proceed => :caution, :caution => :stop
end
end
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/auto_shop.rb | examples/auto_shop.rb | require 'state_machine'
class AutoShop
state_machine :initial => :available do
event :tow_vehicle do
transition :available => :busy
end
event :fix_vehicle do
transition :busy => :available
end
end
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/car.rb | examples/car.rb | require 'state_machine'
class Car < Vehicle
state_machine do
event :reverse do
transition [:parked, :idling, :first_gear] => :backing_up
end
event :park do
transition :backing_up => :parked
end
event :idle do
transition :backing_up => :idling
end
event :sh... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/rails-rest/controller.rb | examples/rails-rest/controller.rb | class UsersController < ApplicationController
# GET /users
def index
@users = User.all
end
# GET /users/1
def show
@user = User.find(params[:id])
end
# GET /users/new
def new
@user = User.new
end
# GET /users/1/edit
def edit
@user = User.find(params[:id])
end
# POST... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/rails-rest/migration.rb | examples/rails-rest/migration.rb | class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name, :state, :access_state
end
end
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/rails-rest/model.rb | examples/rails-rest/model.rb | class User < ActiveRecord::Base
validates_presence_of :name, :state, :access_state
state_machine :initial => :unregistered do
event :register do
transition :unregistered => :registered
end
event :unregister do
transition :registered => :unregistered
end
end
state_machine :... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/merb-rest/controller.rb | examples/merb-rest/controller.rb | class Users < Application
# GET /users
def index
@users = User.all
display @users
end
# GET /users/1
def show(id)
@user = User.get(id)
raise NotFound unless @user
display @user
end
# GET /users/new
def new
only_provides :html
@user = User.new
display @user
end
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/examples/merb-rest/model.rb | examples/merb-rest/model.rb | class User
include DataMapper::Resource
property :id, Serial
property :name, String
validates_present :name, :state, :access_state
state_machine :initial => :unregistered do
event :register do
transition :unregistered => :registered
end
event :unregister do
transition :re... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/yard-state_machine.rb | lib/yard-state_machine.rb | require 'state_machine/core'
require 'state_machine/yard'
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine.rb | lib/state_machine.rb | # By default, requiring "state_machine" means that both the core implementation
# *and* extensions to the Ruby core (Class in particular) will be pulled in.
#
# If you want to skip the Ruby core extensions, simply require "state_machine/core"
# and extend StateMachine::MacroMethods in your class. See the README for m... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/tasks/state_machine.rb | lib/tasks/state_machine.rb | namespace :state_machine do
desc 'Draws state machines using GraphViz (options: CLASS=User,Vehicle; FILE=user.rb,vehicle.rb [not required in Rails / Merb]; FONT=Arial; FORMAT=png; ORIENTATION=portrait; HUMAN_NAMES=true'
task :draw do
# Build drawing options
options = {}
options[:file] = ENV['FILE'] if E... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/initializers.rb | lib/state_machine/initializers.rb | # Load each application initializer
Dir["#{File.dirname(__FILE__)}/initializers/*.rb"].sort.each do |path|
require "state_machine/initializers/#{File.basename(path)}"
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/core.rb | lib/state_machine/core.rb | module StateMachine
# Graphing extensions aren't required, so they're loaded when referenced
autoload :Graph, 'state_machine/graph'
end
# Load all of the core implementation required to use state_machine. This
# includes:
# * StateMachine::MacroMethods which adds the state_machine DSL to your class
# * A set of i... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/helper_module.rb | lib/state_machine/helper_module.rb | module StateMachine
# Represents a type of module that defines instance / class methods for a
# state machine
class HelperModule < Module #:nodoc:
def initialize(machine, kind)
@machine = machine
@kind = kind
end
# Provides a human-readable description of the module
def to_s
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/path.rb | lib/state_machine/path.rb | module StateMachine
# A path represents a sequence of transitions that can be run for a particular
# object. Paths can walk to new transitions, revealing all of the possible
# branches that can be encountered in the object's state machine.
class Path < Array
include Assertions
# The object whose s... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/callback.rb | lib/state_machine/callback.rb | require 'state_machine/branch'
require 'state_machine/eval_helpers'
module StateMachine
# Callbacks represent hooks into objects that allow logic to be triggered
# before, after, or around a specific set of transitions.
class Callback
include EvalHelpers
class << self
# Determines whether to a... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/event_collection.rb | lib/state_machine/event_collection.rb | require 'state_machine/node_collection'
module StateMachine
# Represents a collection of events in a state machine
class EventCollection < NodeCollection
def initialize(machine) #:nodoc:
super(machine, :index => [:name, :qualified_name])
end
# Gets the list of events that can be fired on the... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/version.rb | lib/state_machine/version.rb | module StateMachine
VERSION = '1.2.0'
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/event.rb | lib/state_machine/event.rb | require 'state_machine/transition'
require 'state_machine/branch'
require 'state_machine/assertions'
require 'state_machine/matcher_helpers'
require 'state_machine/error'
module StateMachine
# An invalid event was specified
class InvalidEvent < Error
# The event that was attempted to be run
attr_reader :ev... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/extensions.rb | lib/state_machine/extensions.rb | require 'state_machine/machine_collection'
module StateMachine
module ClassMethods
def self.extended(base) #:nodoc:
base.class_eval do
@state_machines = MachineCollection.new
end
end
# Gets the current list of state machines defined for this class. This
# class-level attribu... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/assertions.rb | lib/state_machine/assertions.rb | module StateMachine
# Provides a set of helper methods for making assertions about the content
# of various objects
module Assertions
# Validates that the given hash *only* includes the specified valid keys.
# If any invalid keys are found, an ArgumentError will be raised.
#
# == Examples
#
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/state_context.rb | lib/state_machine/state_context.rb | require 'state_machine/assertions'
require 'state_machine/eval_helpers'
module StateMachine
# A method was called in an invalid state context
class InvalidContext < Error
end
# Represents a module which will get evaluated within the context of a state.
#
# Class-level methods are proxied to the owner c... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/core_ext.rb | lib/state_machine/core_ext.rb | # Loads all of the extensions to be made to Ruby core classes
require 'state_machine/core_ext/class/state_machine'
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/transition.rb | lib/state_machine/transition.rb | require 'state_machine/transition_collection'
require 'state_machine/error'
module StateMachine
# An invalid transition was attempted
class InvalidTransition < Error
# The machine attempting to be transitioned
attr_reader :machine
# The current state value for the machine
attr_reader :from
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/graph.rb | lib/state_machine/graph.rb | begin
require 'rubygems'
gem 'ruby-graphviz', '>=0.9.17'
require 'graphviz'
rescue LoadError => ex
$stderr.puts "Cannot draw the machine (#{ex.message}). `gem install ruby-graphviz` >= v0.9.17 and try again."
raise
end
require 'state_machine/assertions'
module StateMachine
# Provides a set of higher-order... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/eval_helpers.rb | lib/state_machine/eval_helpers.rb | module StateMachine
# Provides a set of helper methods for evaluating methods within the context
# of an object.
module EvalHelpers
# Evaluates one of several different types of methods within the context
# of the given object. Methods can be one of the following types:
# * Symbol
# * Method / Pr... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/machine_collection.rb | lib/state_machine/machine_collection.rb | require 'state_machine/assertions'
module StateMachine
# Represents a collection of state machines for a class
class MachineCollection < Hash
include Assertions
# Initializes the state of each machine in the given object. This can allow
# states to be initialized in two groups: static and dynamic... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/yard.rb | lib/state_machine/yard.rb | module StateMachine
# YARD plugin for automated documentation
module YARD
end
end
require 'state_machine/yard/handlers'
require 'state_machine/yard/templates'
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/state.rb | lib/state_machine/state.rb | require 'state_machine/assertions'
require 'state_machine/state_context'
module StateMachine
# A state defines a value that an attribute can be in after being transitioned
# 0 or more times. States can represent a value of any type in Ruby, though
# the most common (and default) type is String.
#
# In addi... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/matcher_helpers.rb | lib/state_machine/matcher_helpers.rb | module StateMachine
# Provides a set of helper methods for generating matchers
module MatcherHelpers
# Represents a state that matches all known states in a machine.
#
# == Examples
#
# class Vehicle
# state_machine do
# before_transition any => :parked, :do => lambda {...}... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/matcher.rb | lib/state_machine/matcher.rb | require 'singleton'
module StateMachine
# Provides a general strategy pattern for determining whether a match is found
# for a value. The algorithm that actually determines the match depends on
# the matcher in use.
class Matcher
# The list of values against which queries are matched
attr_reader :valu... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations.rb | lib/state_machine/integrations.rb | # Load each available integration
require 'state_machine/integrations/base'
Dir["#{File.dirname(__FILE__)}/integrations/*.rb"].sort.each do |path|
require "state_machine/integrations/#{File.basename(path)}"
end
require 'state_machine/error'
module StateMachine
# An invalid integration was specified
class Integr... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/state_collection.rb | lib/state_machine/state_collection.rb | require 'state_machine/node_collection'
module StateMachine
# Represents a collection of states in a state machine
class StateCollection < NodeCollection
def initialize(machine) #:nodoc:
super(machine, :index => [:name, :qualified_name, :value])
end
# Determines whether the given object is i... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/machine.rb | lib/state_machine/machine.rb | require 'state_machine/extensions'
require 'state_machine/assertions'
require 'state_machine/integrations'
require 'state_machine/helper_module'
require 'state_machine/state'
require 'state_machine/event'
require 'state_machine/callback'
require 'state_machine/node_collection'
require 'state_machine/state_collection'
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | true |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/transition_collection.rb | lib/state_machine/transition_collection.rb | module StateMachine
# Represents a collection of transitions in a state machine
class TransitionCollection < Array
include Assertions
# Whether to skip running the action for each transition's machine
attr_reader :skip_actions
# Whether to skip running the after callbacks
attr_reader :... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/node_collection.rb | lib/state_machine/node_collection.rb | require 'state_machine/assertions'
module StateMachine
# Represents a collection of nodes in a state machine, be it events or states.
# Nodes will not differentiate between the String and Symbol versions of the
# values being indexed.
class NodeCollection
include Enumerable
include Assertions
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/error.rb | lib/state_machine/error.rb | module StateMachine
# An error occurred during a state machine invocation
class Error < StandardError
# The object that failed
attr_reader :object
def initialize(object, message = nil) #:nodoc:
@object = object
super(message)
end
end
end
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/macro_methods.rb | lib/state_machine/macro_methods.rb | require 'state_machine/machine'
# A state machine is a model of behavior composed of states, events, and
# transitions. This helper adds support for defining this type of
# functionality on any Ruby class.
module StateMachine
module MacroMethods
# Creates a new state machine with the given name. The default na... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/branch.rb | lib/state_machine/branch.rb | require 'state_machine/matcher'
require 'state_machine/eval_helpers'
require 'state_machine/assertions'
module StateMachine
# Represents a set of requirements that must be met in order for a transition
# or callback to occur. Branches verify that the event, from state, and to
# state of the transition match, in... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/path_collection.rb | lib/state_machine/path_collection.rb | require 'state_machine/path'
module StateMachine
# Represents a collection of paths that are generated based on a set of
# requirements regarding what states to start and end on
class PathCollection < Array
include Assertions
# The object whose state machine is being walked
attr_reader :object
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/initializers/rails.rb | lib/state_machine/initializers/rails.rb | if defined?(Rails)
# Track all of the applicable locales to load
locale_paths = []
StateMachine::Integrations.all.each do |integration|
locale_paths << integration.locale_path if integration.available? && integration.locale_path
end
if defined?(Rails::Engine)
# Rails 3.x
class StateMachine::Rai... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/initializers/merb.rb | lib/state_machine/initializers/merb.rb | Merb::Plugins.add_rakefiles("#{File.dirname(__FILE__)}/../../tasks/state_machine") if defined?(Merb::Plugins)
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/active_record.rb | lib/state_machine/integrations/active_record.rb | require 'state_machine/integrations/active_model'
module StateMachine
module Integrations #:nodoc:
# Adds support for integrating state machines with ActiveRecord models.
#
# == Examples
#
# Below is an example of a simple state machine defined within an
# ActiveRecord model:
#
# ... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/active_model.rb | lib/state_machine/integrations/active_model.rb | module StateMachine
module Integrations #:nodoc:
# Adds support for integrating state machines with ActiveModel classes.
#
# == Examples
#
# If using ActiveModel directly within your class, then any one of the
# following features need to be included in order for the integration to be
# ... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/sequel.rb | lib/state_machine/integrations/sequel.rb | module StateMachine
module Integrations #:nodoc:
# Adds support for integrating state machines with Sequel models.
#
# == Examples
#
# Below is an example of a simple state machine defined within a
# Sequel model:
#
# class Vehicle < Sequel::Model
# state_machine :initial ... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/mongoid.rb | lib/state_machine/integrations/mongoid.rb | module StateMachine
module Integrations #:nodoc:
# Adds support for integrating state machines with Mongoid models.
#
# == Examples
#
# Below is an example of a simple state machine defined within a
# Mongoid model:
#
# class Vehicle
# include Mongoid::Document
#
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/base.rb | lib/state_machine/integrations/base.rb | module StateMachine
module Integrations
# Provides a set of base helpers for managing individual integrations
module Base
module ClassMethods
# The default options to use for state machines using this integration
attr_reader :defaults
# The name of the integration
... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/data_mapper.rb | lib/state_machine/integrations/data_mapper.rb | module StateMachine
module Integrations #:nodoc:
# Adds support for integrating state machines with DataMapper resources.
#
# == Examples
#
# Below is an example of a simple state machine defined within a
# DataMapper resource:
#
# class Vehicle
# include DataMapper::Resou... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/mongo_mapper.rb | lib/state_machine/integrations/mongo_mapper.rb | require 'state_machine/integrations/active_model'
module StateMachine
module Integrations #:nodoc:
# Adds support for integrating state machines with MongoMapper models.
#
# == Examples
#
# Below is an example of a simple state machine defined within a
# MongoMapper model:
#
# cl... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/mongo_mapper/locale.rb | lib/state_machine/integrations/mongo_mapper/locale.rb | filename = "#{File.dirname(__FILE__)}/../active_model/locale.rb"
translations = eval(IO.read(File.expand_path(filename)), binding, filename)
translations[:en][:mongo_mapper] = translations[:en].delete(:activemodel)
translations
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/mongo_mapper/versions.rb | lib/state_machine/integrations/mongo_mapper/versions.rb | module StateMachine
module Integrations #:nodoc:
module MongoMapper
version '0.5.x - 0.6.x' do
def self.active?
!defined?(::MongoMapper::Plugins)
end
def filter_attributes(object, attributes)
attributes
end
def define_state_initia... | ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
pluginaweek/state_machine | https://github.com/pluginaweek/state_machine/blob/8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0/lib/state_machine/integrations/mongoid/locale.rb | lib/state_machine/integrations/mongoid/locale.rb | filename = "#{File.dirname(__FILE__)}/../active_model/locale.rb"
translations = eval(IO.read(File.expand_path(filename)), binding, filename)
translations[:en][:mongoid] = translations[:en].delete(:activemodel)
translations
| ruby | MIT | 8a3ba81801782ac4ef9d4ace1209d8d50ffccdb0 | 2026-01-04T15:48:58.823225Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.