lanes 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/appy-app/.gitignore +3 -0
  3. data/appy-app/Gemfile +6 -0
  4. data/appy-app/Guardfile +13 -0
  5. data/appy-app/Rakefile +2 -0
  6. data/appy-app/client/appy-app/Extension.coffee +7 -0
  7. data/appy-app/client/appy-app/Router.coffee +4 -0
  8. data/appy-app/client/appy-app/components/.gitkeep +0 -0
  9. data/appy-app/client/appy-app/controllers/.gitkeep +0 -0
  10. data/appy-app/client/appy-app/index.js +21 -0
  11. data/appy-app/client/appy-app/models/.gitkeep +0 -0
  12. data/appy-app/client/appy-app/models/Base.coffee +5 -0
  13. data/appy-app/client/appy-app/screens/.gitkeep +0 -0
  14. data/appy-app/client/appy-app/screens/Base.coffee +10 -0
  15. data/appy-app/client/appy-app/styles.scss +1 -0
  16. data/appy-app/client/appy-app/views/.gitkeep +0 -0
  17. data/appy-app/client/appy-app/views/Base.coffee +5 -0
  18. data/appy-app/config/database.yml +9 -0
  19. data/appy-app/config/lanes.rb +7 -0
  20. data/appy-app/config/routes.rb +2 -0
  21. data/appy-app/config/screens.rb +8 -0
  22. data/appy-app/config.ru +5 -0
  23. data/appy-app/db/.gitkeep +0 -0
  24. data/appy-app/lib/appy-app/extension.rb +13 -0
  25. data/appy-app/lib/appy-app/model.rb +11 -0
  26. data/appy-app/lib/appy-app/models/empty.rb +0 -0
  27. data/appy-app/lib/appy-app/version.rb +3 -0
  28. data/appy-app/lib/appy-app.rb +14 -0
  29. data/appy-app/spec/appy-app/helpers/AppyAppHelpers.coffee +5 -0
  30. data/appy-app/spec/appy-app/screens/Base.coffee +5 -0
  31. data/appy-app/spec/server/spec_helpers.rb +16 -0
  32. data/client/{lanes/styles/fonts → fonts/lanes}/icomoon.eot +0 -0
  33. data/client/{lanes/styles/fonts → fonts/lanes}/icomoon.svg +0 -0
  34. data/client/{lanes/styles/fonts → fonts/lanes}/icomoon.ttf +0 -0
  35. data/client/{lanes/styles/fonts → fonts/lanes}/icomoon.woff +0 -0
  36. data/client/{lanes/styles/fonts → fonts/lanes}/selection.json +0 -0
  37. data/client/images/{ajax-loader.gif → lanes/ajax-loader.gif} +0 -0
  38. data/client/images/{dataTables → lanes/dataTables}/Sorting icons.psd +0 -0
  39. data/client/images/{dataTables → lanes/dataTables}/back_disabled.png +0 -0
  40. data/client/images/{dataTables → lanes/dataTables}/back_enabled.png +0 -0
  41. data/client/images/{dataTables → lanes/dataTables}/back_enabled_hover.png +0 -0
  42. data/client/images/{dataTables → lanes/dataTables}/favicon.ico +0 -0
  43. data/client/images/{dataTables → lanes/dataTables}/forward_disabled.png +0 -0
  44. data/client/images/{dataTables → lanes/dataTables}/forward_enabled.png +0 -0
  45. data/client/images/{dataTables → lanes/dataTables}/forward_enabled_hover.png +0 -0
  46. data/client/images/{dataTables → lanes/dataTables}/loading-background.png +0 -0
  47. data/client/images/{dataTables → lanes/dataTables}/sort_asc.png +0 -0
  48. data/client/images/{dataTables → lanes/dataTables}/sort_asc_disabled.png +0 -0
  49. data/client/images/{dataTables → lanes/dataTables}/sort_both.png +0 -0
  50. data/client/images/{dataTables → lanes/dataTables}/sort_desc.png +0 -0
  51. data/client/images/{dataTables → lanes/dataTables}/sort_desc_disabled.png +0 -0
  52. data/client/images/lanes/logo-sm.png +0 -0
  53. data/client/lanes/Config.coffee +19 -0
  54. data/client/lanes/components/grid/styles.scss +6 -6
  55. data/client/lanes/index.js +1 -0
  56. data/client/lanes/index.scss.erb +5 -5
  57. data/client/lanes/models/Base.coffee +11 -11
  58. data/client/lanes/models/Bootstrap.coffee +0 -2
  59. data/client/lanes/models/ChangeMonitor.coffee +16 -13
  60. data/client/lanes/models/Collection.coffee +2 -4
  61. data/client/lanes/models/ModelAssociations.coffee +13 -28
  62. data/client/lanes/models/Sync.coffee +1 -1
  63. data/client/lanes/screens/Instance.coffee +1 -0
  64. data/client/lanes/styles/{fonts/style.scss → font-definitions.scss} +0 -0
  65. data/client/lanes/styles/fonts.scss +1 -1
  66. data/client/lanes/styles/plugins/overlay.scss +1 -1
  67. data/client/lanes/testing/ModelSaver.coffee +23 -0
  68. data/client/lanes/testing/index.js +4 -0
  69. data/client/lanes/workspace/ActiveScreensSwitcher.coffee +2 -3
  70. data/client/lanes/workspace/Pages.coffee +6 -11
  71. data/client/lanes/workspace/styles/header.scss +1 -1
  72. data/lanes.gemspec +1 -1
  73. data/lib/lanes/access/authentication_provider.rb +2 -2
  74. data/lib/lanes/access/config/routes.rb +1 -1
  75. data/lib/lanes/access/role.rb +5 -0
  76. data/lib/lanes/access/role_collection.rb +9 -6
  77. data/lib/lanes/access/roles/administrator.rb +3 -10
  78. data/lib/lanes/api/request_wrapper.rb +21 -8
  79. data/lib/lanes/api/root.rb +2 -4
  80. data/lib/lanes/api/sprockets_extension.rb +8 -6
  81. data/lib/lanes/api/test_specs.rb +1 -0
  82. data/lib/lanes/capistrano.rb +18 -0
  83. data/lib/lanes/command/app.rb +2 -6
  84. data/lib/lanes/command/generate_model.rb +11 -11
  85. data/lib/lanes/command/generate_view.rb +1 -1
  86. data/lib/lanes/command/named_command.rb +7 -4
  87. data/lib/lanes/concerns/set_attribute_data.rb +1 -1
  88. data/lib/lanes/configuration.rb +1 -0
  89. data/lib/lanes/db.rb +1 -0
  90. data/lib/lanes/extension/definition.rb +16 -4
  91. data/lib/lanes/extension.rb +1 -4
  92. data/lib/lanes/version.rb +1 -1
  93. data/spec/server/command-reference-files/initial/.gitignore +3 -0
  94. data/spec/server/command-reference-files/initial/Gemfile +6 -0
  95. data/spec/server/command-reference-files/initial/Guardfile +13 -0
  96. data/spec/server/command-reference-files/initial/Rakefile +2 -0
  97. data/spec/server/command-reference-files/initial/client/appy-app/Extension.coffee +7 -0
  98. data/spec/server/command-reference-files/initial/client/appy-app/Router.coffee +4 -0
  99. data/spec/server/command-reference-files/initial/client/appy-app/components/.gitkeep +0 -0
  100. data/spec/server/command-reference-files/initial/client/appy-app/controllers/.gitkeep +0 -0
  101. data/spec/server/command-reference-files/initial/client/appy-app/index.js +21 -0
  102. data/spec/server/command-reference-files/initial/client/appy-app/models/.gitkeep +0 -0
  103. data/spec/server/command-reference-files/initial/client/appy-app/models/Base.coffee +5 -0
  104. data/spec/server/command-reference-files/initial/client/appy-app/screens/.gitkeep +0 -0
  105. data/spec/server/command-reference-files/initial/client/appy-app/screens/Base.coffee +3 -0
  106. data/spec/server/command-reference-files/initial/client/appy-app/styles.scss +1 -0
  107. data/spec/server/command-reference-files/initial/client/appy-app/views/.gitkeep +0 -0
  108. data/spec/server/command-reference-files/initial/client/appy-app/views/Base.coffee +5 -0
  109. data/spec/server/command-reference-files/initial/config/database.yml +9 -0
  110. data/spec/server/command-reference-files/initial/config/lanes.rb +7 -0
  111. data/spec/server/command-reference-files/initial/config/routes.rb +2 -0
  112. data/spec/server/command-reference-files/initial/config/screens.rb +0 -0
  113. data/spec/server/command-reference-files/initial/config.ru +5 -0
  114. data/spec/server/command-reference-files/initial/db/.gitkeep +0 -0
  115. data/spec/server/command-reference-files/initial/lib/appy-app/extension.rb +13 -0
  116. data/spec/server/command-reference-files/initial/lib/appy-app/model.rb +11 -0
  117. data/spec/server/command-reference-files/initial/lib/appy-app/models/empty.rb +0 -0
  118. data/spec/server/command-reference-files/initial/lib/appy-app/version.rb +3 -0
  119. data/spec/server/command-reference-files/initial/lib/appy-app.rb +12 -0
  120. data/spec/server/command-reference-files/initial/spec/appy-app/helpers/AppyAppHelpers.coffee +5 -0
  121. data/spec/server/command-reference-files/initial/spec/appy-app/screens/Base.coffee +5 -0
  122. data/spec/server/command-reference-files/initial/spec/server/spec_helpers.rb +16 -0
  123. data/spec/server/command-reference-files/model/client/appy-app/models/TestTest.coffee +9 -0
  124. data/spec/server/command-reference-files/model/config/routes.rb +3 -0
  125. data/spec/server/command-reference-files/model/db/migrate/20150218032025_create_test_tests.rb +10 -0
  126. data/spec/server/command-reference-files/model/lib/appy-app/models/test_test.rb +7 -0
  127. data/spec/server/command-reference-files/model/spec/appy-app/models/TestTestSpec.coffee +5 -0
  128. data/spec/server/command-reference-files/model/spec/fixtures/appy-app/test_test.yml +11 -0
  129. data/spec/server/command-reference-files/model/spec/server/test_test_spec.rb +10 -0
  130. data/spec/server/command-reference-files/screen/client/appy-app/screens/ready-set-go/ReadySetGo.coffee +7 -0
  131. data/spec/server/command-reference-files/screen/client/appy-app/screens/ready-set-go/index.js +5 -0
  132. data/spec/server/command-reference-files/screen/client/appy-app/screens/ready-set-go/index.scss +8 -0
  133. data/spec/server/command-reference-files/screen/client/appy-app/screens/ready-set-go/layout.html +3 -0
  134. data/spec/server/command-reference-files/screen/config/screens.rb +9 -0
  135. data/spec/server/command-reference-files/screen/spec/appy-app/screens/ready-set-go/ReadySetGoSpec.coffee +5 -0
  136. data/spec/server/command-reference-files/view/client/appy-app/views/BigView.coffee +10 -0
  137. data/spec/server/command-reference-files/view/spec/appy-app/views/BigViewSpec.coffee +5 -0
  138. data/spec/server/command_spec.rb +40 -15
  139. data/templates/client/screens/Base.coffee +3 -0
  140. data/templates/client/screens/Screen.coffee +1 -1
  141. data/templates/config/screen.rb +0 -1
  142. data/templates/db/create_table_migration.rb +1 -1
  143. data/templates/lib/namespace.rb +2 -4
  144. metadata +118 -25
  145. data/client/images/logo-sm.png +0 -0
  146. data/client/lanes/models/Config.coffee +0 -10
@@ -0,0 +1,23 @@
1
+ class Lanes.Testing.ModelSaver
2
+
3
+ @perform: (model,completion)->
4
+ saver = new Lanes.Testing.ModelSaver(completion)
5
+ saver.save(model)
6
+
7
+ constructor: (@completion)->
8
+ _.bindAll(this,'success','error')
9
+ spyOn(this, 'success').and.callThrough()
10
+ spyOn(this, 'error').and.callThrough()
11
+
12
+ success: ->
13
+ this.notification.resolve(this)
14
+ _.defer(@completion) if @completion
15
+
16
+ error: ->
17
+ this.notification.resolve(this)
18
+ _.defer(@completion) if @completion
19
+
20
+ save: (model)->
21
+ model.save(this)
22
+ this.notification = new _.DeferredPromise
23
+ this.notification.promise
@@ -0,0 +1,4 @@
1
+ //=require_self
2
+ //=require ./ModelSaver
3
+
4
+ Lanes.Testing = ( Lanes.Testing || {} )
@@ -53,11 +53,10 @@ class Lanes.Workspace.ActiveScreenSwitcher extends Lanes.Views.Base
53
53
  super
54
54
  _.bindAll(this, 'resetShownControls')
55
55
  @collection = Lanes.Screens.Definitions.displaying
56
- this.listenTo( @collection, "change:active", this.onActiveChange )
57
- this.listenTo( this.viewport, "change:width", this.resetShownControls )
56
+ this.listenTo( @collection, "change:active", this.onActiveChange)
57
+ this.listenTo( this.viewport, "change:width", this.resetShownControls)
58
58
  this.listenTo( Lanes.current_user, "change:isLoggedIn", this.closeScreens)
59
59
 
60
-
61
60
  closeScreens: ->
62
61
  @collection.reset()
63
62
 
@@ -11,7 +11,6 @@ class Lanes.Workspace.Pages extends Lanes.Views.Base
11
11
  'model.screen_menu_size': { type: 'class' }
12
12
  'model.popover_menu': { type: 'booleanClass', name: 'popover-menu' }
13
13
 
14
-
15
14
  subviews:
16
15
  menu:
17
16
  view: 'ScreensMenu'
@@ -19,26 +18,22 @@ class Lanes.Workspace.Pages extends Lanes.Views.Base
19
18
  ui:
20
19
  screen: '.screen'
21
20
 
22
-
23
21
  initialize: (options)->
24
- this.listenTo( Lanes.Screens.Definitions.displaying, "change:active", this.onActiveChange )
25
- this.listenTo( Lanes.Screens.Definitions.displaying, "remove", this.onRemove )
26
- #this.listenTo( @model,'change:screen_menu_position', this.moveScreensMenu )
22
+ this.listenTo( Lanes.current_user, "change:isLoggedIn", this.closeScreens)
23
+ this.listenTo( Lanes.Screens.Definitions.displaying, "change:active", this.onActiveChange)
27
24
  super
28
25
 
29
- # moveScreensMenu: ->
30
- # return unless 'side' == this.viewport.screen_menu_position
31
- # this.ui.screens_menu_container.append( this.viewport.menu_view.el )
26
+ closeScreens: ->
27
+ this.ui.screen.children().detach()
32
28
 
33
- onRemove: (sv)->
34
- sv.view.remove()
29
+ onRemove: (screen)->
30
+ screen.view.remove()
35
31
 
36
32
  onActiveChange: (screen,active)->
37
33
  view = screen.view
38
34
  view.parent = this
39
35
  unless view.rendered
40
36
  view.render()
41
-
42
37
  if active
43
38
  this.ui.screen.append( view.el )
44
39
  else
@@ -22,7 +22,7 @@
22
22
  height: 48px;
23
23
  width: 150px;
24
24
  margin: 2px;
25
- background: url(asset_path('images/logo-sm.png')) no-repeat;
25
+ background: url(asset_path('images/lanes/logo-sm.png')) no-repeat;
26
26
  }
27
27
 
28
28
  .navbar-toggle, .screens-menu-toggle {
data/lanes.gemspec CHANGED
@@ -54,5 +54,5 @@ Gem::Specification.new do |spec|
54
54
  spec.add_development_dependency "bundler", "~> 1.5"
55
55
  spec.add_development_dependency "growl", "~> 1.0"
56
56
  spec.add_development_dependency "pry-byebug", "~> 2.0"
57
-
57
+ spec.add_development_dependency "diffy", "~> 3.0"
58
58
  end
@@ -40,14 +40,14 @@ module Lanes
40
40
  end
41
41
  end
42
42
 
43
+
43
44
  def wrap_request(model, req)
44
45
  if allowed_access_to?(model)
45
46
  ::Lanes::User.scoped_to(current_user) do | user |
46
- Lanes.logger.debug "User : #{user.id} (#{user.login})"
47
- Lanes.logger.debug "Params : #{@params}"
48
47
  yield
49
48
  end
50
49
  else
50
+ Lanes.logger.warn "Unauthorized access attempted to #{req}"
51
51
  req.halt( 401, Oj.dump({
52
52
  success:false, errors: {user: "Access Denied"}, message: "Access Denied"
53
53
  }))
@@ -15,7 +15,7 @@ module Lanes
15
15
 
16
16
  delete "/user-session/:id.json" do
17
17
  session.destroy
18
- wrap_json_reply do
18
+ wrap_request do
19
19
  { success: true, message: "Logout succeeded", data: {} }
20
20
  end
21
21
  end
@@ -53,6 +53,11 @@ module Lanes
53
53
  ALL
54
54
  end
55
55
 
56
+ # By default a role can only access if it's type is included in the
57
+ # array of acceptable roles. An Admin role may provide a custom implementation
58
+ def can_access_locked_roles?(roles)
59
+ roles.include?(self)
60
+ end
56
61
  end
57
62
  end
58
63
 
@@ -49,20 +49,23 @@ module Lanes
49
49
 
50
50
  private
51
51
 
52
+ def role_types
53
+ @role_types ||= @roles.map(&:class)
54
+ end
55
+
52
56
  def model_to_class(model)
53
- model.is_a?(Class) ? model : model.class
57
+ model.is_a?(Class) ? model : model.class
54
58
  end
55
59
 
56
60
  # Test if the given roles grant access to the model
57
61
  def test_access(model, attribute, access_type)
58
62
  # Check if the attribute is locked
59
63
  # If it is, the locks determine access, otherwise use the model's grants
60
- roles = LockedFields.roles_needed_for(model, attribute, access_type)
61
- if roles.empty?
62
- return !!@roles.detect { |role| yield role }.present?
64
+ locked_to_roles = LockedFields.roles_needed_for(model, attribute, access_type)
65
+ if locked_to_roles.none?
66
+ return @roles.detect{ |role| yield role }.present?
63
67
  else
64
- roles.any?{ |role| role.models_include?(model) }
65
- #!!roles.find { |role| @roles.map(&:class).include?(role) }
68
+ role_types.any?{|role| role.can_access_locked_roles?(locked_to_roles) }
66
69
  end
67
70
  end
68
71
 
@@ -5,18 +5,11 @@ module Lanes
5
5
 
6
6
  class Administrator < Role
7
7
 
8
- def self.grant_global_access!
9
-
10
- self.grant( *Lanes::Model.descendants )
11
-
12
- LockedFields.definitions.each do | klass, fields |
13
- fields.each do |field, grants|
14
- grants.push({ role: self, only: nil })
15
- end
16
- end
8
+ # The admin can access all the things
9
+ def self.can_access_locked_roles?(roles)
10
+ true
17
11
  end
18
12
 
19
-
20
13
  def can_read?(model)
21
14
  true
22
15
  end
@@ -5,30 +5,30 @@ module Lanes
5
5
  class << self
6
6
 
7
7
  def get(*args)
8
- wrap_request(*args) do |controller|
8
+ make_handler(*args) do |controller|
9
9
  controller.perform_retrieval
10
10
  end
11
11
  end
12
12
 
13
13
  def post(*args)
14
- wrap_request(*args) do |controller|
14
+ make_handler(*args) do |controller|
15
15
  controller.perform_creation
16
16
  end
17
17
  end
18
18
 
19
19
  def update(*args)
20
- wrap_request(*args) do |controller|
20
+ make_handler(*args) do |controller|
21
21
  controller.perform_update
22
22
  end
23
23
  end
24
24
 
25
25
  def delete(*args)
26
- wrap_request(*args) do |controller|
26
+ make_handler(*args) do |controller|
27
27
  controller.perform_destroy
28
28
  end
29
29
  end
30
30
 
31
- def wrap_request(model, controller, parent_attribute)
31
+ def make_handler(model, controller, parent_attribute)
32
32
  lambda do
33
33
  authentication = Lanes::API::AuthenticationProvider.new(
34
34
  request_type: request.request_method,
@@ -40,7 +40,7 @@ module Lanes
40
40
  params[:nested_attribute] = Hash[ parent_attribute,
41
41
  params[parent_attribute] ]
42
42
  end
43
- wrap_json_reply do
43
+ wrap_request(!request.get?) do
44
44
  yield controller.new(model, authentication, params, data)
45
45
  end
46
46
  end
@@ -48,8 +48,21 @@ module Lanes
48
48
  end
49
49
  end
50
50
 
51
- def wrap_json_reply
52
- response = yield
51
+ def log_request
52
+ Lanes.logger.info "UserID: #{session['user_id']}, Params: #{request.params}"
53
+ end
54
+
55
+ def wrap_request(with_transaction=true)
56
+ response = { success: false, message: "No response was generated" }
57
+ log_request
58
+ if with_transaction
59
+ Lanes::Model.transaction do
60
+ response = yield
61
+ raise ActiveRecord::StatementInvalid if request.env['X_ROLLBACK_AFTER_REQUEST']
62
+ end
63
+ else
64
+ response = yield
65
+ end
53
66
  if false == response[:success]
54
67
  status(406)
55
68
  end
@@ -9,19 +9,17 @@ require_relative 'pub_sub'
9
9
  module Lanes
10
10
  module API
11
11
  class Root < Sinatra::Application
12
- set :environment, Lanes.config.environment
13
12
  Lanes.config.get(:environment) do | env |
14
13
  set :environment, env
15
14
  end
16
15
  register SprocketsExtension
17
16
  helpers RequestWrapper
18
17
  helpers HelperMethods
18
+ use Rack::Session::Cookie, :key => 'lanes.session', :secret => Lanes.config.session_secret_key_base
19
+ use ActiveRecord::ConnectionAdapters::ConnectionManagement
19
20
  not_found do
20
21
  Oj.dump({ message: "endpoint not found", success: false })
21
22
  end
22
-
23
- use Rack::Session::Cookie, :key => 'lanes.session', :secret => Lanes.config.session_secret_key_base
24
- use ActiveRecord::ConnectionAdapters::ConnectionManagement
25
23
  error do
26
24
  Oj.dump({
27
25
  success: false,
@@ -14,13 +14,15 @@ module Lanes
14
14
  env = ::Sprockets::Environment.new
15
15
  Lanes::API::SprocketsExtension.configure(env, compress:true)
16
16
  manifest = Sprockets::Manifest.new( env.index, "public/assets/manifest.json" )
17
- manifest.compile('lanes/workspace.js', 'lanes/workspace.css',
18
- 'lanes/minimal.js', 'lanes/minimal.css' )
19
- Extensions.each{|ext|
20
- manifest.compile(ext.client_images.map(&:to_s))
21
- }
17
+ manifest.compile('lanes.js', 'lanes.css')
18
+ Extensions.each do |ext|
19
+ ext.each_static_asset do | asset |
20
+ manifest.compile( asset.to_s )
21
+ end
22
+ end
22
23
  Screen.each do | screen |
23
- manifest.compile( screen.assets ) unless screen.assets.blank?
24
+ assets = screen.assets
25
+ manifest.compile( assets ) unless assets.empty?
24
26
  end
25
27
  end
26
28
 
@@ -18,6 +18,7 @@ module Lanes
18
18
  end
19
19
 
20
20
  def js_files
21
+ [ '/assets/lanes/testing' ] +
21
22
  urlpath(Jasmine::Core.js_files) +
22
23
  urlpath(Jasmine::Core.boot_files) +
23
24
  urlpath(spec_files(extension.identifier))
@@ -0,0 +1,18 @@
1
+ set :linked_dirs, %w{config}
2
+
3
+ namespace :deploy do
4
+
5
+ desc 'Runs bundle exec lanes db migrate'
6
+ task :migrate => [:set_rails_env] do
7
+ on primary fetch(:migration_role) do
8
+ info '[deploy:migrate] Run `lanes db migrate`'
9
+ within release_path do
10
+ with rails_env: fetch(:rails_env) do
11
+ execute :bundle, "exec lanes db migrate"
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ after 'deploy:updated', 'deploy:migrate'
18
+ end
@@ -62,13 +62,9 @@ module Lanes
62
62
  @template = "<div><h1>Base Screen</h1></div>"
63
63
  options[:description] = "Base Screen for #{namespace.titleize}"
64
64
  options[:fileless] = true
65
- screen_id = 'base'
66
- template "client/screens/Screen.coffee", "#{client_dir}/screens/Base.coffee"
65
+ template "client/screens/Base.coffee", "#{client_dir}/screens/Base.coffee"
67
66
  template "spec/client/Screen.coffee", "#{spec_dir}/screens/Base.coffee"
68
- insert_into_file "config/screens.rb", after: "" do
69
- source = File.expand_path(find_in_source_paths("config/screen.rb"))
70
- ERB.new(::File.binread(source), nil, "-","@output_buffer").result(binding)
71
- end
67
+ create_file "config/screens.rb", ""
72
68
  end
73
69
 
74
70
  end
@@ -18,27 +18,23 @@ module Lanes
18
18
 
19
19
  def set_variables
20
20
  super
21
- if name=~/::/
22
- (@namespace,@name) = name.split("::")
23
- else
24
- @namespace = computed_namespace
25
- end
26
21
  @file_name = name.underscore
27
- @table_name = namespace + "_" + name.tableize
22
+ prefix = extension.db_table_prefix
23
+ @table_name = prefix ? "#{prefix}_#{name.tableize}" : name.tableize
28
24
  end
29
25
 
30
26
  def create_migration
31
27
  migration = exising_migration ||
32
- Time.now.utc.strftime("%Y%m%d%H%M%S") + "_create_#{table_name}.rb"
28
+ migration_timestamp + "_create_#{table_name}.rb"
33
29
  self.fields = fields.map{ |field| ModelAttribute.parse(field) }
34
30
  template "db/create_table_migration.rb", "db/migrate/#{migration}"
35
31
  end
36
32
 
37
33
  def create_model
38
- template "lib/namespace/model.rb", "lib/#{namespace}/models/#{file_name}.rb"
34
+ template "lib/namespace/model.rb", "lib/#{identifier}/models/#{file_name}.rb"
39
35
  template "spec/server/model_spec.rb", "spec/server/#{file_name}_spec.rb"
40
36
  template "spec/fixtures/namespace/model.yml",
41
- "spec/fixtures/#{namespace}/#{file_name}.yml"
37
+ "spec/fixtures/#{identifier}/#{file_name}.yml"
42
38
  end
43
39
 
44
40
  def create_client
@@ -50,8 +46,8 @@ module Lanes
50
46
  end
51
47
 
52
48
  def add_route
53
- insert_into_file "config/routes.rb", before: "end" do
54
- " resources #{namespace.camelize}::#{class_name}\n"
49
+ insert_into_file "config/routes.rb", after: /.*Lanes::API.routes.draw.*?\n/ do
50
+ " resources #{namespace}::#{class_name}\n"
55
51
  end
56
52
  end
57
53
 
@@ -66,6 +62,10 @@ module Lanes
66
62
  migrations.any? ? migrations.first.basename.to_s : nil
67
63
  end
68
64
 
65
+ def migration_timestamp
66
+ ENV['MIGRATION_TIMESTAMP'] || Time.now.utc.strftime("%Y%m%d%H%M%S")
67
+ end
68
+
69
69
  def computed_namespace
70
70
  # find a file and directory with the same basename
71
71
  entries = Dir.glob(self.destination_root + "/lib/*")
@@ -25,7 +25,7 @@ module Lanes
25
25
  # option :from, :required => true
26
26
 
27
27
  def create_screen
28
- template "client/views/View.coffee", "#{client_dir}/#{name.classify}.coffee"
28
+ template "client/views/View.coffee", "#{client_dir}/#{class_name}.coffee"
29
29
  template "spec/client/views/ViewSpec.coffee", \
30
30
  "#{spec_dir}/#{class_name}Spec.coffee"
31
31
  end
@@ -13,10 +13,8 @@ module Lanes
13
13
  end
14
14
 
15
15
  def load_namespace
16
- @namespace = options[:namespace] ||
17
- Command.load_current_extension(raise_on_fail:true)
18
- .identifier.underscore.camelize
19
- @identifier = @namespace.underscore.dasherize
16
+ @identifier = extension.identifier
17
+ @namespace = options[:namespace] || @identifier.underscore.camelize
20
18
  end
21
19
 
22
20
  def set_variables
@@ -25,6 +23,11 @@ module Lanes
25
23
  @client_dir = "client/#{identifier}"
26
24
  end
27
25
 
26
+ protected
27
+
28
+ def extension
29
+ @extension ||= Command.load_current_extension(raise_on_fail:true)
30
+ end
28
31
  end
29
32
  end
30
33
  end
@@ -100,7 +100,7 @@ module Lanes::Concerns
100
100
 
101
101
  association = self.association(name)
102
102
  if value.is_a?(Hash) && [:belongs_to,:has_one].include?(association.reflection.macro)
103
- target = association.target || association.build
103
+ target = send(name) || association.build
104
104
  result[name] = target.set_attribute_data(value, user)
105
105
  elsif value.is_a?(Array) && :has_many == association.reflection.macro
106
106
  result[name] = _set_attribute_data_from_collection(association, value, user)
@@ -70,6 +70,7 @@ module Lanes
70
70
  config_option :root_view, 'Lanes.Workspace.Layout'
71
71
  config_option :initial_workspace_screen_id, ''
72
72
  config_option :specs_root, Pathname.getwd
73
+ config_option :static_asset_types, ['images','fonts']
73
74
  end
74
75
 
75
76
  class << self
data/lib/lanes/db.rb CHANGED
@@ -14,6 +14,7 @@ module Lanes
14
14
  ::ActiveRecord::Base.configurations = config
15
15
  ::ActiveRecord::Base.establish_connection( ::ActiveRecord::Base.configurations[ env ] )
16
16
  end
17
+ ActiveRecord::Base.logger = Lanes.logger
17
18
  end
18
19
 
19
20
  def load_seed
@@ -21,6 +21,8 @@ module Lanes
21
21
  # Array of Pathname's to add to sprockets
22
22
  attr_accessor_with_default :root_path
23
23
 
24
+ attr_accessor_with_default :db_table_prefix
25
+
24
26
  # Does the extension use PubSub functionality
25
27
  class_attribute :uses_pub_sub
26
28
 
@@ -52,10 +54,20 @@ module Lanes
52
54
  [ root_path.join('client') ]
53
55
  end
54
56
 
55
- def client_images
56
- images = []
57
- root_path.join('client','images').find{|path| images << path if path.file? }
58
- images
57
+ def static_paths
58
+ client_paths.each_with_object(Array.new) do |path, result|
59
+ Lanes.config.static_asset_types.each do | prefix |
60
+ result << path.join(prefix) if path.join(prefix).exist?
61
+ end
62
+ end
63
+ end
64
+
65
+ def each_static_asset
66
+ static_paths.each do | path |
67
+ path.find.each do | entry |
68
+ yield entry if entry.file?
69
+ end
70
+ end
59
71
  end
60
72
 
61
73
  def route(route_set)
@@ -95,6 +95,7 @@ module Lanes
95
95
  controlling_extension: controlling.identifier,
96
96
  root_view: Lanes.config.root_view,
97
97
  api_path: Lanes.config.mounted_at,
98
+ environment: Lanes.config.environment,
98
99
  initial_workspace_screen_id: Lanes.config.initial_workspace_screen_id,
99
100
  pub_sub: require_pub_sub?
100
101
  }
@@ -104,10 +105,6 @@ module Lanes
104
105
  return data
105
106
  end
106
107
 
107
- def client_images
108
- each{|ext| }
109
- end
110
-
111
108
  def load_controlling_config
112
109
  config_file = self.controlling.root_path.join('config','lanes.rb')
113
110
  if config_file.exist?
data/lib/lanes/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Lanes
2
2
 
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
 
5
5
  end
@@ -0,0 +1,3 @@
1
+ public/assets
2
+ tmp/cache
3
+ log/*log
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "lanes", '0.1.5'
4
+
5
+ gem "rake"
6
+ gem 'puma'
@@ -0,0 +1,13 @@
1
+ require "lanes/guard_tasks"
2
+
3
+ Lanes::GuardTasks.run(self, name: "appy-app") do | tests |
4
+
5
+ tests.client do
6
+
7
+ end
8
+
9
+ tests.server do
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'lib/appy-app'
2
+ require 'lanes/rake_tasks'
@@ -0,0 +1,7 @@
1
+ class AppyApp.Extension extends Lanes.Extensions.Base
2
+
3
+ FILE: FILE
4
+
5
+ identifier: "appy-app"
6
+
7
+ setBootstrapData: (data)->
@@ -0,0 +1,4 @@
1
+ class AppyApp.Router extends Lanes.Screens.Router
2
+
3
+ routes:
4
+ {}
@@ -0,0 +1,21 @@
1
+ //=require ./models/Base
2
+ //=require ./views/Base
3
+ //=require_tree ./models
4
+ //=require_tree ./views
5
+ //=require_tree ./components
6
+ //=require ./screens/Base
7
+ //=require ./Router
8
+ //=require ./Extension
9
+
10
+ /*
11
+ Files located in the above directories are part of the default
12
+ Javascript build and are downloaded to the client on the initial
13
+ request.
14
+
15
+ Accordingly, only essential files should be included here. Code that
16
+ relates to a screen should be placed in the "screens" directory,
17
+ where it will be loaded dynamically when the screen is displayed.
18
+
19
+ Alternatively, feel free to modify the require statements above to
20
+ only include the paths you need.
21
+ */
@@ -0,0 +1,5 @@
1
+ # All models in AppyApp will inherit from
2
+ # this common base class.
3
+ class AppyApp.Models.Base extends Lanes.Models.Base
4
+
5
+ abstractClass: true
@@ -0,0 +1,3 @@
1
+ class AppyApp.Screens.Base extends Lanes.Screens.Base
2
+
3
+ abstractClass: true
@@ -0,0 +1 @@
1
+ /* Enter styles for your application in scss format here */
@@ -0,0 +1,5 @@
1
+ # All views in AppyApp will inherit from
2
+ # this common base class.
3
+ class AppyApp.Views.Base extends Lanes.Views.Base
4
+
5
+ abstractClass: true