lanes 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/appy-app/.gitignore +3 -0
- data/appy-app/Gemfile +6 -0
- data/appy-app/Guardfile +13 -0
- data/appy-app/Rakefile +2 -0
- data/appy-app/client/appy-app/Extension.coffee +7 -0
- data/appy-app/client/appy-app/Router.coffee +4 -0
- data/appy-app/client/appy-app/components/.gitkeep +0 -0
- data/appy-app/client/appy-app/controllers/.gitkeep +0 -0
- data/appy-app/client/appy-app/index.js +21 -0
- data/appy-app/client/appy-app/models/.gitkeep +0 -0
- data/appy-app/client/appy-app/models/Base.coffee +5 -0
- data/appy-app/client/appy-app/screens/.gitkeep +0 -0
- data/appy-app/client/appy-app/screens/Base.coffee +10 -0
- data/appy-app/client/appy-app/styles.scss +1 -0
- data/appy-app/client/appy-app/views/.gitkeep +0 -0
- data/appy-app/client/appy-app/views/Base.coffee +5 -0
- data/appy-app/config/database.yml +9 -0
- data/appy-app/config/lanes.rb +7 -0
- data/appy-app/config/routes.rb +2 -0
- data/appy-app/config/screens.rb +8 -0
- data/appy-app/config.ru +5 -0
- data/appy-app/db/.gitkeep +0 -0
- data/appy-app/lib/appy-app/extension.rb +13 -0
- data/appy-app/lib/appy-app/model.rb +11 -0
- data/appy-app/lib/appy-app/models/empty.rb +0 -0
- data/appy-app/lib/appy-app/version.rb +3 -0
- data/appy-app/lib/appy-app.rb +14 -0
- data/appy-app/spec/appy-app/helpers/AppyAppHelpers.coffee +5 -0
- data/appy-app/spec/appy-app/screens/Base.coffee +5 -0
- data/appy-app/spec/server/spec_helpers.rb +16 -0
- data/client/{lanes/styles/fonts → fonts/lanes}/icomoon.eot +0 -0
- data/client/{lanes/styles/fonts → fonts/lanes}/icomoon.svg +0 -0
- data/client/{lanes/styles/fonts → fonts/lanes}/icomoon.ttf +0 -0
- data/client/{lanes/styles/fonts → fonts/lanes}/icomoon.woff +0 -0
- data/client/{lanes/styles/fonts → fonts/lanes}/selection.json +0 -0
- data/client/images/{ajax-loader.gif → lanes/ajax-loader.gif} +0 -0
- data/client/images/{dataTables → lanes/dataTables}/Sorting icons.psd +0 -0
- data/client/images/{dataTables → lanes/dataTables}/back_disabled.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/back_enabled.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/back_enabled_hover.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/favicon.ico +0 -0
- data/client/images/{dataTables → lanes/dataTables}/forward_disabled.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/forward_enabled.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/forward_enabled_hover.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/loading-background.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/sort_asc.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/sort_asc_disabled.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/sort_both.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/sort_desc.png +0 -0
- data/client/images/{dataTables → lanes/dataTables}/sort_desc_disabled.png +0 -0
- data/client/images/lanes/logo-sm.png +0 -0
- data/client/lanes/Config.coffee +19 -0
- data/client/lanes/components/grid/styles.scss +6 -6
- data/client/lanes/index.js +1 -0
- data/client/lanes/index.scss.erb +5 -5
- data/client/lanes/models/Base.coffee +11 -11
- data/client/lanes/models/Bootstrap.coffee +0 -2
- data/client/lanes/models/ChangeMonitor.coffee +16 -13
- data/client/lanes/models/Collection.coffee +2 -4
- data/client/lanes/models/ModelAssociations.coffee +13 -28
- data/client/lanes/models/Sync.coffee +1 -1
- data/client/lanes/screens/Instance.coffee +1 -0
- data/client/lanes/styles/{fonts/style.scss → font-definitions.scss} +0 -0
- data/client/lanes/styles/fonts.scss +1 -1
- data/client/lanes/styles/plugins/overlay.scss +1 -1
- data/client/lanes/testing/ModelSaver.coffee +23 -0
- data/client/lanes/testing/index.js +4 -0
- data/client/lanes/workspace/ActiveScreensSwitcher.coffee +2 -3
- data/client/lanes/workspace/Pages.coffee +6 -11
- data/client/lanes/workspace/styles/header.scss +1 -1
- data/lanes.gemspec +1 -1
- data/lib/lanes/access/authentication_provider.rb +2 -2
- data/lib/lanes/access/config/routes.rb +1 -1
- data/lib/lanes/access/role.rb +5 -0
- data/lib/lanes/access/role_collection.rb +9 -6
- data/lib/lanes/access/roles/administrator.rb +3 -10
- data/lib/lanes/api/request_wrapper.rb +21 -8
- data/lib/lanes/api/root.rb +2 -4
- data/lib/lanes/api/sprockets_extension.rb +8 -6
- data/lib/lanes/api/test_specs.rb +1 -0
- data/lib/lanes/capistrano.rb +18 -0
- data/lib/lanes/command/app.rb +2 -6
- data/lib/lanes/command/generate_model.rb +11 -11
- data/lib/lanes/command/generate_view.rb +1 -1
- data/lib/lanes/command/named_command.rb +7 -4
- data/lib/lanes/concerns/set_attribute_data.rb +1 -1
- data/lib/lanes/configuration.rb +1 -0
- data/lib/lanes/db.rb +1 -0
- data/lib/lanes/extension/definition.rb +16 -4
- data/lib/lanes/extension.rb +1 -4
- data/lib/lanes/version.rb +1 -1
- data/spec/server/command-reference-files/initial/.gitignore +3 -0
- data/spec/server/command-reference-files/initial/Gemfile +6 -0
- data/spec/server/command-reference-files/initial/Guardfile +13 -0
- data/spec/server/command-reference-files/initial/Rakefile +2 -0
- data/spec/server/command-reference-files/initial/client/appy-app/Extension.coffee +7 -0
- data/spec/server/command-reference-files/initial/client/appy-app/Router.coffee +4 -0
- data/spec/server/command-reference-files/initial/client/appy-app/components/.gitkeep +0 -0
- data/spec/server/command-reference-files/initial/client/appy-app/controllers/.gitkeep +0 -0
- data/spec/server/command-reference-files/initial/client/appy-app/index.js +21 -0
- data/spec/server/command-reference-files/initial/client/appy-app/models/.gitkeep +0 -0
- data/spec/server/command-reference-files/initial/client/appy-app/models/Base.coffee +5 -0
- data/spec/server/command-reference-files/initial/client/appy-app/screens/.gitkeep +0 -0
- data/spec/server/command-reference-files/initial/client/appy-app/screens/Base.coffee +3 -0
- data/spec/server/command-reference-files/initial/client/appy-app/styles.scss +1 -0
- data/spec/server/command-reference-files/initial/client/appy-app/views/.gitkeep +0 -0
- data/spec/server/command-reference-files/initial/client/appy-app/views/Base.coffee +5 -0
- data/spec/server/command-reference-files/initial/config/database.yml +9 -0
- data/spec/server/command-reference-files/initial/config/lanes.rb +7 -0
- data/spec/server/command-reference-files/initial/config/routes.rb +2 -0
- data/spec/server/command-reference-files/initial/config/screens.rb +0 -0
- data/spec/server/command-reference-files/initial/config.ru +5 -0
- data/spec/server/command-reference-files/initial/db/.gitkeep +0 -0
- data/spec/server/command-reference-files/initial/lib/appy-app/extension.rb +13 -0
- data/spec/server/command-reference-files/initial/lib/appy-app/model.rb +11 -0
- data/spec/server/command-reference-files/initial/lib/appy-app/models/empty.rb +0 -0
- data/spec/server/command-reference-files/initial/lib/appy-app/version.rb +3 -0
- data/spec/server/command-reference-files/initial/lib/appy-app.rb +12 -0
- data/spec/server/command-reference-files/initial/spec/appy-app/helpers/AppyAppHelpers.coffee +5 -0
- data/spec/server/command-reference-files/initial/spec/appy-app/screens/Base.coffee +5 -0
- data/spec/server/command-reference-files/initial/spec/server/spec_helpers.rb +16 -0
- data/spec/server/command-reference-files/model/client/appy-app/models/TestTest.coffee +9 -0
- data/spec/server/command-reference-files/model/config/routes.rb +3 -0
- data/spec/server/command-reference-files/model/db/migrate/20150218032025_create_test_tests.rb +10 -0
- data/spec/server/command-reference-files/model/lib/appy-app/models/test_test.rb +7 -0
- data/spec/server/command-reference-files/model/spec/appy-app/models/TestTestSpec.coffee +5 -0
- data/spec/server/command-reference-files/model/spec/fixtures/appy-app/test_test.yml +11 -0
- data/spec/server/command-reference-files/model/spec/server/test_test_spec.rb +10 -0
- data/spec/server/command-reference-files/screen/client/appy-app/screens/ready-set-go/ReadySetGo.coffee +7 -0
- data/spec/server/command-reference-files/screen/client/appy-app/screens/ready-set-go/index.js +5 -0
- data/spec/server/command-reference-files/screen/client/appy-app/screens/ready-set-go/index.scss +8 -0
- data/spec/server/command-reference-files/screen/client/appy-app/screens/ready-set-go/layout.html +3 -0
- data/spec/server/command-reference-files/screen/config/screens.rb +9 -0
- data/spec/server/command-reference-files/screen/spec/appy-app/screens/ready-set-go/ReadySetGoSpec.coffee +5 -0
- data/spec/server/command-reference-files/view/client/appy-app/views/BigView.coffee +10 -0
- data/spec/server/command-reference-files/view/spec/appy-app/views/BigViewSpec.coffee +5 -0
- data/spec/server/command_spec.rb +40 -15
- data/templates/client/screens/Base.coffee +3 -0
- data/templates/client/screens/Screen.coffee +1 -1
- data/templates/config/screen.rb +0 -1
- data/templates/db/create_table_migration.rb +1 -1
- data/templates/lib/namespace.rb +2 -4
- metadata +118 -25
- data/client/images/logo-sm.png +0 -0
- 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
|
@@ -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,
|
57
|
-
this.listenTo( this.viewport,
|
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.
|
25
|
-
this.listenTo( Lanes.Screens.Definitions.displaying, "
|
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
|
-
|
30
|
-
|
31
|
-
# this.ui.screens_menu_container.append( this.viewport.menu_view.el )
|
26
|
+
closeScreens: ->
|
27
|
+
this.ui.screen.children().detach()
|
32
28
|
|
33
|
-
onRemove: (
|
34
|
-
|
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
|
data/lanes.gemspec
CHANGED
@@ -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
|
}))
|
data/lib/lanes/access/role.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
61
|
-
if
|
62
|
-
return
|
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
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
26
|
+
make_handler(*args) do |controller|
|
27
27
|
controller.perform_destroy
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
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
|
-
|
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
|
52
|
-
|
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
|
data/lib/lanes/api/root.rb
CHANGED
@@ -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
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
24
|
+
assets = screen.assets
|
25
|
+
manifest.compile( assets ) unless assets.empty?
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
data/lib/lanes/api/test_specs.rb
CHANGED
@@ -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
|
data/lib/lanes/command/app.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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/#{
|
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/#{
|
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",
|
54
|
-
" resources #{namespace
|
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}/#{
|
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
|
-
@
|
17
|
-
|
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 =
|
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)
|
data/lib/lanes/configuration.rb
CHANGED
data/lib/lanes/db.rb
CHANGED
@@ -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
|
56
|
-
|
57
|
-
|
58
|
-
|
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)
|
data/lib/lanes/extension.rb
CHANGED
@@ -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
File without changes
|
File without changes
|
@@ -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
|
+
*/
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
/* Enter styles for your application in scss format here */
|
File without changes
|