stator 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79f3afdff7482b4d1cb783a7bdee4941e78bb3c8
4
- data.tar.gz: 1015c2937be4daef19f9c270f8f5e20a47539232
3
+ metadata.gz: bd69f892293770471063f818138639b932e78120
4
+ data.tar.gz: 8f0f90685de79f5fd2d29e9170dc25a8c82bc6bb
5
5
  SHA512:
6
- metadata.gz: 6f1ebc9d9eecf8af87e94d778dd4eb23f146d772d91d9f4e09739c0927225e2ce15a0026fe6b05d425bbb5ccd3babf0b38604279f787951bb312fcd216d181e2
7
- data.tar.gz: 055f13839c226f3542bd72da2a8683c9a03ee540cfb31206d6ec3b0b4357f698ba8407d1b76418393767f59efd945abc4dc272895b54b6452405f4a97620b304
6
+ metadata.gz: e167050e139b82a6d1004739881e42a90dc711f0465d23823475876bf05254ecb0157e41b4038ae82e2779dcb102df5d334750d86da6da367ca78e237b4a0b40
7
+ data.tar.gz: 8e5346d2586207932a1bdddff88d828953c2ffaebca9a98861845a2fde0b95a7b0a7b2d0c0f2a534c4b85db960534cd3cea14139ff10a1a41323056e6d3ecb3b
data/.travis.yml CHANGED
@@ -4,12 +4,38 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.6
6
6
  - 2.2.3
7
+ - 2.4.5
8
+ - 2.5.3
7
9
 
8
10
  gemfile:
9
11
  - gemfiles/ar40.gemfile
10
12
  - gemfiles/ar41.gemfile
11
13
  - gemfiles/ar42.gemfile
14
+ - gemfiles/ar52.gemfile
12
15
 
13
16
  matrix:
14
17
  allow_failures:
15
18
  - gemfile: gemfiles/ar42.gemfile
19
+ - gemfile: gemfiles/ar52.gemfile
20
+
21
+ exclude:
22
+ - rvm: 2.0.0
23
+ gemfile: gemfiles/ar52.gemfile
24
+
25
+ - rvm: 2.1.6
26
+ gemfile: gemfiles/ar52.gemfile
27
+
28
+ - rvm: 2.2.3
29
+ gemfile: gemfiles/ar52.gemfile
30
+
31
+ - rvm: 2.4.5
32
+ gemfile: gemfiles/ar40.gemfile
33
+
34
+ - rvm: 2.4.5
35
+ gemfile: gemfiles/ar41.gemfile
36
+
37
+ - rvm: 2.5.3
38
+ gemfile: gemfiles/ar40.gemfile
39
+
40
+ - rvm: 2.5.3
41
+ gemfile: gemfiles/ar41.gemfile
data/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in stator.gemspec
4
- gem 'activerecord', '4.0.0'
4
+ gem 'activerecord', '5.2.3'
5
5
 
6
6
  gemspec
7
7
 
8
8
  gem 'rake'
9
- gem 'activerecord-nulldb-adapter', :require => false, :git => 'git@github.com:nulldb/nulldb.git', :ref => 'ffc7dae4697c6b9fb15bed9edca3acb1f00eb5f0'
9
+ gem 'activerecord-nulldb-adapter', '~> 0.4.0', :require => false, :git => 'git@github.com:nulldb/nulldb.git'
10
10
  gem 'rspec'
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in stator.gemspec
4
- gem 'activerecord', '~> 4.2.0'
4
+ gem 'activerecord', '~> 4.0.0'
5
5
 
6
6
  gemspec :path => '../'
7
7
 
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stator.gemspec
4
+ gem 'activerecord', '~> 5.2.0'
5
+
6
+ gemspec :path => '../'
7
+
8
+ gem 'rake'
9
+ gem 'activerecord-nulldb-adapter', '~> 0.4.0', :require => false, :git => 'git@github.com:nulldb/nulldb.git'
10
+ gem 'rspec'
@@ -67,7 +67,9 @@ module Stator
67
67
  end
68
68
 
69
69
  def conditional(*states, &block)
70
- klass.instance_exec("#{states.map(&:to_s).inspect}.include?(self._stator(#{@namespace.inspect}).integration(self).state)", &block)
70
+ _namespace = @namespace
71
+
72
+ klass.instance_exec(proc { states.map(&:to_s).include?(self._stator(_namespace).integration(self).state) }, &block)
71
73
  end
72
74
 
73
75
  def matching_transition(from, to)
@@ -42,7 +42,7 @@ module Stator
42
42
  end
43
43
 
44
44
  def conditional(options = {}, &block)
45
- klass.instance_exec(conditional_string(options), &block)
45
+ klass.instance_exec(conditional_block(options), &block)
46
46
  end
47
47
 
48
48
  def any
@@ -63,19 +63,24 @@ module Stator
63
63
  @callbacks[kind] || []
64
64
  end
65
65
 
66
- def conditional_string(options = {})
66
+ def conditional_block(options = {})
67
67
  options[:use_previous] ||= false
68
- %Q{
69
- (
70
- self._stator(#{@namespace.inspect}).integration(self).state_changed?(#{options[:use_previous].inspect})
71
- ) && (
72
- #{@froms.inspect}.include?(self._stator(#{@namespace.inspect}).integration(self).state_was(#{options[:use_previous].inspect})) ||
73
- #{@froms.inspect}.include?(::Stator::Transition::ANY)
74
- ) && (
75
- self._stator(#{@namespace.inspect}).integration(self).state == #{@to.inspect} ||
76
- #{@to.inspect} == ::Stator::Transition::ANY
77
- )
78
- }
68
+
69
+ _namespace = @namespace
70
+ _froms = @froms
71
+ _to = @to
72
+
73
+ Proc.new do
74
+ (
75
+ self._stator(_namespace).integration(self).state_changed?(options[:use_previous])
76
+ ) && (
77
+ _froms.include?(self._stator(_namespace).integration(self).state_was(options[:use_previous])) ||
78
+ _froms.include?(::Stator::Transition::ANY)
79
+ ) && (
80
+ self._stator(_namespace).integration(self).state == _to ||
81
+ _to == ::Stator::Transition::ANY
82
+ )
83
+ end
79
84
  end
80
85
 
81
86
  def generate_methods
@@ -1,7 +1,7 @@
1
1
  module Stator
2
2
  MAJOR = 0
3
- MINOR = 2
4
- PATCH = 2
3
+ MINOR = 3
4
+ PATCH = 0
5
5
  PRERELEASE = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, PATCH, PRERELEASE].compact.join('.')
data/spec/model_spec.rb CHANGED
@@ -36,7 +36,9 @@ describe Stator::Model do
36
36
 
37
37
  it 'should ensure a valid state transition when given an illegal state based on the current state' do
38
38
  u = User.new
39
- u.stub(:new_record?).and_return(false)
39
+
40
+ allow(u).to receive(:new_record?).and_return(false)
41
+
40
42
  u.state = 'hyperactivated'
41
43
 
42
44
  u.should_not be_valid
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,7 @@ require 'stator'
12
12
 
13
13
  RSpec.configure do |config|
14
14
  config.treat_symbols_as_metadata_keys_with_true_values = true
15
+ config.expect_with(:rspec) { |c| c.syntax = :should }
15
16
  config.run_all_when_everything_filtered = true
16
17
  config.filter_run :focus
17
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-06 00:00:00.000000000 Z
11
+ date: 2019-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -44,6 +44,7 @@ files:
44
44
  - gemfiles/ar40.gemfile
45
45
  - gemfiles/ar41.gemfile
46
46
  - gemfiles/ar42.gemfile
47
+ - gemfiles/ar52.gemfile
47
48
  - lib/stator.rb
48
49
  - lib/stator/alias.rb
49
50
  - lib/stator/integration.rb