pakyow-ui 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/pakyow-ui/CHANGELOG.md +16 -0
  3. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/base.rb +0 -9
  4. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/channel_builder.rb +3 -2
  5. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/config.rb +4 -6
  6. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/ext/app.rb +2 -0
  7. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/ext/view_context.rb +0 -0
  8. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/fetch_view_handler.rb +6 -5
  9. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/helpers.rb +5 -1
  10. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/mock_mutation_eval.rb +0 -0
  11. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/mutable.rb +0 -0
  12. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/mutable_data.rb +0 -0
  13. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/mutate_context.rb +2 -17
  14. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/mutation_set.rb +0 -0
  15. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/mutation_store.rb +14 -3
  16. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/mutator.rb +2 -2
  17. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/no_op_view.rb +0 -0
  18. data/pakyow-ui/lib/pakyow/ui/registries/redis_mutation_registry.rb +70 -0
  19. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/registries/simple_mutation_registry.rb +8 -2
  20. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/ui.rb +11 -13
  21. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/ui_attrs.rb +0 -0
  22. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/ui_component.rb +0 -0
  23. data/pakyow-ui/lib/pakyow/ui/ui_context.rb +16 -0
  24. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/ui_instructable.rb +7 -2
  25. data/pakyow-ui/lib/pakyow/ui/ui_request.rb +14 -0
  26. data/pakyow-ui/lib/{pakyow-ui → pakyow/ui}/ui_view.rb +29 -8
  27. data/pakyow-ui/lib/pakyow/ui.rb +1 -0
  28. data/pakyow-ui/lib/pakyow-ui.rb +1 -1
  29. metadata +36 -35
  30. data/pakyow-ui/lib/pakyow-ui/ext/app_context.rb +0 -5
  31. data/pakyow-ui/lib/pakyow-ui/registries/redis_mutation_registry.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24471e00560aac034fdda11129454a02e0ff3ce2
4
- data.tar.gz: feb95285832ddf7dfa155ca8a479e7be1166f05b
3
+ metadata.gz: 24196ce0d24c1cadd2de47cf134537493f743080
4
+ data.tar.gz: 3507e7ff24e9590d2a02eec6282003f266f8d95a
5
5
  SHA512:
6
- metadata.gz: 4f0d64184b3e515dd386d13cf82cfabec6d01f9de958add8db93c65322241512a280e12dbd23b4b7151e1413710982451b0ed281e0bc974e7071e03df822a7ba
7
- data.tar.gz: e014ce22b9ec56f71b1fc8efd37dbecb9ceb5eca301bd30d273f247fcc1b28793b13b69a7260179d9904fb87b4bebc89f9a1e7dc3658131bbf3d3f524844a3fd
6
+ metadata.gz: 1402d439bf007d90320dfc4e9d9dc0ac4991b6b0c9a446ea5c25f5c6f644c546319b786c0f97d05784d1ada9fa28cfc777bdc7e19a49f4de4bca48e852c86063
7
+ data.tar.gz: 01461b40f22477c6d65f310f63d4b2c15c4cc86a8612f1e79f47d968d2cb511e2502c5ef676c5cc0a2638cdb69574eb8fc03ef4293b6bb121a92830ac10b3cb4
@@ -1,3 +1,19 @@
1
+ # 0.11.0
2
+
3
+ * Mutators are now evaluated in a proper app context
4
+ * Helper methods can now be called inside of a mutator
5
+ * Sessions are now stored with mutations and available when the mutation is invoked after a state change
6
+ * Registered mutations are now unregistered when the WebSocket shuts down
7
+ * Qualification values are now typecasted to strings before comparison
8
+ * Removes code that inserts a node when subscribing an empty view
9
+ * Automatically returns the mutated view from the mutation
10
+ * Adds support for view versioning
11
+ * Allows mutables and mutations to have different scopes
12
+ * Moves everything into the Pakyow namespace
13
+ * Now sets `pakyow.socket` on request env when fetching view
14
+ * Fixes a bug determining qualifiers with non-array data
15
+ * No longer registers mutations registered on a socket request
16
+
1
17
  # 0.10.0 / 2015-10-19
2
18
 
3
19
  * Initial release
@@ -15,7 +15,6 @@ require_relative 'ui_component'
15
15
  require_relative 'ui_instructable'
16
16
 
17
17
  require_relative 'ext/app'
18
- require_relative 'ext/app_context'
19
18
  require_relative 'ext/view_context'
20
19
 
21
20
  Pakyow::App.before :init do
@@ -25,11 +24,3 @@ end
25
24
  Pakyow::App.after :load do
26
25
  @ui.load(mutators, mutables)
27
26
  end
28
-
29
- Pakyow::App.before :route do
30
- # setup a new ui context to work in
31
- #
32
- ui_dup = @ui.dup
33
- ui_dup.context = self
34
- @context.ui = ui_dup
35
- end
@@ -34,12 +34,13 @@ module Pakyow
34
34
  qualifiers = Array.ensure(qualifiers)
35
35
 
36
36
  data = data.data if data.is_a?(Pakyow::UI::MutableData)
37
+ data = Array.ensure(data)
37
38
  return if qualifiers.empty? || data.empty?
38
39
 
39
- datum = Array.ensure(data).first
40
+ datum = data.first
40
41
 
41
42
  qualifiers.each do |qualifier|
42
- channel_extras << "#{qualifier}:#{datum[qualifier]}"
43
+ channel_extras << "#{qualifier}:#{datum[qualifier.to_sym]}"
43
44
  end
44
45
  end
45
46
 
@@ -1,13 +1,11 @@
1
1
  require_relative 'registries/simple_mutation_registry'
2
2
  require_relative 'registries/redis_mutation_registry'
3
3
 
4
- Pakyow::Config.register(:ui) { |config|
4
+ Pakyow::Config.register :ui do |config|
5
5
  # The registry to use when keeping up with connections.
6
6
  config.opt :registry, Pakyow::UI::SimpleMutationRegistry
7
- }.env(:development) { |opts|
7
+ end.env :development do |opts|
8
8
  opts.registry = Pakyow::UI::SimpleMutationRegistry
9
- }.env(:staging) { |opts|
9
+ end.env :production do |opts|
10
10
  opts.registry = Pakyow::UI::RedisMutationRegistry
11
- }.env(:production) { |opts|
12
- opts.registry = Pakyow::UI::RedisMutationRegistry
13
- }
11
+ end
@@ -1,5 +1,7 @@
1
1
  module Pakyow
2
2
  class App
3
+ attr_reader :ui
4
+
3
5
  class << self
4
6
  # Defines mutators for a scope.
5
7
  #
@@ -20,22 +20,23 @@ require_relative 'no_op_view'
20
20
  #
21
21
  Pakyow::Realtime.handler :'fetch-view' do |message, session, response|
22
22
  env = Rack::MockRequest.env_for(message['uri'])
23
+ env['pakyow.socket'] = true
23
24
  env['rack.session'] = session
24
25
 
25
- app = Pakyow.app.dup
26
+ context = Pakyow::CallContext.new(env)
26
27
 
27
- def app.view
28
+ def context.view
28
29
  Pakyow::Presenter::NoOpView.new(
29
30
  Pakyow::Presenter::ViewContext.new(@presenter.view, self),
30
31
  self
31
32
  )
32
33
  end
33
34
 
34
- app_response = app.process(env)
35
+ app_response = context.process.finish
35
36
 
36
37
  body = ''
37
38
  lookup = message['lookup']
38
- view = app.presenter.view
39
+ view = context.presenter.view
39
40
 
40
41
  channel = lookup['channel']
41
42
 
@@ -54,7 +55,7 @@ Pakyow::Realtime.handler :'fetch-view' do |message, session, response|
54
55
  end
55
56
 
56
57
  if view.is_a?(Pakyow::Presenter::ViewVersion)
57
- body = view.use(lookup['version'] || :default).to_html
58
+ body = view.use((lookup['version'] || :default).to_sym).to_html
58
59
  else
59
60
  body = view.to_html
60
61
  end
@@ -1,7 +1,11 @@
1
1
  module Pakyow
2
2
  module Helpers
3
3
  def ui
4
- context.ui
4
+ return @ui unless @ui.nil?
5
+
6
+ ui_dup = Pakyow.app.ui.dup
7
+ ui_dup.context = self
8
+ @ui = ui_dup
5
9
  end
6
10
 
7
11
  def data(scope)
File without changes
@@ -35,8 +35,8 @@ module Pakyow
35
35
  #
36
36
  # @api public
37
37
  def subscribe(qualifications = {})
38
- if data.is_a?(MutableData)
39
- MutationStore.instance.register(self, data, qualifications)
38
+ if data.is_a?(MutableData) && !view.context.request.env['pakyow.socket']
39
+ MutationStore.instance.register(self, view, data, qualifications, view.context.request.session)
40
40
  end
41
41
 
42
42
  channel = ChannelBuilder.build(
@@ -57,21 +57,6 @@ module Pakyow
57
57
  working_view = view
58
58
  end
59
59
 
60
- if working_view.is_a?(Presenter::ViewCollection)
61
- # NOTE there's a special case here where if the collection is
62
- # empty we insert an empty element in its place; this makes
63
- # it possible to know what the data should be applied to when
64
- # a mutation occurs in the future
65
-
66
- unless working_view.exists?
67
- # TODO: would rather this be an html comment, but they aren't
68
- # supported by query selectors; need to finalize how we will
69
- # handle this particular edge case
70
- working_view.first.doc.append('<span data-channel="' + channel + '" data-version="empty"></span>')
71
- return
72
- end
73
- end
74
-
75
60
  working_view.attrs.send(:'data-channel=', channel)
76
61
  end
77
62
  end
@@ -10,21 +10,32 @@ module Pakyow
10
10
  @registry = Config.ui.registry.instance
11
11
  end
12
12
 
13
- def register(mutate_context, mutable_data, qualifications)
14
- # TODO: decide how we'll clean these up as clients disconnect
13
+ def register(mutate_context, view, mutable_data, qualifications, session)
15
14
  @registry.register(
16
15
  mutable_data.scope,
16
+
17
+ view_scope: view.scoped_as,
17
18
  mutation: mutate_context.mutation[:name],
18
19
  qualifiers: mutate_context.mutation[:qualifiers],
19
20
  qualifications: qualifications,
20
21
  query_name: mutable_data.query_name,
21
- query_args: mutable_data.query_args
22
+ query_args: mutable_data.query_args,
23
+ session: session.to_h,
24
+ socket_key: mutate_context.view.context.socket_digest(mutate_context.view.context.socket_connection_id)
22
25
  )
23
26
  end
24
27
 
28
+ def unregister(socket_key)
29
+ @registry.unregister(socket_key)
30
+ end
31
+
25
32
  def mutations(scope)
26
33
  @registry.mutations(scope) || []
27
34
  end
28
35
  end
29
36
  end
30
37
  end
38
+
39
+ Pakyow::Realtime::Websocket.on :leave do
40
+ Pakyow::UI::MutationStore.instance.unregister(socket_digest(socket_connection_id))
41
+ end
@@ -54,8 +54,8 @@ module Pakyow
54
54
  working_data = data
55
55
  end
56
56
 
57
- result = mutation[:fn].call(view, working_data)
58
- MutateContext.new(mutation, result, data)
57
+ view.instance_exec(view, working_data, &mutation[:fn])
58
+ MutateContext.new(mutation, view, data)
59
59
  end
60
60
  end
61
61
  end
@@ -0,0 +1,70 @@
1
+ require 'json'
2
+
3
+ module Pakyow
4
+ module UI
5
+ # Manages mutations.
6
+ #
7
+ # This is the default registry in production systems and is required in
8
+ # deployments with more than one app instance.
9
+ #
10
+ # @api private
11
+ class RedisMutationRegistry
12
+ include Singleton
13
+
14
+ def initialize
15
+ end
16
+
17
+ def register(scope, mutation)
18
+ Pakyow::Realtime.redis.sadd(key(scope: scope, socket_key: mutation[:socket_key]), mutation.to_json)
19
+ end
20
+
21
+ def mutations(scope)
22
+ mutations = []
23
+
24
+ keys(key(scope: scope)) do |key|
25
+ Pakyow::Realtime.redis.smembers(key).each do |m|
26
+ mutations << Hash.strhash(JSON.parse(m))
27
+ end
28
+ end
29
+
30
+ mutations
31
+ end
32
+
33
+ def unregister(socket_key)
34
+ keys(key(socket_key: socket_key)) do |key|
35
+ Pakyow::Realtime.redis.del(key)
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def key(scope: nil, socket_key: nil)
42
+ if socket_key.nil?
43
+ base = "*:"
44
+ else
45
+ base = "#{socket_key}:"
46
+ end
47
+
48
+ if scope.nil?
49
+ "#{base}*"
50
+ else
51
+ "#{base}pui-mutation-#{scope}"
52
+ end
53
+ end
54
+
55
+ def keys(match)
56
+ cursor = 0
57
+
58
+ loop do
59
+ cursor, keys = Pakyow::Realtime.redis.scan(cursor, match: match)
60
+
61
+ keys.each do |key|
62
+ yield key
63
+ end
64
+
65
+ break if cursor == '0'
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -18,11 +18,17 @@ module Pakyow
18
18
 
19
19
  def register(scope, mutation)
20
20
  @mutations[scope] ||= []
21
-
22
- return if @mutations[scope].include?(mutation)
23
21
  @mutations[scope] << mutation
24
22
  end
25
23
 
24
+ def unregister(socket_key)
25
+ @mutations.each do |_, mutations|
26
+ mutations.delete_if { |mutation|
27
+ mutation[:socket_key] == socket_key
28
+ }
29
+ end
30
+ end
31
+
26
32
  def mutations(scope)
27
33
  @mutations[scope]
28
34
  end
@@ -19,14 +19,14 @@ module Pakyow
19
19
  context ||= @context
20
20
 
21
21
  MutationStore.instance.mutations(scope).each do |mutation|
22
- view = UIView.new(scope)
22
+ view = UIView.new(mutation[:view_scope], mutation[:session])
23
23
 
24
24
  qualified = true
25
25
 
26
26
  # qualifiers are defined with the mutation
27
27
  unless mutation[:qualifiers].empty? || data.nil?
28
28
  mutation[:qualifiers].each_with_index do |qualifier, i|
29
- qualified = false unless data[qualifier] == mutation[:query_args][i]
29
+ qualified = false unless data[qualifier.to_sym].to_s == mutation[:query_args][i].to_s
30
30
  end
31
31
  end
32
32
 
@@ -35,7 +35,7 @@ module Pakyow
35
35
  # qualifications are set on the subscription
36
36
  unless !qualified || mutation[:qualifications].empty? || data.nil?
37
37
  mutation[:qualifications].each_pair do |key, value|
38
- qualified = false unless data[key.to_sym] == value
38
+ qualified = false if data[key.to_sym].to_s != value.to_s
39
39
  end
40
40
  end
41
41
 
@@ -44,17 +44,15 @@ module Pakyow
44
44
  mutable_data = Mutator.instance.mutable(scope, context).send(mutation[:query_name], *mutation[:query_args]).data
45
45
  Mutator.instance.mutate(mutation[:mutation].to_sym, view, mutable_data)
46
46
 
47
- Pakyow.app.socket.push(
48
- view.finalize,
49
-
50
- ChannelBuilder.build(
51
- scope: scope,
52
- mutation: mutation[:mutation].to_sym,
53
- qualifiers: mutation[:qualifiers],
54
- data: mutable_data,
55
- qualifications: mutation[:qualifications]
56
- )
47
+ channel = ChannelBuilder.build(
48
+ scope: mutation[:view_scope],
49
+ mutation: mutation[:mutation].to_sym,
50
+ qualifiers: mutation[:qualifiers],
51
+ data: mutable_data,
52
+ qualifications: mutation[:qualifications]
57
53
  )
54
+
55
+ Pakyow.app.socket.push_message_to_socket_with_key(view.finalize, channel, mutation[:socket_key])
58
56
  end
59
57
  end
60
58
 
File without changes
@@ -0,0 +1,16 @@
1
+ module Pakyow
2
+ module UI
3
+ # A simple context object used for accessing the session.
4
+ #
5
+ # @api private
6
+ class UIContext
7
+ def initialize(session)
8
+ @session = session
9
+ end
10
+
11
+ def request
12
+ UIRequest.new(@session)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -58,7 +58,7 @@ module Pakyow
58
58
 
59
59
  def mixin_bindings(data, bindings = {})
60
60
  data.map { |bindable|
61
- datum = bindable.to_hash
61
+ datum = bindable.to_hash.dup
62
62
  Pakyow::Presenter::Binder.instance.bindings_for_scope(scoped_as, bindings).keys.each do |key|
63
63
  result = Pakyow::Presenter::Binder.instance.value_for_scoped_prop(scoped_as, key, bindable, bindings, self)
64
64
 
@@ -67,8 +67,13 @@ module Pakyow
67
67
  # TODO: look into what it would take to support this
68
68
  result.delete(:view)
69
69
 
70
+ content = result.delete(:content)
71
+ if content.respond_to?(:to_proc)
72
+ content = content.to_proc.call()
73
+ end
74
+
70
75
  datum[key] = {
71
- __content: result.delete(:content),
76
+ __content: content,
72
77
  __attrs: Hash[*result.flat_map { |k, v|
73
78
  if v.respond_to?(:to_proc)
74
79
  attrs = UIAttrs.new
@@ -0,0 +1,14 @@
1
+ module Pakyow
2
+ module UI
3
+ # A simple request object used for accessing the session.
4
+ #
5
+ # @api private
6
+ class UIRequest
7
+ attr_reader :session
8
+
9
+ def initialize(session)
10
+ @session = Hash.strhash(session)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,7 @@
1
1
  require_relative 'ui_attrs'
2
2
  require_relative 'ui_instructable'
3
+ require_relative 'ui_context'
4
+ require_relative 'ui_request'
3
5
 
4
6
  module Pakyow
5
7
  module UI
@@ -8,14 +10,17 @@ module Pakyow
8
10
  # @api private
9
11
  class UIView
10
12
  include Instructable
13
+ include Pakyow::Helpers
11
14
 
12
- def initialize(scope)
15
+ def initialize(scope, session = {})
13
16
  super()
14
- @scope = scope
17
+ @scope = scope.to_sym
18
+ @session = session
19
+ @context = UIContext.new(session)
15
20
  end
16
21
 
17
22
  def nested_instruct_object(_method, _data, scope)
18
- UIView.new(scope || @scope)
23
+ UIView.new(scope || @scope, @session)
19
24
  end
20
25
 
21
26
  def scoped_as
@@ -50,6 +55,7 @@ module Pakyow
50
55
  after
51
56
  before
52
57
  replace
58
+ use
53
59
  ).each do |method|
54
60
  define_method method do |value|
55
61
  instruct(method, value.to_s)
@@ -93,6 +99,23 @@ module Pakyow
93
99
 
94
100
  ### view methods that continue into a new context
95
101
 
102
+ def version(data, &block)
103
+ nested = nested_instruct(:version, data)
104
+ Array.ensure(data).each do |datum|
105
+ sub = UIView.new(@scope)
106
+
107
+ if block.arity == 1
108
+ sub.instance_exec(datum, &block)
109
+ else
110
+ block.call(sub, datum)
111
+ end
112
+
113
+ nested.instructions << sub.finalize
114
+ end
115
+
116
+ self
117
+ end
118
+
96
119
  def for(data, &block)
97
120
  nested = nested_instruct(:for, data)
98
121
  Array.ensure(data).each do |datum|
@@ -134,8 +157,7 @@ module Pakyow
134
157
  def bind(data, bindings: {}, context: nil, &block)
135
158
  # TODO: handle context?
136
159
 
137
- data = mixin_bindings(Array.ensure(data), bindings)
138
- nested = nested_instruct(:bind, data)
160
+ nested = nested_instruct(:bind, mixin_bindings(Array.ensure(data), bindings))
139
161
  return self unless block_given?
140
162
 
141
163
  data.each do |datum|
@@ -158,12 +180,11 @@ module Pakyow
158
180
  def apply(data, bindings: {}, context: nil, &block)
159
181
  # TODO: handle context?
160
182
 
161
- data = mixin_bindings(Array.ensure(data), bindings)
162
- nested = nested_instruct(:apply, data)
183
+ nested = nested_instruct(:apply, mixin_bindings(Array.ensure(data), bindings))
163
184
  return self unless block_given?
164
185
 
165
186
  data.each do |datum|
166
- sub = UIView.new(@scope)
187
+ sub = UIView.new(@scope, @session)
167
188
 
168
189
  if block.arity == 1
169
190
  sub.instance_exec(datum, &block)
@@ -0,0 +1 @@
1
+ require 'pakyow/ui/base'
@@ -1 +1 @@
1
- require_relative 'pakyow-ui/base'
1
+ require 'pakyow/ui'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakyow-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-16 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pakyow-support
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.2
19
+ version: 0.11.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.2
26
+ version: 0.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pakyow-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.10.2
33
+ version: 0.11.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.10.2
40
+ version: 0.11.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pakyow-presenter
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.10.2
47
+ version: 0.11.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.10.2
54
+ version: 0.11.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pakyow-realtime
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.10.2
61
+ version: 0.11.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.10.2
68
+ version: 0.11.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -104,29 +104,31 @@ files:
104
104
  - pakyow-ui/LICENSE
105
105
  - pakyow-ui/README.md
106
106
  - pakyow-ui/lib/pakyow-ui.rb
107
- - pakyow-ui/lib/pakyow-ui/base.rb
108
- - pakyow-ui/lib/pakyow-ui/channel_builder.rb
109
- - pakyow-ui/lib/pakyow-ui/config.rb
110
- - pakyow-ui/lib/pakyow-ui/ext/app.rb
111
- - pakyow-ui/lib/pakyow-ui/ext/app_context.rb
112
- - pakyow-ui/lib/pakyow-ui/ext/view_context.rb
113
- - pakyow-ui/lib/pakyow-ui/fetch_view_handler.rb
114
- - pakyow-ui/lib/pakyow-ui/helpers.rb
115
- - pakyow-ui/lib/pakyow-ui/mock_mutation_eval.rb
116
- - pakyow-ui/lib/pakyow-ui/mutable.rb
117
- - pakyow-ui/lib/pakyow-ui/mutable_data.rb
118
- - pakyow-ui/lib/pakyow-ui/mutate_context.rb
119
- - pakyow-ui/lib/pakyow-ui/mutation_set.rb
120
- - pakyow-ui/lib/pakyow-ui/mutation_store.rb
121
- - pakyow-ui/lib/pakyow-ui/mutator.rb
122
- - pakyow-ui/lib/pakyow-ui/no_op_view.rb
123
- - pakyow-ui/lib/pakyow-ui/registries/redis_mutation_registry.rb
124
- - pakyow-ui/lib/pakyow-ui/registries/simple_mutation_registry.rb
125
- - pakyow-ui/lib/pakyow-ui/ui.rb
126
- - pakyow-ui/lib/pakyow-ui/ui_attrs.rb
127
- - pakyow-ui/lib/pakyow-ui/ui_component.rb
128
- - pakyow-ui/lib/pakyow-ui/ui_instructable.rb
129
- - pakyow-ui/lib/pakyow-ui/ui_view.rb
107
+ - pakyow-ui/lib/pakyow/ui.rb
108
+ - pakyow-ui/lib/pakyow/ui/base.rb
109
+ - pakyow-ui/lib/pakyow/ui/channel_builder.rb
110
+ - pakyow-ui/lib/pakyow/ui/config.rb
111
+ - pakyow-ui/lib/pakyow/ui/ext/app.rb
112
+ - pakyow-ui/lib/pakyow/ui/ext/view_context.rb
113
+ - pakyow-ui/lib/pakyow/ui/fetch_view_handler.rb
114
+ - pakyow-ui/lib/pakyow/ui/helpers.rb
115
+ - pakyow-ui/lib/pakyow/ui/mock_mutation_eval.rb
116
+ - pakyow-ui/lib/pakyow/ui/mutable.rb
117
+ - pakyow-ui/lib/pakyow/ui/mutable_data.rb
118
+ - pakyow-ui/lib/pakyow/ui/mutate_context.rb
119
+ - pakyow-ui/lib/pakyow/ui/mutation_set.rb
120
+ - pakyow-ui/lib/pakyow/ui/mutation_store.rb
121
+ - pakyow-ui/lib/pakyow/ui/mutator.rb
122
+ - pakyow-ui/lib/pakyow/ui/no_op_view.rb
123
+ - pakyow-ui/lib/pakyow/ui/registries/redis_mutation_registry.rb
124
+ - pakyow-ui/lib/pakyow/ui/registries/simple_mutation_registry.rb
125
+ - pakyow-ui/lib/pakyow/ui/ui.rb
126
+ - pakyow-ui/lib/pakyow/ui/ui_attrs.rb
127
+ - pakyow-ui/lib/pakyow/ui/ui_component.rb
128
+ - pakyow-ui/lib/pakyow/ui/ui_context.rb
129
+ - pakyow-ui/lib/pakyow/ui/ui_instructable.rb
130
+ - pakyow-ui/lib/pakyow/ui/ui_request.rb
131
+ - pakyow-ui/lib/pakyow/ui/ui_view.rb
130
132
  homepage: http://pakyow.org
131
133
  licenses:
132
134
  - MIT
@@ -147,9 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
149
  version: '0'
148
150
  requirements: []
149
151
  rubyforge_project:
150
- rubygems_version: 2.4.5
152
+ rubygems_version: 2.5.1
151
153
  signing_key:
152
154
  specification_version: 4
153
155
  summary: Pakyow UI
154
156
  test_files: []
155
- has_rdoc:
@@ -1,5 +0,0 @@
1
- module Pakyow
2
- class AppContext
3
- attr_accessor :ui
4
- end
5
- end
@@ -1,34 +0,0 @@
1
- require 'json'
2
-
3
- module Pakyow
4
- module UI
5
- # Manages mutations.
6
- #
7
- # This is the default registry in production systems and is required in
8
- # deployments with more than one app instance.
9
- #
10
- # @api private
11
- class RedisMutationRegistry
12
- include Singleton
13
-
14
- def initialize
15
- end
16
-
17
- def register(scope, mutation)
18
- Pakyow::Realtime.redis.sadd(key(scope), mutation.to_json)
19
- end
20
-
21
- def mutations(scope)
22
- Pakyow::Realtime.redis.smembers(key(scope)).map do |m|
23
- Hash.strhash(JSON.parse(m))
24
- end
25
- end
26
-
27
- private
28
-
29
- def key(scope)
30
- "pui-mutation-#{scope}"
31
- end
32
- end
33
- end
34
- end