lanes 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/client/lanes/components/ChoicesInput.coffee +1 -1
  3. data/client/lanes/components/grid/Grid.coffee +4 -4
  4. data/client/lanes/components/grid/PopOverEditor.coffee +1 -1
  5. data/client/lanes/components/popover/PopOver.coffee +3 -3
  6. data/client/lanes/components/record_finder/RecordFinder.coffee +4 -4
  7. data/client/lanes/components/select_field/SelectField.coffee +1 -1
  8. data/client/lanes/extension/Base.coffee +1 -1
  9. data/client/lanes/extension/Extensions.coffee +3 -3
  10. data/client/lanes/extension/GlAccounts.coffee +2 -2
  11. data/client/lanes/lib/namespace.coffee +1 -1
  12. data/client/lanes/minimal.js +1 -1
  13. data/client/lanes/{data/Model.coffee → models/Base.coffee} +29 -47
  14. data/client/lanes/models/Bootstrap.coffee +8 -0
  15. data/client/lanes/{data → models}/ChangeSet.coffee +3 -3
  16. data/client/lanes/{data → models}/Collection.coffee +20 -40
  17. data/client/lanes/{data → models}/Config.coffee +2 -2
  18. data/client/lanes/{data → models}/PubSub.coffee +4 -3
  19. data/client/lanes/{data → models}/Query.coffee +7 -7
  20. data/client/lanes/{data → models}/Screens.coffee +12 -12
  21. data/client/lanes/models/Sync.coffee +86 -0
  22. data/client/lanes/{data → models}/User.coffee +8 -8
  23. data/client/lanes/{data → models}/index.js +1 -1
  24. data/client/lanes/{data → models}/mixins/HasCodeField.coffee +2 -2
  25. data/client/lanes/screens/Base.coffee +1 -1
  26. data/client/lanes/screens/ChangeListener.coffee +1 -1
  27. data/client/lanes/screens/Instance.coffee +3 -3
  28. data/client/lanes/screens/screen-definitions.js.erb +2 -2
  29. data/client/lanes/views/Base.coffee +10 -10
  30. data/client/lanes/views/ModelObserver.coffee +1 -1
  31. data/client/lanes/views/PubSub.coffee +4 -4
  32. data/client/lanes/views/Viewport.coffee +1 -1
  33. data/client/lanes/workspace/ActiveScreensSwitcher.coffee +1 -1
  34. data/client/lanes/workspace/Pages.coffee +2 -2
  35. data/client/lanes/workspace/ScreensMenu.coffee +1 -1
  36. data/lanes.gemspec +2 -1
  37. data/lib/lanes/command/generate_model.rb +6 -7
  38. data/lib/lanes/command/named_command.rb +1 -1
  39. data/lib/lanes/command/templates/client/index.js +1 -1
  40. data/lib/lanes/command/templates/client/{data → models}/Model.coffee +3 -7
  41. data/lib/lanes/command/templates/client/views/View.coffee +1 -1
  42. data/lib/lanes/command/templates/spec/client/models/ModelSpec.coffee +5 -0
  43. data/lib/lanes/command/update_model.rb +4 -11
  44. data/lib/lanes/command.rb +4 -3
  45. data/lib/lanes/version.rb +1 -1
  46. data/spec/helpers/lanes-helpers.coffee +5 -4
  47. data/spec/lanes/{data/ModelSpec.coffee → models/BaseSpec.coffee} +23 -11
  48. data/spec/lanes/{data → models}/PubSubSpec.coffee +6 -6
  49. data/views/specs.erb +1 -4
  50. metadata +19 -20
  51. data/client/lanes/data/Bootstrap.coffee +0 -8
  52. data/client/lanes/data/Sync.coffee +0 -63
  53. data/lib/lanes/command/templates/spec/client/data/ModelSpec.coffee +0 -5
  54. data/lib/lanes/spec_asset_expander.rb +0 -43
@@ -1,17 +1,17 @@
1
1
 
2
- describe "Model Suite", ->
2
+ describe "Base Model Suite", ->
3
3
  Model = undefined
4
4
  Collection = undefined
5
5
  class Color
6
6
  constructor: -> super
7
7
  props: { id: 'integer', rgb: 'string' }
8
- Lanes.Data.Model.extend(Color)
8
+ Lanes.Models.Base.extend(Color)
9
9
 
10
10
  makeModel = (props,args={})->
11
11
  _.extend(Model.prototype, props)
12
- Lanes.Data.Model.extend(Model)
12
+ Lanes.Models.Base.extend(Model)
13
13
  Collection::model = Model
14
- Lanes.Data.Collection.extend(Collection)
14
+ Lanes.Models.Collection.extend(Collection)
15
15
  collection = new Collection
16
16
  return collection.add(new Model(args))
17
17
 
@@ -35,7 +35,7 @@ describe "Model Suite", ->
35
35
  expect(model.isDirty()).toBeFalse()
36
36
  model.foo = 'baz' # session prop
37
37
  expect(model.isDirty()).toBeFalse()
38
- expect(model.unsavedData()).toBeEmptyObject()
38
+ expect(model.unsavedModels()).toBeEmptyObject()
39
39
  model.set( saved: 'true' )
40
40
  expect(model.isDirty()).toBeTrue()
41
41
 
@@ -83,7 +83,7 @@ describe "Model Suite", ->
83
83
 
84
84
  }, { foo: 'one, two, three'} )
85
85
  expect(model.isDirty()).toBeTrue()
86
- expect(model.unsavedData()).toEqual( foo: 'one, two, three' )
86
+ expect(model.unsavedModels()).toEqual( foo: 'one, two, three' )
87
87
  model.save()
88
88
  expect(model.sync).toHaveBeenCalledWith('create', model, jasmine.any(Object))
89
89
  model.id=11
@@ -111,6 +111,23 @@ describe "Model Suite", ->
111
111
  expect(options).toHaveTrue('ignoreUnsaved')
112
112
  expect(options).toHaveNumberWithinRange('limit',1,1)
113
113
 
114
+ it "creates a Collection property", ->
115
+ model = makeModel({})
116
+ expect(Model.Collection::model).toEqual(Model)
117
+
118
+ it "loads using where", ->
119
+ model = makeModel({
120
+ props:
121
+ { id: 'integer', title: 'string' }
122
+ })
123
+ syncSucceedWith([
124
+ { id: 1, title: 'first value' }
125
+ { id: 2, title: 'second value' }
126
+ ])
127
+ collection = model.where(title: 'first value')
128
+ options = model.sync.lastOptions()
129
+ expect(options.query).toEqual({title:'first value'})
130
+ expect(collection.length).toEqual(2)
114
131
 
115
132
  it "can be destroyed", ->
116
133
  model = makeModel({
@@ -145,8 +162,3 @@ describe "Model Suite", ->
145
162
  expect(model.sync).toHaveBeenCalledWith('read', model, jasmine.any(Object))
146
163
  options = model.sync.lastOptions()
147
164
  expect(options.include).toEqual(['color'])
148
-
149
- it "assigns an inverse collection property", ->
150
- model = makeModel({})
151
- expect(Model::Collection).toEqual(Collection)
152
-
@@ -4,18 +4,18 @@ describe "PubSub Suite", ->
4
4
  it "checks in/out a model when it binds to a view", ->
5
5
  view = new Lanes.Testing.View
6
6
  model = new Lanes.Testing.Model(id:1)
7
- spyOn(Lanes.Data.PubSub,'add').and.callThrough()
8
- spyOn(Lanes.Data.PubSub,'remove')
7
+ spyOn(Lanes.Models.PubSub,'add').and.callThrough()
8
+ spyOn(Lanes.Models.PubSub,'remove')
9
9
  view.model = model
10
- expect(Lanes.Data.PubSub.add).toHaveBeenCalledWith(model)
10
+ expect(Lanes.Models.PubSub.add).toHaveBeenCalledWith(model)
11
11
  expect(Lanes.Vendor.MessageBus.subscribe)
12
12
  .toHaveBeenCalledWith("/test/1", jasmine.any(Function))
13
13
  view.unset('model')
14
- expect(Lanes.Data.PubSub.remove).toHaveBeenCalledWith(model)
14
+ expect(Lanes.Models.PubSub.remove).toHaveBeenCalledWith(model)
15
15
 
16
16
  it "can retrieve a model after checkin", ->
17
17
  model = new Lanes.Testing.Model(id: 11, name:'bar')
18
- Lanes.Data.PubSub.add(model)
19
- checkin = Lanes.Data.PubSub.instanceFor(Lanes.Testing.Model, 11)
18
+ Lanes.Models.PubSub.add(model)
19
+ checkin = Lanes.Models.PubSub.instanceFor(Lanes.Testing.Model, 11)
20
20
  expect(checkin).toEqual(model)
21
21
 
data/views/specs.erb CHANGED
@@ -5,18 +5,15 @@
5
5
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"/>
7
7
  <title>Lanes Specs</title>
8
-
9
8
  <%= javascript_tag 'lanes/workspace.js' %>
10
-
11
9
  <% specs.css_files.each do |css_file| %>
12
10
  <link rel="stylesheet" href="<%= css_file %>" type="text/css" media="screen"/>
13
11
  <% end %>
14
-
15
12
  <% specs.js_files.each do | js_file | %>
16
13
  <script src="<%= js_file %>" type="text/javascript"></script>
17
14
  <% end %>
18
15
  <script type="text/javascript">
19
- Lanes.Data.Bootstrap.initialize( <%= client_bootstrap_data %> );
16
+ Lanes.Models.Bootstrap.initialize( <%= client_bootstrap_data %> );
20
17
  </script>
21
18
 
22
19
  </head>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lanes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Stitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-20 00:00:00.000000000 Z
11
+ date: 2014-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -502,18 +502,6 @@ files:
502
502
  - client/lanes/components/select_field/SelectField.coffee
503
503
  - client/lanes/components/select_field/index.js
504
504
  - client/lanes/components/select_field/select_field.scss
505
- - client/lanes/data/Bootstrap.coffee
506
- - client/lanes/data/ChangeSet.coffee
507
- - client/lanes/data/Collection.coffee
508
- - client/lanes/data/Config.coffee
509
- - client/lanes/data/Model.coffee
510
- - client/lanes/data/PubSub.coffee
511
- - client/lanes/data/Query.coffee
512
- - client/lanes/data/Screens.coffee
513
- - client/lanes/data/Sync.coffee
514
- - client/lanes/data/User.coffee
515
- - client/lanes/data/index.js
516
- - client/lanes/data/mixins/HasCodeField.coffee
517
505
  - client/lanes/extension/Base.coffee
518
506
  - client/lanes/extension/EarlyExtensions.js.erb
519
507
  - client/lanes/extension/Extensions.coffee
@@ -538,6 +526,18 @@ files:
538
526
  - client/lanes/lib/utilFunctions.coffee
539
527
  - client/lanes/minimal.js
540
528
  - client/lanes/minimal.scss.erb
529
+ - client/lanes/models/Base.coffee
530
+ - client/lanes/models/Bootstrap.coffee
531
+ - client/lanes/models/ChangeSet.coffee
532
+ - client/lanes/models/Collection.coffee
533
+ - client/lanes/models/Config.coffee
534
+ - client/lanes/models/PubSub.coffee
535
+ - client/lanes/models/Query.coffee
536
+ - client/lanes/models/Screens.coffee
537
+ - client/lanes/models/Sync.coffee
538
+ - client/lanes/models/User.coffee
539
+ - client/lanes/models/index.js
540
+ - client/lanes/models/mixins/HasCodeField.coffee
541
541
  - client/lanes/plugins/ResizeSensor.js
542
542
  - client/lanes/plugins/index.js
543
543
  - client/lanes/plugins/overlay.coffee
@@ -811,8 +811,8 @@ files:
811
811
  - lib/lanes/command/templates/client/Extension.coffee
812
812
  - lib/lanes/command/templates/client/components/.gitkeep
813
813
  - lib/lanes/command/templates/client/components/Component.coffee
814
- - lib/lanes/command/templates/client/data/Model.coffee
815
814
  - lib/lanes/command/templates/client/index.js
815
+ - lib/lanes/command/templates/client/models/Model.coffee
816
816
  - lib/lanes/command/templates/client/screens/Screen.coffee
817
817
  - lib/lanes/command/templates/client/screens/index.js
818
818
  - lib/lanes/command/templates/client/screens/layout.html
@@ -834,7 +834,7 @@ files:
834
834
  - lib/lanes/command/templates/lib/namespace/version.rb
835
835
  - lib/lanes/command/templates/public/.gitkeep
836
836
  - lib/lanes/command/templates/spec/client/Screen.coffee
837
- - lib/lanes/command/templates/spec/client/data/ModelSpec.coffee
837
+ - lib/lanes/command/templates/spec/client/models/ModelSpec.coffee
838
838
  - lib/lanes/command/templates/spec/client/views/ViewSpec.coffee
839
839
  - lib/lanes/command/templates/spec/fixtures/namespace/model.yml
840
840
  - lib/lanes/command/templates/spec/namespace/model_spec.rb
@@ -874,7 +874,6 @@ files:
874
874
  - lib/lanes/rails_engine.rb
875
875
  - lib/lanes/rake_tasks.rb
876
876
  - lib/lanes/screens.rb
877
- - lib/lanes/spec_asset_expander.rb
878
877
  - lib/lanes/spec_helper.rb
879
878
  - lib/lanes/strings.rb
880
879
  - lib/lanes/testing_models.rb
@@ -905,8 +904,8 @@ files:
905
904
  - spec/helpers/jasmine-jquery.js
906
905
  - spec/helpers/jasmine-matchers.js
907
906
  - spec/helpers/lanes-helpers.coffee
908
- - spec/lanes/data/ModelSpec.coffee
909
- - spec/lanes/data/PubSubSpec.coffee
907
+ - spec/lanes/models/BaseSpec.coffee
908
+ - spec/lanes/models/PubSubSpec.coffee
910
909
  - spec/lanes/views/BaseSpec.coffee
911
910
  - spec/numbers_spec.rb
912
911
  - spec/strings_spec.rb
@@ -927,7 +926,7 @@ files:
927
926
  - yard_ext/templates/default/method_details/setup.rb
928
927
  - yard_ext/validators.rb
929
928
  - yard_ext/visible_id_handler.rb
930
- homepage: http://argosity.com/lanes/
929
+ homepage: http://lanesframework.org/
931
930
  licenses:
932
931
  - MIT
933
932
  metadata: {}
@@ -1,8 +0,0 @@
1
- Lanes.Data.Bootstrap = {
2
-
3
- initialize: (options)->
4
- Lanes.Data.Config.csrf_token = options.csrf
5
- Lanes.Data.Config.api_path = options.api_path
6
- Lanes.Extensions.setBootstrapData(options);
7
-
8
- }
@@ -1,63 +0,0 @@
1
-
2
- # a simple reimplentation
3
- # to use traffic cop
4
- methodMap = {
5
- 'create': 'POST',
6
- 'update': 'PUT',
7
- 'patch': 'PATCH',
8
- 'delete': 'DELETE',
9
- 'read': 'GET'
10
- }
11
-
12
- getValue = (object, prop)->
13
- if !(object && object[prop])
14
- return null;
15
- return if _.isFunction(object[prop]) then object[prop]() else object[prop];
16
-
17
-
18
- urlError = ->
19
- throw new Error('A "url" property or function must be specified')
20
-
21
-
22
- paramsMap = {
23
- fields : 'f'
24
- with : 'w'
25
- query : 'q'
26
- include : 'i'
27
- order : 'o'
28
- limit : 'l'
29
- start : 's'
30
- format : 'df'
31
- }
32
-
33
- Lanes.Data.Sync = (method, model, options={})->
34
-
35
- query = {}
36
- for key, value of options
37
- query[ paramsMap[key] ] = value if paramsMap[key]
38
-
39
- # Default JSON-request options.
40
- params = {
41
- type: methodMap[method]
42
- dataType: "json"
43
- data: query
44
- }
45
-
46
- # Ensure that we have a URL.
47
- params.url = _.result(model, "url") or urlError() unless options.url
48
- params.url += '.json'
49
- params.headers = {
50
- X_CSRF_TOKEN: Lanes.Data.Config.csrf_token
51
- }
52
- params.contentType = "application/json"
53
- if options.data || _.contains(['create','update','patch'], method)
54
- params.data = JSON.stringify( options.data || model.dataForSave(options) )
55
- delete options.data
56
-
57
- # Don't process data on a non-GET request.
58
- #params.processData = false if params.type isnt "GET"
59
-
60
- # Make the request, allowing the user to override any Ajax options.
61
- xhr = options.xhr = Lanes.$.ajax(_.extend(params, options))
62
- model.trigger "request", model, xhr, options
63
- xhr
@@ -1,5 +0,0 @@
1
- describe "<%= class_name %> Model Suite", ->
2
-
3
- it "can be instantiated", ->
4
- model = new Lanes.<%= namespace.camelize %>.Data.<%= class_name %>()
5
- expect(model).toEqual(jasmine.any(Lanes.<%= namespace.camelize %>.Data.<%= class_name %>));
@@ -1,43 +0,0 @@
1
- module Lanes
2
- class SpecAssetExpander
3
-
4
- def expand(src_dir, src_path)
5
- pathname = src_path.gsub(/^\/?assets\//, '').gsub(/\.js$/, '')
6
-
7
- asset_bundle.assets(pathname).flat_map { |asset|
8
- "/#{asset.gsub(/^\//, '')}?body=true"
9
- }
10
- end
11
-
12
- private
13
-
14
- def asset_bundle
15
- return AssetBundle.new
16
- end
17
-
18
- class AssetBundle
19
- def assets(pathname)
20
- context.get_original_assets(pathname)
21
- end
22
-
23
- private
24
-
25
- def context
26
- @context ||= ActionView::Base.new.extend(GetOriginalAssetsHelper)
27
- end
28
-
29
- module GetOriginalAssetsHelper
30
- def get_original_assets(pathname)
31
- assets_environment.find_asset(pathname).to_a.map do |processed_asset|
32
- case processed_asset.content_type
33
- when "text/css"
34
- path_to_stylesheet(processed_asset.logical_path, debug: true)
35
- when "application/javascript"
36
- path_to_javascript(processed_asset.logical_path, debug: true)
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end