ruby_ext_direct 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/Gemfile +1 -1
  2. data/README.markdown +60 -0
  3. data/lib/ext_direct/api.rb +68 -10
  4. data/lib/ext_direct/router.rb +25 -5
  5. data/lib/ext_direct/version.rb +1 -1
  6. data/ruby_ext_direct.gemspec +1 -0
  7. data/test/test_ext_direct.rb +19 -0
  8. metadata +17 -34
  9. data/README +0 -12
  10. data/examples/API/Gemfile +0 -29
  11. data/examples/API/app/actions/api_action.rb +0 -18
  12. data/examples/API/app/actions/home_action.rb +0 -11
  13. data/examples/API/app/actions/router_action.rb +0 -18
  14. data/examples/API/application.rb +0 -37
  15. data/examples/API/config.ru +0 -25
  16. data/examples/API/config/database.yml +0 -6
  17. data/examples/API/config/routes.rb +0 -6
  18. data/examples/API/public/NamesApp/app/store/NamesStore.js +0 -48
  19. data/examples/API/public/NamesApp/app/view/namesWindow.js +0 -21
  20. data/examples/API/public/NamesApp/app/view/ui/namesWindow.js +0 -58
  21. data/examples/API/public/NamesApp/designer.html +0 -19
  22. data/examples/API/public/NamesApp/designer.js +0 -32
  23. data/examples/API/public/NamesApp/designer_includeOrder.txt +0 -3
  24. data/examples/API/public/namesApp.xds +0 -200
  25. data/examples/rack/config.ru +0 -40
  26. data/examples/rack/exposed_classes/countries.rb +0 -10
  27. data/examples/rack/exposed_classes/names.rb +0 -82
  28. data/examples/rack/html/NamesApp/app/store/NamesStore.js +0 -56
  29. data/examples/rack/html/NamesApp/app/view/namesWindow.js +0 -49
  30. data/examples/rack/html/NamesApp/app/view/ui/namesWindow.js +0 -92
  31. data/examples/rack/html/NamesApp/designer.html +0 -19
  32. data/examples/rack/html/NamesApp/designer.js +0 -32
  33. data/examples/rack/html/NamesApp/designer_includeOrder.txt +0 -3
  34. data/examples/rack/html/names.xds +0 -275
@@ -1,40 +0,0 @@
1
- require 'rubygems'
2
- require 'json'
3
- require 'rack'
4
- require 'ext_direct'
5
-
6
- require 'pp'
7
-
8
- ExtDirect::Api.expose_all("./exposed_classes")
9
-
10
- app = Rack::Builder.new do
11
- use Rack::ShowExceptions
12
-
13
- map '/' do
14
- run Rack::Directory.new('./html')
15
- end
16
-
17
- map '/api' do
18
- run Proc.new { |env|
19
- [200, {'Content-Type' => 'text/json'}, [ExtDirect::Api.to_json]]
20
- }
21
- end
22
-
23
- map '/router' do
24
- run Proc.new { |env|
25
- result = ''
26
-
27
- req = Rack::Request.new(env)
28
- if req.post?
29
- data = env["rack.input"].gets
30
- pp data
31
- result = ExtDirect::Router.route(data)
32
- end
33
-
34
- [200, {'Content-Type' => 'text/html'}, [result.to_json]]
35
- }
36
- end
37
-
38
- end
39
-
40
- run app
@@ -1,10 +0,0 @@
1
- class Countries
2
- attr_reader :countries
3
- def initialize
4
- @countries =[ {'id' => 1, 'code' => 'be', 'value' => 'Belgium'}, {'id' => 2, 'code' => 'us', 'value' => 'United States'}]
5
- end
6
-
7
- def get
8
- @countries
9
- end
10
- end
@@ -1,82 +0,0 @@
1
- require 'rubygems'
2
- require 'yaml'
3
-
4
- require 'pp'
5
- class Names
6
- def load
7
- names ||= init
8
- {'total' => names.size, 'data' => names}
9
- end
10
-
11
- def create(data)
12
- highest_id = 0
13
- names ||= init
14
-
15
- names.each do |n|
16
- highest_id = n['id'].to_i if n['id'].to_i == 0 || n['id'].to_i > highest_id
17
- end
18
-
19
- data.each do |d|
20
- d['id'] = highest_id + 1
21
- end
22
-
23
- names += data
24
-
25
- store(names)
26
-
27
- {'success' => true, 'data' => data, 'message' => 'saved'}
28
- end
29
-
30
-
31
- def update(data)
32
- names ||= init
33
- new_names = []
34
- highest_id = 0
35
-
36
-
37
- data.each do |d|
38
- updated = false
39
- new_names = names.map do |n|
40
- highest_id = n['id'] if n['id'].to_i == 0 || n['id'].to_i < highest_id
41
- if n['id'].eql?(d['id'])
42
- updated = true
43
- d
44
- else
45
- n
46
- end
47
- end
48
-
49
- unless updated
50
- data['id'] = highest_id += 1
51
- new_names += data
52
- end
53
- names = new_names
54
- end
55
-
56
- store(new_names)
57
-
58
- {'success' => true, 'data' => data, 'message' => 'updated'}
59
- end
60
-
61
- private
62
- def init
63
- names = []
64
- if File.exists?('data.yml')
65
- names = YAML::load_file('data.yml')
66
- else
67
- names = [
68
- {'id' => 1, 'country' => 'be', 'name' => 'Mehmet Celik', 'address' => 'Country road 8, Takemehome'},
69
- {'id' => 2, 'country' => 'be', 'name' => 'Kris Wellens', 'address' => 'Country road 88, Takemehome'}
70
- ]
71
- store(names)
72
- end
73
-
74
- names
75
- end
76
-
77
- def store(names)
78
- File.open('data.yml', 'w') do |f|
79
- f.puts YAML::dump(names)
80
- end
81
- end
82
- end
@@ -1,56 +0,0 @@
1
- /*
2
- * File: app/store/NamesStore.js
3
- * Date: Wed Sep 07 2011 15:18:03 GMT+0200 (CEST)
4
- *
5
- * This file was generated by Ext Designer version 1.2.0.
6
- * http://www.sencha.com/products/designer/
7
- *
8
- * This file will be auto-generated each and everytime you export.
9
- *
10
- * Do NOT hand edit this file.
11
- */
12
-
13
- Ext.define('NamesApp.store.NamesStore', {
14
- extend: 'Ext.data.Store',
15
-
16
- constructor: function(cfg) {
17
- var me = this;
18
- cfg = cfg || {};
19
- me.callParent([Ext.apply({
20
- autoLoad: true,
21
- storeId: 'NamesStore',
22
- proxy: {
23
- type: 'direct',
24
- api: {
25
- read: Names.load,
26
- update: Names.update,
27
- create: Names.create
28
- },
29
- reader: {
30
- type: 'json',
31
- idProperty: 'id',
32
- messageProperty: 'message',
33
- root: 'data'
34
- }
35
- },
36
- fields: [
37
- {
38
- name: 'id',
39
- type: 'int'
40
- },
41
- {
42
- name: 'name',
43
- type: 'string'
44
- },
45
- {
46
- name: 'address',
47
- type: 'string'
48
- },
49
- {
50
- name: 'country',
51
- type: 'string'
52
- }
53
- ]
54
- }, cfg)]);
55
- }
56
- });
@@ -1,49 +0,0 @@
1
- /*
2
- * File: app/view/namesWindow.js
3
- * Date: Tue Sep 06 2011 11:39:42 GMT+0200 (CEST)
4
- *
5
- * This file was generated by Ext Designer version 1.2.0.
6
- * http://www.sencha.com/products/designer/
7
- *
8
- * This file will be generated the first time you export.
9
- *
10
- * You should implement event handling and custom methods in this
11
- * class.
12
- */
13
-
14
- Ext.define('NamesApp.view.namesWindow', {
15
- extend: 'NamesApp.view.ui.namesWindow',
16
-
17
- initComponent: function() {
18
- var me = this;
19
- me.callParent(arguments);
20
- },
21
- initEvents: function(){
22
- var me = this;
23
-
24
- me.down('tool[type=plus]').on('click',function(){
25
- me.addNewRow();
26
- });
27
-
28
- me.down('tool[type=refresh]').on('click', function(){
29
- me.down('#namesGrid').getStore().load();
30
- me.down('#namesGrid').getView().refresh();
31
- });
32
-
33
- me.down('tool[type=save]').on('click', function(){
34
- me.down('#namesGrid').getStore().save();
35
- me.down('#namesGrid').getView().refresh();
36
- });
37
-
38
- me.down('#namesGrid').on('edit', function(editor, e){
39
- // result = editor.record.save();
40
- editor.record.commit();
41
- me.down('#namesGrid').getStore().save();
42
- me.down('#namesGrid').getView().refresh();
43
- });
44
- },
45
- addNewRow:function(){
46
- var store = Ext.data.StoreManager.lookup('NamesStore');
47
- store.insert(0,{});
48
- }
49
- });
@@ -1,92 +0,0 @@
1
- /*
2
- * File: app/view/ui/namesWindow.js
3
- * Date: Wed Sep 07 2011 15:18:03 GMT+0200 (CEST)
4
- *
5
- * This file was generated by Ext Designer version 1.2.0.
6
- * http://www.sencha.com/products/designer/
7
- *
8
- * This file will be auto-generated each and everytime you export.
9
- *
10
- * Do NOT hand edit this file.
11
- */
12
-
13
- Ext.define('NamesApp.view.ui.namesWindow', {
14
- extend: 'Ext.window.Window',
15
-
16
- height: 541,
17
- id: 'namesWindow',
18
- width: 797,
19
- layout: {
20
- type: 'fit'
21
- },
22
- title: 'All Names',
23
-
24
- initComponent: function() {
25
- var me = this;
26
- me.items = [
27
- {
28
- xtype: 'gridpanel',
29
- id: 'namesGrid',
30
- title: 'Names Grid',
31
- store: 'NamesStore',
32
- viewConfig: {
33
-
34
- },
35
- columns: [
36
- {
37
- xtype: 'gridcolumn',
38
- width: 272,
39
- dataIndex: 'name',
40
- editor: {
41
- xtype: 'textfield',
42
- allowBlank: false
43
- },
44
- text: 'Name'
45
- },
46
- {
47
- xtype: 'gridcolumn',
48
- width: 393,
49
- dataIndex: 'address',
50
- editor: {
51
- xtype: 'textfield',
52
- allowBlank: false
53
- },
54
- text: 'Address'
55
- },
56
- {
57
- xtype: 'gridcolumn',
58
- dataIndex: 'country',
59
- editor: {
60
- xtype: 'textfield',
61
- allowBlank: false
62
- },
63
- text: 'Country'
64
- }
65
- ],
66
- plugins: [
67
- Ext.create('Ext.grid.plugin.RowEditing', {
68
- clicksToEdit: 1
69
- })
70
- ]
71
- }
72
- ];
73
- me.tools = [
74
- {
75
- xtype: 'tool',
76
- tooltip: 'Add row',
77
- type: 'plus'
78
- },
79
- {
80
- xtype: 'tool',
81
- tooltip: 'Save',
82
- type: 'save'
83
- },
84
- {
85
- xtype: 'tool',
86
- tooltip: 'Refresh',
87
- type: 'refresh'
88
- }
89
- ];
90
- me.callParent(arguments);
91
- }
92
- });
@@ -1,19 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <!-- Auto Generated with Ext Designer -->
4
- <!-- Modifications to this file will be overwritten. -->
5
- <html>
6
- <head>
7
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
- <title>names.xds</title>
9
- <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-4.0.2a/resources/css/ext-all.css"/>
10
- <script type="text/javascript" src="http://extjs.cachefly.net/ext-4.0.2a/ext-all-debug.js"></script>
11
- <script type="text/javascript">
12
- Ext.ns("REMOTING_API");
13
- REMOTING_API = {"descriptor":"REMOTING_API","url":"/router","type":"remoting","actions":{"Countries":[{"name":"countries","len":0},{"name":"get","len":0}],"Names":[{"name":"names","len":0},{"name":"load","len":0},{"name":"create","len":1},{"name":"update","len":1}]}};
14
- Ext.Direct.addProvider(REMOTING_API);
15
- </script>
16
- <script type="text/javascript" src="designer.js"></script>
17
- </head>
18
- <body></body>
19
- </html>
@@ -1,32 +0,0 @@
1
- /*
2
- * File: designer.js
3
- * Date: Wed Sep 07 2011 15:18:03 GMT+0200 (CEST)
4
- *
5
- * This file was generated by Ext Designer version 1.2.0.
6
- * http://www.sencha.com/products/designer/
7
- *
8
- * This file will be auto-generated each and everytime you export.
9
- *
10
- * Do NOT hand edit this file.
11
- */
12
-
13
- Ext.Loader.setConfig({
14
- enabled: true
15
- });
16
-
17
- Ext.application({
18
- name: 'NamesApp',
19
-
20
- stores: [
21
- 'NamesStore'
22
- ],
23
-
24
- launch: function() {
25
- Ext.QuickTips.init();
26
-
27
- var cmp1 = Ext.create('NamesApp.view.namesWindow', {
28
- renderTo: Ext.getBody()
29
- });
30
- cmp1.show();
31
- }
32
- });
@@ -1,3 +0,0 @@
1
- <script type="text/javascript" src="app/view/ui/namesWindow.js"></script>
2
- <script type="text/javascript" src="app/view/namesWindow.js"></script>
3
- <script type="text/javascript" src="app/store/NamesStore.js"></script>
@@ -1,275 +0,0 @@
1
- {
2
- "name": "names.xds",
3
- "settings": {
4
- "urlPrefix": "http://localhost/",
5
- "directAPI": "http://localhost:9292/api",
6
- "spacesToIndent": "4",
7
- "codeGenFormat": "Class",
8
- "exportPath": "./NamesApp",
9
- "extPath": "http://extjs.cachefly.net/ext-4.0.2a/",
10
- "lineEnding": "LF",
11
- "instantiateStore": true,
12
- "exportXDSFiles": true,
13
- "genTimestamps": true,
14
- "appName": "NamesApp"
15
- },
16
- "xdsVersion": "1.2.0",
17
- "components": [
18
- {
19
- "id": "ExtBox1-ext-gen2626",
20
- "type": "window",
21
- "reference": {
22
- "name": "items",
23
- "type": "array"
24
- },
25
- "codeClass": null,
26
- "userConfig": {
27
- "height": 541,
28
- "id": "namesWindow",
29
- "width": 797,
30
- "layout": "fit",
31
- "title": "All Names",
32
- "designer|userClassName": "namesWindow"
33
- },
34
- "cn": [
35
- {
36
- "id": "ExtBox1-ext-gen2817",
37
- "type": "gridpanel",
38
- "reference": {
39
- "name": "items",
40
- "type": "array"
41
- },
42
- "codeClass": null,
43
- "userConfig": {
44
- "id": "namesGrid",
45
- "title": "Names Grid",
46
- "store": "NamesStore",
47
- "designer|userClassName": "MyGridPanel"
48
- },
49
- "cn": [
50
- {
51
- "id": "ExtBox1-ext-gen2854",
52
- "type": "gridview",
53
- "reference": {
54
- "name": "viewConfig",
55
- "type": "object"
56
- },
57
- "codeClass": null,
58
- "userConfig": {
59
- "designer|userClassName": "MyGridView"
60
- }
61
- },
62
- {
63
- "id": "ExtBox1-ext-gen3732",
64
- "type": "gridcolumn",
65
- "reference": {
66
- "name": "columns",
67
- "type": "array"
68
- },
69
- "codeClass": null,
70
- "userConfig": {
71
- "width": 272,
72
- "dataIndex": "name",
73
- "editor": "{xtype: 'textfield',\nallowBlank:false}",
74
- "text": "Name",
75
- "designer|userClassName": "MyColumn"
76
- }
77
- },
78
- {
79
- "id": "ExtBox1-ext-gen3741",
80
- "type": "gridcolumn",
81
- "reference": {
82
- "name": "columns",
83
- "type": "array"
84
- },
85
- "codeClass": null,
86
- "userConfig": {
87
- "width": 393,
88
- "dataIndex": "address",
89
- "editor": "{xtype: 'textfield',\nallowBlank:false}",
90
- "text": "Address",
91
- "designer|userClassName": "MyColumn1"
92
- }
93
- },
94
- {
95
- "id": "ExtBox1-ext-gen3750",
96
- "type": "gridcolumn",
97
- "reference": {
98
- "name": "columns",
99
- "type": "array"
100
- },
101
- "codeClass": null,
102
- "userConfig": {
103
- "dataIndex": "country",
104
- "editor": "{xtype: 'textfield',\nallowBlank:false}",
105
- "text": "Country",
106
- "designer|userClassName": "MyColumn2"
107
- }
108
- },
109
- {
110
- "id": "ExtBox1-ext-gen5035",
111
- "type": "gridroweditingplugin",
112
- "reference": {
113
- "name": "plugins",
114
- "type": "array"
115
- },
116
- "codeClass": "Ext.grid.plugin.RowEditing",
117
- "userConfig": {
118
- "clicksToEdit": 1,
119
- "designer|userClassName": "MyRowEditingPlugin"
120
- }
121
- }
122
- ]
123
- },
124
- {
125
- "id": "ExtBox1-ext-gen6904",
126
- "type": "tool",
127
- "reference": {
128
- "name": "tools",
129
- "type": "array"
130
- },
131
- "codeClass": null,
132
- "userConfig": {
133
- "tooltip": "Add row",
134
- "type": "plus",
135
- "designer|userClassName": "MyTool2"
136
- }
137
- },
138
- {
139
- "id": "ExtBox1-ext-gen6486",
140
- "type": "tool",
141
- "reference": {
142
- "name": "tools",
143
- "type": "array"
144
- },
145
- "codeClass": null,
146
- "userConfig": {
147
- "tooltip": "Save",
148
- "type": "save",
149
- "designer|userClassName": "MyTool"
150
- }
151
- },
152
- {
153
- "id": "ExtBox1-ext-gen6611",
154
- "type": "tool",
155
- "reference": {
156
- "name": "tools",
157
- "type": "array"
158
- },
159
- "codeClass": null,
160
- "userConfig": {
161
- "tooltip": "Refresh",
162
- "type": "refresh",
163
- "designer|userClassName": "MyTool1"
164
- }
165
- }
166
- ]
167
- }
168
- ],
169
- "stores": [
170
- {
171
- "id": "ExtBox1-ext-gen1666",
172
- "type": "directstore",
173
- "reference": {
174
- "name": "items",
175
- "type": "array"
176
- },
177
- "codeClass": null,
178
- "userConfig": {
179
- "autoLoad": true,
180
- "storeId": "NamesStore",
181
- "designer|userClassName": "NamesStore"
182
- },
183
- "cn": [
184
- {
185
- "id": "ExtBox1-ext-gen1670",
186
- "type": "directproxy",
187
- "reference": {
188
- "name": "proxy",
189
- "type": "object"
190
- },
191
- "codeClass": null,
192
- "userConfig": {
193
- "api": "{read:Names.load,\nupdate:Names.update,\ncreate:Names.create}",
194
- "directFn": null,
195
- "designer|userClassName": "Direct Proxy"
196
- },
197
- "cn": [
198
- {
199
- "id": "ExtBox1-ext-gen1676",
200
- "type": "jsonreader",
201
- "reference": {
202
- "name": "reader",
203
- "type": "object"
204
- },
205
- "codeClass": null,
206
- "userConfig": {
207
- "idProperty": "id",
208
- "messageProperty": "message",
209
- "root": "data",
210
- "designer|userClassName": "Json Reader"
211
- }
212
- }
213
- ]
214
- },
215
- {
216
- "id": "ExtBox1-ext-gen5836",
217
- "type": "datafield",
218
- "reference": {
219
- "name": "fields",
220
- "type": "array"
221
- },
222
- "codeClass": null,
223
- "userConfig": {
224
- "name": "id",
225
- "type": "int",
226
- "designer|userClassName": "MyField3"
227
- }
228
- },
229
- {
230
- "id": "ExtBox1-ext-gen2110",
231
- "type": "datafield",
232
- "reference": {
233
- "name": "fields",
234
- "type": "array"
235
- },
236
- "codeClass": null,
237
- "userConfig": {
238
- "name": "name",
239
- "type": "string",
240
- "designer|userClassName": "MyField"
241
- }
242
- },
243
- {
244
- "id": "ExtBox1-ext-gen2117",
245
- "type": "datafield",
246
- "reference": {
247
- "name": "fields",
248
- "type": "array"
249
- },
250
- "codeClass": null,
251
- "userConfig": {
252
- "name": "address",
253
- "type": "string",
254
- "designer|userClassName": "MyField1"
255
- }
256
- },
257
- {
258
- "id": "ExtBox1-ext-gen2124",
259
- "type": "datafield",
260
- "reference": {
261
- "name": "fields",
262
- "type": "array"
263
- },
264
- "codeClass": null,
265
- "userConfig": {
266
- "name": "country",
267
- "type": "string",
268
- "designer|userClassName": "MyField2"
269
- }
270
- }
271
- ]
272
- }
273
- ],
274
- "framework": "ext40"
275
- }