grand_central 0.2.0 → 0.2.1

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: 6b45f78ea1757bbbbc1c82b7af2160fddeb6a553
4
- data.tar.gz: e277a7ae9bab10b26b8491243400929563dfae47
3
+ metadata.gz: db799a36024cf51a5bb7f773c960004e73e46f14
4
+ data.tar.gz: 834c42bf7db774cd5e0f5a98ae401875d82cb71f
5
5
  SHA512:
6
- metadata.gz: 335b2ef9e6eeb2d0f783aa506cfe4af029051f7b7c9a0216c7ee0c8b656caac985c07e64826e521b821c7facae8064984fc2a12fe991c05d04f8c77f8c4f8304
7
- data.tar.gz: 717c93ab776b1903f8e16d69666bfc4038a431dbcd1fa9cf381bf20bb22ad83bea394c8e8c0bd97c51669d9d0e5cbf0b2a982fdfff635798ddeed920ddda4bb9
6
+ metadata.gz: c4f09955fcecc0f4df052ecb182867995f6f3cd0b1998c4e743f32041a8b83083717261fac6cb4ac3f0f3bdb2daf293a421a471ea2b1950c7612f5a57efea097
7
+ data.tar.gz: b86b2ef1799904b35ead134b2100dbbcd2167800addcec339b442c8812f52236cf9ccf50fcba3f914e870f2f40ecfe0d360e50765161ead5c4fcfd875f43eb18
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_runtime_dependency "opal", "~> 0.7"
21
20
  spec.add_development_dependency "bundler", "~> 1.10"
22
21
  spec.add_development_dependency "rake", "~> 10.0"
23
22
  spec.add_development_dependency "rspec"
data/lib/grand_central.rb CHANGED
@@ -6,6 +6,10 @@ module GrandCentral
6
6
  end
7
7
 
8
8
  if RUBY_ENGINE != 'opal'
9
- require "opal"
10
- Opal.append_path File.expand_path('..', __FILE__)
9
+ # Autodetect Opal
10
+ begin
11
+ require "opal"
12
+ Opal.append_path File.expand_path('..', __FILE__)
13
+ rescue LoadError => e
14
+ end
11
15
  end
@@ -25,7 +25,7 @@ module GrandCentral
25
25
  promise.fail &block
26
26
  end
27
27
 
28
- def always
28
+ def always &block
29
29
  promise.always &block
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module GrandCentral
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -2,22 +2,33 @@ require 'grand_central/store'
2
2
 
3
3
  module GrandCentral
4
4
  class VersionedStore < Store
5
+ attr_reader :current_version
6
+
5
7
  def initialize *args
6
8
  super
9
+
10
+ @current_version = 0
7
11
  @rollback_versions = []
8
12
  @redo_versions = []
9
13
  end
10
14
 
11
15
  def dispatch *args
12
- @rollback_versions << state
16
+ old_state = state
17
+
18
+ result = super
19
+
20
+ @rollback_versions << old_state
13
21
  @redo_versions.clear
14
- super
22
+ @current_version += 1
23
+
24
+ result
15
25
  end
16
26
 
17
27
  def rollback
18
28
  unless @rollback_versions.empty?
19
29
  @redo_versions << (old_state = state)
20
30
  @state = @rollback_versions.pop
31
+ @current_version -= 1
21
32
  end
22
33
 
23
34
  run_callbacks old_state, state
@@ -27,9 +38,27 @@ module GrandCentral
27
38
  unless @redo_versions.empty?
28
39
  @rollback_versions << (old_state = state)
29
40
  @state = @redo_versions.pop
41
+ @current_version += 1
30
42
  end
31
43
 
32
44
  run_callbacks old_state, state
33
45
  end
46
+
47
+ def total_versions
48
+ @rollback_versions.size + @redo_versions.size + 1
49
+ end
50
+
51
+ def go_to_version version
52
+ while version > current_version
53
+ self.redo
54
+ end
55
+ while version < current_version
56
+ rollback
57
+ end
58
+ end
59
+
60
+ def commit!
61
+ initialize state
62
+ end
34
63
  end
35
64
  end
metadata CHANGED
@@ -1,69 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grand_central
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Gaskins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: opal
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '0.7'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '0.7'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - ~>
17
+ - - "~>"
32
18
  - !ruby/object:Gem::Version
33
19
  version: '1.10'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - ~>
24
+ - - "~>"
39
25
  - !ruby/object:Gem::Version
40
26
  version: '1.10'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ~>
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
33
  version: '10.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ~>
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
40
  version: '10.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - '>='
45
+ - - ">="
60
46
  - !ruby/object:Gem::Version
61
47
  version: '0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - '>='
52
+ - - ">="
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  description:
@@ -73,9 +59,9 @@ executables: []
73
59
  extensions: []
74
60
  extra_rdoc_files: []
75
61
  files:
76
- - .gitignore
77
- - .rspec
78
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
79
65
  - CODE_OF_CONDUCT.md
80
66
  - Gemfile
81
67
  - README.md
@@ -97,17 +83,17 @@ require_paths:
97
83
  - lib
98
84
  required_ruby_version: !ruby/object:Gem::Requirement
99
85
  requirements:
100
- - - '>='
86
+ - - ">="
101
87
  - !ruby/object:Gem::Version
102
88
  version: '0'
103
89
  required_rubygems_version: !ruby/object:Gem::Requirement
104
90
  requirements:
105
- - - '>='
91
+ - - ">="
106
92
  - !ruby/object:Gem::Version
107
93
  version: '0'
108
94
  requirements: []
109
95
  rubyforge_project:
110
- rubygems_version: 2.0.14
96
+ rubygems_version: 2.4.5.1
111
97
  signing_key:
112
98
  specification_version: 4
113
99
  summary: State and action management for Opal apps