netzke-core 0.10.1 → 0.11.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: c2d3974415d753788a68fa93d39bab6ae4c53a14
4
- data.tar.gz: c7ce197f714115ef55ea6f119d9c1a7e89fbbde0
3
+ metadata.gz: e8985c0704cb87adfae5eb77c6419bac1b2ef76a
4
+ data.tar.gz: 586a4f56bd0700cd35d72ceec9336d2dfa1796e2
5
5
  SHA512:
6
- metadata.gz: 8355b25b20420bf35a4c83c0b36483d7e331106c5a92b4a9a286eb3cb1cc38d24bebd1358d027df5b41bd41db665dcdae252e3d3f7a38b85807d30517cda79b2
7
- data.tar.gz: 1bb1721a1f5d7d3a013a33dd916abd50ce383e820673853b513aa9793f5f863e057f222554bb810597ae089fb8171a5343f5cbc120c45c4b2107ea9bc8d50ac0
6
+ metadata.gz: 8a00abb3fb10d0cce4a1bafafb3f2d9de4545e105440ded180fe817a0a5ca64e1b442291135b1431ac5455da54510296789d2cb62cf14dd8329324e00976af88
7
+ data.tar.gz: e5e7213adadfd0a14a3d5007ad13c546d87d1a1577b0073436e08b1e1d766c02d7e489aa389c24d7cb5a834893b7a74e1e7539363626d348bb4955d6be562207
data/Gemfile CHANGED
@@ -1,15 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- # For local development
6
- # gem 'netzke_testing', path: '~/code/netzke/netzke_testing'
7
-
8
- # This partial duplication of gemspec is required for rails_app to run
9
- group :test do
10
- gem 'capybara'
11
- gem 'selenium-webdriver'
12
- gem 'database_cleaner'
13
- gem 'rspec-rails'
14
- gem 'netzke-testing', '0.10.0'
15
- end
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ### TODO
2
+
1
3
  # Netzke Core [![Gem Version](https://fury-badge.herokuapp.com/rb/netzke-core.png)](http://badge.fury.io/rb/netzke-core) [![Build Status](https://travis-ci.org/netzke/netzke-core.png?branch=master)](https://travis-ci.org/netzke/netzke-core) [![Code Climate](https://codeclimate.com/github/netzke/netzke-core.png)](https://codeclimate.com/github/netzke/netzke-core)
2
4
 
3
5
  [RDocs](http://rdoc.info/projects/netzke/netzke-core)
@@ -325,9 +327,9 @@ Netzke provides support for HAML templates in case you don't want to put HTML in
325
327
 
326
328
  ## Requirements
327
329
 
328
- * Ruby ~> 1.9.2
329
- * Rails ~> 4.0.0
330
- * Ext JS ~> 4.2.0
330
+ * Ruby >= 2.0.0
331
+ * Rails ~> 4.2.0
332
+ * Ext JS = 4.2.1
331
333
 
332
334
  ## Installation
333
335
 
@@ -369,7 +371,7 @@ This assumes that the Ext JS library is located/symlinked in `spec/rails_app/pub
369
371
 
370
372
  Help developing Netzke by submitting a pull request when you think others can benefit from it.
371
373
 
372
- If you feel particularily generous, you can support the author by donating a couple bucks a week at [GitTip](https://www.gittip.com/uptomax).
374
+ If you feel particularily generous, you can support the author by donating a couple bucks a week at [GitTip](https://www.gittip.com/mxgrn).
373
375
 
374
376
  ## Useful links
375
377
 
@@ -378,6 +380,6 @@ If you feel particularily generous, you can support the author by donating a cou
378
380
  * [Twitter](http://twitter.com/netzke) - latest news about the framework
379
381
 
380
382
  ---
381
- Copyright (c) 2008-2013 [Max Gorin](https://twitter.com/uptomax), released under the MIT license (see LICENSE).
383
+ Copyright (c) 2008-2015 [Max Gorin](https://twitter.com/mxgrn), released under the MIT license (see LICENSE).
382
384
 
383
385
  **Note** that Ext JS is licensed [differently](http://www.sencha.com/products/extjs/license/), and you may need to purchase a commercial license in order to use it in your projects!
@@ -1,3 +1,5 @@
1
1
  class NetzkeController < ApplicationController
2
2
  include Netzke::Railz::ControllerExtensions
3
+
4
+ skip_before_action :verify_authenticity_token, only: [:ext, :direct, :dispatcher]
3
5
  end
@@ -134,7 +134,11 @@ module Netzke::Core
134
134
  cfg.js_id = options[:js_id]
135
135
  send("#{name}_component", cfg)
136
136
  cfg.set_defaults!
137
- cfg.klass.new(cfg, self)
137
+ component_instance_from_config(cfg)
138
+ end
139
+
140
+ def component_instance_from_config(c)
141
+ c.klass.new(c, self)
138
142
  end
139
143
 
140
144
  # @return [Array<Class>] All component classes that we depend on (used to render all necessary javascripts and stylesheets)
@@ -1,4 +1,27 @@
1
+ # Carefully monkey-patch ActiveSupport's JSON encoder, so it *also* does what we need
2
+ class ActiveSupport::JSON::Encoding::JSONGemEncoder
3
+ private
4
+
5
+ def jsonify(value)
6
+ case value
7
+ when Netzke::Core::JsonLiteral
8
+ value
9
+ when String
10
+ EscapedString.new(value)
11
+ when Numeric, NilClass, TrueClass, FalseClass
12
+ value
13
+ when Hash
14
+ Hash[value.map { |k, v| [jsonify(k), jsonify(v)] }]
15
+ when Array
16
+ value.map { |v| jsonify(v) }
17
+ else
18
+ jsonify value.as_json
19
+ end
20
+ end
21
+ end
22
+
1
23
  class Netzke::Core::JsonLiteral < String
2
24
  def as_json(options = nil) self end #:nodoc:
25
+ def to_json(options = nil) self end #:nodoc:
3
26
  def encode_json(encoder) self end #:nodoc:
4
27
  end
@@ -97,16 +97,16 @@ module Netzke
97
97
  tid: request.tid,
98
98
  action: component_name,
99
99
  method: request.endpoint,
100
- result: Netzke::Core::JsonLiteral.new(endpoint_response.netzke_jsonify.to_json)
100
+ result: endpoint_response.netzke_jsonify
101
101
  }
102
102
  end
103
103
 
104
104
  def invoke_endpoint(request)
105
105
  component_name, *sub_components = request.cmp_path.split('__')
106
- components_in_session = session[:netzke_components]
106
+ components_in_session = session[:netzke_components].try(:symbolize_keys)
107
107
 
108
108
  if components_in_session
109
- cmp_config = components_in_session[component_name.to_sym]
109
+ cmp_config = components_in_session[component_name.to_sym].symbolize_keys
110
110
  cmp_config[:client_config] = request.client_configs.shift || {}
111
111
  component_instance = Netzke::Base.instance_by_config(cmp_config)
112
112
  component_instance.invoke_endpoint((sub_components + [request.endpoint]).join("__"), request.args, request.client_configs)
@@ -4,20 +4,28 @@ module Netzke::Core
4
4
  # Instance of this class is returned through component_session, and allows writing/reading to/from the session part reserved for a specific component (specified by component's js_id).
5
5
  class ComponentSessionProxy < Object
6
6
  def initialize(component_id)
7
- @component_id = component_id
7
+ @component_id = component_id.to_s
8
8
  Netzke::Base.session ||= {}
9
9
  Netzke::Base.session[:netzke_sessions] ||= {}
10
- @session = Netzke::Base.session[:netzke_sessions][@component_id] ||= {}
10
+ # @session = Netzke::Base.session[:netzke_sessions][@component_id] ||= {}
11
+ # @session = {}
11
12
  end
12
13
 
13
14
  # Delegate everything to session
14
15
  def method_missing(method, *args)
15
- @session.send(method, *args)
16
+ session_data = to_hash
17
+ session_data.send(method, *args).tap do |d|
18
+ Netzke::Base.session[:netzke_sessions] = {@component_id => session_data}
19
+ end
16
20
  end
17
21
 
18
22
  def clear
19
23
  Netzke::Base.session[:netzke_sessions].delete(@component_id)
20
24
  end
25
+
26
+ def to_hash
27
+ ActiveSupport::HashWithIndifferentAccess.new(Netzke::Base.session[:netzke_sessions][@component_id] || {})
28
+ end
21
29
  end
22
30
 
23
31
  # Component-specific session.
@@ -14,6 +14,31 @@ module Netzke::Core
14
14
  # Note that the provided persistence_key has effect on _application_ level, _not_ only within the view.
15
15
  # By default +persistence_key+ is set to component's +js_id+. Thus, _two components named equally will share the state even being used in different Rails views_.
16
16
  module State
17
+ class StateProxy < Object
18
+ def initialize(key)
19
+ @key = key.to_s
20
+ Netzke::Base.session ||= {}
21
+ Netzke::Base.session[:netzke_states] ||= {}
22
+ # @session = Netzke::Base.session[:netzke_sessions][@component_id] ||= {}
23
+ # @session = {}
24
+ end
25
+
26
+ # Delegate everything to session
27
+ def method_missing(method, *args)
28
+ session_data = to_hash
29
+ session_data.send(method, *args).tap do |d|
30
+ Netzke::Base.session[:netzke_states] = {@key => session_data}
31
+ end
32
+ end
33
+
34
+ def to_hash
35
+ ActiveSupport::HashWithIndifferentAccess.new(Netzke::Base.session[:netzke_states][@key] || {})
36
+ end
37
+
38
+ def clear
39
+ Netzke::Base.session[:netzke_states].delete(@key)
40
+ end
41
+ end
17
42
  # A string which identifies the component. Can be passed as +persistence_key+ config option. Two components with the same +persistence_key+ will be sharing the state.
18
43
  # If +persistence_key+ is passed, use it. Otherwise use js_id.
19
44
  def persistence_key
@@ -33,8 +58,9 @@ module Netzke::Core
33
58
  # * delete(key)
34
59
  # * clear
35
60
  def state
36
- session[:netzke_states] ||= {}
37
- session[:netzke_states][persistence_key] ||= {}
61
+ @state_proxy ||= StateProxy.new(persistence_key)
62
+ # session[:netzke_states] ||= {}
63
+ # session[:netzke_states][persistence_key] ||= {}
38
64
  end
39
65
  end
40
66
  end
@@ -1,5 +1,5 @@
1
1
  module Netzke
2
2
  module Core
3
- VERSION = "0.10.1"
3
+ VERSION = "0.11.0"
4
4
  end
5
5
  end
@@ -0,0 +1,30 @@
1
+ require "./lib/netzke/core/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "netzke-core"
5
+ s.version = Netzke::Core::VERSION
6
+ s.author = "Max Gorin"
7
+ s.email = "gorinme@gmail.com"
8
+ s.homepage = "http://netzke.org"
9
+ s.summary = "Client-server GUI components with Sencha Ext JS and Ruby on Rails"
10
+ s.description = "Build complex web GUI in a modular way"
11
+
12
+ s.files = Dir["{app,javascripts,lib,stylesheets,tasks}/**/*", "[A-Z]*", "init.rb"] - ["Gemfile.lock"]
13
+ s.test_files = Dir["{test}/**/*"]
14
+ s.require_paths = ["lib"]
15
+
16
+ s.add_dependency 'uglifier'
17
+ s.add_dependency 'execjs'
18
+
19
+ s.add_development_dependency 'rails', '~> 4.2.0'
20
+ s.add_development_dependency 'sqlite3'
21
+ s.add_development_dependency 'redcarpet'
22
+ s.add_development_dependency 'yard'
23
+ s.add_development_dependency 'coffee-script'
24
+ s.add_development_dependency 'capybara'
25
+ s.add_development_dependency 'selenium-webdriver'
26
+ s.add_development_dependency 'rspec-rails'
27
+ s.add_development_dependency 'netzke-testing', '~> 0.11.0'
28
+
29
+ s.required_rubygems_version = ">= 1.3.4"
30
+ end
metadata CHANGED
@@ -1,124 +1,189 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netzke-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Gorin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-24 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uglifier
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '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
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: execjs
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '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
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 4.0.0
47
+ version: 4.2.0
48
48
  type: :development
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: 4.0.0
54
+ version: 4.2.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redcarpet
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: yard
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: coffee-script
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: capybara
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: selenium-webdriver
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec-rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: netzke-testing
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.11.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.11.0
111
167
  description: Build complex web GUI in a modular way
112
168
  email: gorinme@gmail.com
113
169
  executables: []
114
170
  extensions: []
115
171
  extra_rdoc_files: []
116
172
  files:
173
+ - CHANGELOG.md
174
+ - Gemfile
175
+ - LICENSE
176
+ - README.md
177
+ - Rakefile
178
+ - TODO.md
117
179
  - app/controllers/netzke_controller.rb
180
+ - init.rb
118
181
  - javascripts/base.js
119
182
  - javascripts/ext.js
120
183
  - javascripts/js_extensions.js
184
+ - lib/netzke-core.rb
121
185
  - lib/netzke/base.rb
186
+ - lib/netzke/core.rb
122
187
  - lib/netzke/core/action_config.rb
123
188
  - lib/netzke/core/actions.rb
124
189
  - lib/netzke/core/client_class.rb
@@ -137,35 +202,27 @@ files:
137
202
  - lib/netzke/core/json_literal.rb
138
203
  - lib/netzke/core/panel.rb
139
204
  - lib/netzke/core/plugins.rb
140
- - lib/netzke/core/railz/action_view_ext/ext.rb
205
+ - lib/netzke/core/railz.rb
141
206
  - lib/netzke/core/railz/action_view_ext.rb
207
+ - lib/netzke/core/railz/action_view_ext/ext.rb
142
208
  - lib/netzke/core/railz/controller_extensions.rb
143
209
  - lib/netzke/core/railz/engine.rb
144
210
  - lib/netzke/core/railz/routes.rb
145
- - lib/netzke/core/railz.rb
211
+ - lib/netzke/core/ruby_ext.rb
146
212
  - lib/netzke/core/ruby_ext/array.rb
147
213
  - lib/netzke/core/ruby_ext/hash.rb
148
214
  - lib/netzke/core/ruby_ext/time_with_zone.rb
149
- - lib/netzke/core/ruby_ext.rb
150
215
  - lib/netzke/core/services.rb
151
216
  - lib/netzke/core/session.rb
152
217
  - lib/netzke/core/state.rb
153
218
  - lib/netzke/core/stylesheets.rb
154
219
  - lib/netzke/core/version.rb
155
- - lib/netzke/core.rb
156
220
  - lib/netzke/plugin.rb
157
- - lib/netzke-core.rb
158
221
  - lib/tasks/netzke_core_tasks.rake
222
+ - netzke-core.gemspec
159
223
  - stylesheets/core.css
160
224
  - tasks/app_test_tasks.rake
161
225
  - tasks/rake_helper.rb
162
- - CHANGELOG.md
163
- - Gemfile
164
- - LICENSE
165
- - Rakefile
166
- - README.md
167
- - TODO.md
168
- - init.rb
169
226
  homepage: http://netzke.org
170
227
  licenses: []
171
228
  metadata: {}
@@ -175,17 +232,17 @@ require_paths:
175
232
  - lib
176
233
  required_ruby_version: !ruby/object:Gem::Requirement
177
234
  requirements:
178
- - - '>='
235
+ - - ">="
179
236
  - !ruby/object:Gem::Version
180
237
  version: '0'
181
238
  required_rubygems_version: !ruby/object:Gem::Requirement
182
239
  requirements:
183
- - - '>='
240
+ - - ">="
184
241
  - !ruby/object:Gem::Version
185
242
  version: 1.3.4
186
243
  requirements: []
187
244
  rubyforge_project:
188
- rubygems_version: 2.0.14
245
+ rubygems_version: 2.4.5
189
246
  signing_key:
190
247
  specification_version: 4
191
248
  summary: Client-server GUI components with Sencha Ext JS and Ruby on Rails