lanes 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/Gemfile +0 -1
- data/README.md +2 -0
- data/client/lanes/data/Bootstrap.coffee +2 -2
- data/client/lanes/data/Collection.coffee +4 -0
- data/client/lanes/data/Config.coffee +0 -5
- data/client/lanes/data/Model.coffee +236 -150
- data/client/lanes/data/PubSub.coffee +6 -12
- data/client/lanes/data/Sync.coffee +1 -0
- data/client/lanes/extension/Extensions.coffee +4 -2
- data/client/lanes/lib/MakeBaseClass.coffee +1 -1
- data/client/lanes/minimal.js +11 -0
- data/client/lanes/minimal.scss.erb +12 -0
- data/client/lanes/screens/Base.coffee +1 -2
- data/client/lanes/screens/Instance.coffee +52 -0
- data/client/lanes/vendor/packaged.js +1 -2
- data/client/lanes/views/Base.coffee +12 -10
- data/client/lanes/workspace.scss.erb +3 -0
- data/client/lanes/workspace/index.js +2 -12
- data/docs/command.md +111 -0
- data/docs/model.md +188 -0
- data/docs/todo-example-part-1.md +71 -0
- data/docs/view.md +275 -0
- data/{spec/client/jasmine_examples/PlayerSpec.js → docs/welcome.md} +0 -0
- data/lanes.gemspec +3 -1
- data/lib/lanes/api/helper_methods.rb +8 -0
- data/lib/lanes/api/javascript_processor.rb +14 -10
- data/lib/lanes/api/pub_sub.rb +7 -7
- data/lib/lanes/api/request_wrapper.rb +1 -0
- data/lib/lanes/api/root.rb +2 -7
- data/lib/lanes/api/sprockets_compressor.rb +6 -2
- data/lib/lanes/api/sprockets_extension.rb +25 -9
- data/lib/lanes/api/test_specs.rb +13 -9
- data/lib/lanes/command.rb +16 -6
- data/lib/lanes/command/app.rb +11 -5
- data/lib/lanes/command/generate_model.rb +4 -3
- data/lib/lanes/command/generate_screen.rb +2 -1
- data/lib/lanes/command/generate_view.rb +1 -1
- data/lib/lanes/command/named_command.rb +5 -4
- data/lib/lanes/command/templates/Gemfile +1 -2
- data/lib/lanes/command/templates/client/data/Model.coffee +3 -3
- data/lib/lanes/command/templates/client/{namespace-extension.js → index.js} +0 -0
- data/lib/lanes/command/templates/client/screens/Screen.coffee +1 -3
- data/lib/lanes/command/templates/client/{styles/styles.scss → styles.scss} +0 -0
- data/lib/lanes/command/templates/client/views/View.coffee +1 -3
- data/lib/lanes/command/templates/config/lanes.rb +1 -1
- data/lib/lanes/command/templates/gitignore +1 -0
- data/lib/lanes/command/templates/lib/namespace/screen.rb +1 -1
- data/lib/lanes/command/templates/public/.gitkeep +0 -0
- data/lib/lanes/command/templates/spec/client/Screen.coffee +7 -0
- data/lib/lanes/command/templates/spec/client/views/ViewSpec.coffee +2 -2
- data/lib/lanes/concerns/all.rb +1 -1
- data/lib/lanes/concerns/sanitize_fields.rb +32 -0
- data/lib/lanes/concerns/set_attribute_data.rb +4 -4
- data/lib/lanes/db.rb +7 -8
- data/lib/lanes/extension.rb +37 -3
- data/lib/lanes/guard_tasks.rb +2 -2
- data/lib/lanes/model.rb +2 -2
- data/lib/lanes/screens.rb +1 -0
- data/lib/lanes/spec_helper.rb +17 -6
- data/{spec → lib/lanes}/testing_models.rb +1 -1
- data/lib/lanes/version.rb +1 -1
- data/npm-build/compile.coffee +1 -6
- data/public/javascripts/jasmine_examples/Player.js +22 -0
- data/public/javascripts/jasmine_examples/Song.js +7 -0
- data/spec/api/javascript_processor_spec.rb +6 -3
- data/spec/concerns/api_path_spec.rb +1 -1
- data/spec/concerns/association_extensions_spec.rb +7 -3
- data/spec/concerns/attr_accessor_with_default_spec.rb +1 -1
- data/spec/concerns/code_identifier_spec.rb +1 -1
- data/spec/concerns/export_associations_spec.rb +1 -1
- data/spec/concerns/export_methods_spec.rb +1 -14
- data/spec/concerns/export_scope_spec.rb +7 -9
- data/spec/concerns/exported_limits_spec.rb +1 -1
- data/spec/concerns/pub_sub_spec.rb +1 -1
- data/spec/concerns/set_attribute_data_spec.rb +16 -24
- data/spec/configuration_spec.rb +1 -1
- data/spec/helpers/lanes-helpers.coffee +61 -0
- data/spec/lanes/data/ModelSpec.coffee +152 -0
- data/spec/lanes/data/PubSubSpec.coffee +21 -0
- data/spec/{client/view → lanes/views}/BaseSpec.coffee +6 -26
- data/spec/numbers_spec.rb +1 -1
- data/spec/strings_spec.rb +1 -1
- data/views/index.erb +3 -10
- data/views/specs.erb +4 -1
- metadata +62 -16
- data/client/lanes/plugins/trigger.coffee +0 -15
- data/client/lanes/workspace/Instance.es6 +0 -64
- data/lib/lanes/concerns/sanitize_api_data.rb +0 -15
- data/spec/api/user_spec.rb +0 -52
- data/spec/fixtures/lanes/users.yml +0 -13
- data/spec/locked_fields_spec.rb +0 -27
- data/spec/role_collection_spec.rb +0 -19
- data/spec/user_role_spec.rb +0 -7
- data/spec/user_spec.rb +0 -53
data/lib/lanes/api/root.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'sinatra'
|
2
2
|
require 'oj'
|
3
3
|
require 'rack/csrf'
|
4
|
-
|
5
|
-
require 'message_bus'
|
4
|
+
|
6
5
|
require_relative 'sprockets_extension'
|
7
6
|
require_relative 'helper_methods'
|
8
7
|
require_relative 'pub_sub'
|
@@ -20,13 +19,9 @@ module Lanes
|
|
20
19
|
not_found do
|
21
20
|
Oj.dump({ message: "endpoint not found", success: false })
|
22
21
|
end
|
23
|
-
before do
|
24
|
-
content_type 'application/json'
|
25
|
-
end
|
26
22
|
|
27
23
|
use Rack::Session::Cookie, :key => 'lanes.session', :secret => Lanes.config.session_secret_key_base
|
28
24
|
use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
29
|
-
use MessageBus::Rack::Middleware
|
30
25
|
error do
|
31
26
|
Lanes.logger.warn request.env['sinatra.error']#.backtrace
|
32
27
|
Oj.dump({
|
@@ -40,7 +35,7 @@ module Lanes
|
|
40
35
|
set :views, Pathname.new(__FILE__).dirname.join("../../../views")
|
41
36
|
set :show_exceptions, false
|
42
37
|
DB.establish_connection
|
43
|
-
PubSub.initialize
|
38
|
+
PubSub.initialize(self)
|
44
39
|
Extensions.load_current_config
|
45
40
|
# late load in case an extension has provided an alternative implementation
|
46
41
|
require "lanes/api/null_authentication_provider" unless API.const_defined?(:AuthenticationProvider)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "yui/compressor"
|
2
|
+
require "closure-compiler"
|
2
3
|
|
3
4
|
module Lanes
|
4
5
|
module API
|
@@ -9,13 +10,16 @@ module Lanes
|
|
9
10
|
|
10
11
|
def initialize_engine
|
11
12
|
require_template_library 'yui/compressor'
|
13
|
+
require_template_library 'closure-compiler'
|
12
14
|
end
|
13
15
|
|
14
16
|
def prepare
|
15
17
|
end
|
16
18
|
|
17
19
|
def js
|
18
|
-
|
20
|
+
# n.b. setting 'ADVANCED_OPTIMIZATIONS' doesn't work at this time, it
|
21
|
+
# introduces JS errors :( Haven't debugged further
|
22
|
+
@js||=Closure::Compiler.new
|
19
23
|
end
|
20
24
|
def css
|
21
25
|
@css ||= YUI::CssCompressor.new( :java_opts=>'-client' )
|
@@ -23,7 +27,7 @@ module Lanes
|
|
23
27
|
def evaluate(context, locals, &block)
|
24
28
|
case context.content_type
|
25
29
|
when 'application/javascript'
|
26
|
-
js.
|
30
|
+
js.compile(data)
|
27
31
|
when 'text/css'
|
28
32
|
css.compress(data)
|
29
33
|
else
|
@@ -2,8 +2,8 @@ require 'sprockets'
|
|
2
2
|
require 'sass'
|
3
3
|
require 'sinatra/sprockets-helpers'
|
4
4
|
require_relative 'javascript_processor'
|
5
|
-
require_relative 'sprockets_compressor'
|
6
5
|
require 'compass/import-once/activate'
|
6
|
+
require 'sprockets-helpers'
|
7
7
|
|
8
8
|
module Lanes
|
9
9
|
module API
|
@@ -13,9 +13,16 @@ module Lanes
|
|
13
13
|
def compile!
|
14
14
|
env = ::Sprockets::Environment.new
|
15
15
|
Lanes::API::SprocketsExtension.configure(env, compress:true)
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
+
}
|
22
|
+
Screens::Definition.each(env) do | screen |
|
23
|
+
manifest.compile( screen.files )
|
24
|
+
end
|
25
|
+
|
19
26
|
end
|
20
27
|
|
21
28
|
def configure(env, compress:false)
|
@@ -29,6 +36,7 @@ module Lanes
|
|
29
36
|
ext.client_paths.each{ |path| env.append_path(path) }
|
30
37
|
end
|
31
38
|
if compress
|
39
|
+
require_relative 'sprockets_compressor'
|
32
40
|
env.js_compressor = AssetCompressor
|
33
41
|
env.css_compressor = AssetCompressor
|
34
42
|
end
|
@@ -41,16 +49,16 @@ module Lanes
|
|
41
49
|
app.set :sprockets, ::Sprockets::Environment.new
|
42
50
|
configure(app.sprockets)
|
43
51
|
|
44
|
-
# The url for client
|
45
|
-
app.set :digest_assets, false
|
46
|
-
|
47
52
|
app.configure do
|
48
53
|
::Sprockets::Helpers.configure do |config|
|
49
54
|
config.environment = app.sprockets
|
50
55
|
config.prefix = Lanes.config.assets_path_prefix
|
51
|
-
config.digest = app.digest_assets
|
52
56
|
config.public_path = app.public_folder
|
53
|
-
config.debug =
|
57
|
+
config.debug = !app.production?
|
58
|
+
if app.production?
|
59
|
+
config.manifest = Sprockets::Manifest.new(app.sprockets,
|
60
|
+
"public/assets/manifest.json")
|
61
|
+
end
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
@@ -61,6 +69,14 @@ module Lanes
|
|
61
69
|
settings.sprockets.call env_sprockets
|
62
70
|
end
|
63
71
|
end
|
72
|
+
app.configure :production do
|
73
|
+
app.get "#{Lanes.config.assets_path_prefix}/*" do |path|
|
74
|
+
if manifest_path = ::Sprockets::Helpers.manifest.assets[path]
|
75
|
+
path = manifest_path
|
76
|
+
end
|
77
|
+
send_file "public/assets/" + path
|
78
|
+
end
|
79
|
+
end
|
64
80
|
end
|
65
81
|
|
66
82
|
end
|
data/lib/lanes/api/test_specs.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
require 'jasmine-core'
|
2
|
+
require 'lanes/command'
|
2
3
|
|
3
4
|
module Lanes
|
4
5
|
module API
|
5
6
|
|
7
|
+
LanesDummyExt = Struct.new(:identifier, :root_path)
|
6
8
|
class TestSpecs
|
9
|
+
|
7
10
|
cattr_accessor :current
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
attr_accessor :extension
|
13
|
+
def initialize(ext)
|
14
|
+
@extension = ext
|
11
15
|
end
|
12
16
|
|
13
17
|
def css_files
|
@@ -18,13 +22,13 @@ module Lanes
|
|
18
22
|
urlpath(Jasmine::Core.js_files) +
|
19
23
|
urlpath(Jasmine::Core.boot_files) +
|
20
24
|
urlpath(spec_files("helpers")) +
|
21
|
-
urlpath(spec_files(
|
25
|
+
urlpath(spec_files(extension.identifier))
|
22
26
|
end
|
23
27
|
|
24
28
|
private
|
25
29
|
|
26
30
|
def spec_files(path)
|
27
|
-
dir =
|
31
|
+
dir = extension.root_path.join("spec")
|
28
32
|
regex = /^#{dir}\//
|
29
33
|
Dir.glob( dir.join(path,"**/*.{coffee,js}") ).map do |file|
|
30
34
|
file.sub(regex,'').sub(/coffee$/,'js')
|
@@ -37,11 +41,11 @@ module Lanes
|
|
37
41
|
end
|
38
42
|
|
39
43
|
|
40
|
-
Lanes.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
44
|
+
ext = Lanes::Command.load_current_extension ||
|
45
|
+
LanesDummyExt.new('lanes', Pathname.new(__FILE__).dirname.join("../../../"))
|
46
|
+
TestSpecs.current = TestSpecs.new(ext)
|
47
|
+
Root.sprockets.append_path(ext.root_path.join("spec"))
|
48
|
+
|
45
49
|
|
46
50
|
Root.sprockets.append_path(Jasmine::Core.path)
|
47
51
|
|
data/lib/lanes/command.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'thor/error'
|
2
|
+
|
1
3
|
module Lanes
|
2
4
|
module Command
|
3
5
|
class << self
|
@@ -16,22 +18,30 @@ module Lanes
|
|
16
18
|
# Will silently swallow any exceptions that are raised when the file is required and return nil
|
17
19
|
#
|
18
20
|
# @return [Extension] extension that was loaded, nil if none was found
|
19
|
-
def load_current_extension
|
21
|
+
def load_current_extension(raise_on_fail:false)
|
22
|
+
|
20
23
|
previous = Extensions.all
|
21
|
-
ext = Dir.glob("./lib
|
24
|
+
ext = Dir.glob("./lib/*/extension.rb").first
|
22
25
|
if ext
|
23
26
|
begin
|
24
27
|
require(ext)
|
25
28
|
rescue
|
26
|
-
return
|
29
|
+
return _maybe_fail(raise_on_fail)
|
30
|
+
end
|
31
|
+
all = Extensions.all
|
32
|
+
if all.any?
|
33
|
+
diff = all - previous
|
34
|
+
return diff.any? ? diff.first.new : Extensions.all.first.new
|
27
35
|
end
|
28
|
-
diff = Extensions.all - previous
|
29
|
-
return diff.any? ? diff.first.new : nil
|
30
36
|
else
|
31
|
-
return
|
37
|
+
return _maybe_fail(raise_on_fail)
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
41
|
+
def _maybe_fail(should_raise)
|
42
|
+
raise Thor::Error.new("Unable to locate Lanes environment") if should_raise
|
43
|
+
return nil
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
37
47
|
end
|
data/lib/lanes/command/app.rb
CHANGED
@@ -33,15 +33,21 @@ module Lanes
|
|
33
33
|
|
34
34
|
def create_client_files
|
35
35
|
self.class.source_root.join('client').children.each do | path |
|
36
|
-
|
36
|
+
next unless path.directory?
|
37
|
+
empty_directory "#{client_dir}/#{path.basename}"
|
38
|
+
create_file "#{client_dir}/#{path.basename}/.gitkeep"
|
37
39
|
end
|
38
|
-
template "client/
|
39
|
-
template "client/Extension.coffee",
|
40
|
-
template "client/styles
|
40
|
+
template "client/index.js", "#{client_dir}/index.js"
|
41
|
+
template "client/Extension.coffee", "#{client_dir}/Extension.coffee"
|
42
|
+
template "client/styles.scss", "#{client_dir}/styles.scss"
|
41
43
|
end
|
42
44
|
|
45
|
+
def create_spec
|
46
|
+
|
47
|
+
end
|
48
|
+
|
43
49
|
def create_first_screen
|
44
|
-
invoke GenerateScreen, [
|
50
|
+
invoke GenerateScreen, ["base"], title: name.titleize, namespace: name
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
@@ -36,15 +36,16 @@ module Lanes
|
|
36
36
|
|
37
37
|
def create_model
|
38
38
|
template "lib/namespace/model.rb", "lib/#{namespace}/#{file_name}.rb"
|
39
|
-
template "spec/namespace/model_spec.rb", "
|
39
|
+
template "spec/namespace/model_spec.rb", "#{spec_dir}/#{file_name}.rb"
|
40
40
|
template "spec/fixtures/namespace/model.yml", "spec/fixtures/#{namespace}/#{file_name}.yml"
|
41
41
|
end
|
42
42
|
|
43
43
|
def create_client
|
44
|
+
self.fields.unshift ModelAttribute.parse("id:integer")
|
44
45
|
template "client/data/Model.coffee", \
|
45
|
-
|
46
|
+
"#{client_dir}/data/#{class_name}.coffee"
|
46
47
|
template "spec/client/data/ModelSpec.coffee", \
|
47
|
-
|
48
|
+
"#{spec_dir}/data/#{class_name}Spec.coffee"
|
48
49
|
end
|
49
50
|
|
50
51
|
def add_route
|
@@ -22,8 +22,9 @@ module Lanes
|
|
22
22
|
template "lib/namespace/screen.rb", "lib/#{namespace}/#{name}_screen.rb"
|
23
23
|
template "client/screens/index.js", "#{client_dir}/screens/#{name}/index.js"
|
24
24
|
template "client/screens/styles.scss", "#{client_dir}/screens/#{name}/index.scss"
|
25
|
-
template "client/screens/Screen.coffee", "#{client_dir}/screens/#{name}/#{
|
25
|
+
template "client/screens/Screen.coffee", "#{client_dir}/screens/#{name}/#{class_name}.coffee"
|
26
26
|
template "client/screens/layout.html", "#{client_dir}/screens/#{name}/layout.html"
|
27
|
+
template "spec/client/Screen.coffee", "#{spec_dir}/screens/#{class_name}.coffee"
|
27
28
|
end
|
28
29
|
|
29
30
|
end
|
@@ -13,7 +13,7 @@ module Lanes
|
|
13
13
|
template "client/views/View.coffee", "#{client_dir}/views/#{name.classify}.coffee"
|
14
14
|
template "client/views/template.html", "#{client_dir}/views/#{name.dasherize}.html"
|
15
15
|
template "spec/client/views/ViewSpec.coffee", \
|
16
|
-
|
16
|
+
"#{spec_dir}/views/#{class_name}Spec.coffee"
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -6,19 +6,20 @@ module Lanes
|
|
6
6
|
|
7
7
|
argument :name
|
8
8
|
|
9
|
-
attr_reader :namespace, :class_name, :client_dir
|
9
|
+
attr_reader :namespace, :class_name, :client_dir, :spec_dir
|
10
10
|
|
11
11
|
def self.source_root
|
12
12
|
Pathname.new(__FILE__).dirname.join("templates")
|
13
13
|
end
|
14
14
|
|
15
15
|
def load_namespace
|
16
|
-
@namespace = options[:namespace] ||
|
17
|
-
|
18
|
-
|
16
|
+
@namespace = options[:namespace] ||
|
17
|
+
Command.load_current_extension(raise_on_fail:true).identifier
|
18
|
+
end
|
19
19
|
|
20
20
|
def set_variables
|
21
21
|
@class_name = name.classify
|
22
|
+
@spec_dir = "spec/#{namespace}"
|
22
23
|
@client_dir = "client/#{namespace}"
|
23
24
|
end
|
24
25
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem "
|
4
|
-
gem "lanes", github: "argosity/lanes", branch: 'master'
|
3
|
+
gem "lanes", github: "argosity/lanes", branch: 'master'
|
5
4
|
|
6
5
|
# Uncomment to enable access control and user administration
|
7
6
|
# gem "lanes-access", github: "argosity/lanes-access", branch: 'master'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class <%= namespace.camelize %>.Data.<%= class_name %> extends <%= client_parent %>
|
2
2
|
|
3
3
|
api_path: '<%= name.downcase.pluralize.underscore.dasherize %>'
|
4
|
-
|
4
|
+
source: FILE
|
5
5
|
|
6
6
|
props:
|
7
7
|
<% fields.each do |field| -%>
|
@@ -19,6 +19,6 @@ class <%= namespace.camelize %>.Data.<%= class_name %> extends <%= client_parent
|
|
19
19
|
<% end -%>
|
20
20
|
<% end -%>
|
21
21
|
|
22
|
-
class
|
22
|
+
class <%= namespace.camelize %>.Data.<%= class_name %>Collection extends <%= options[:client_collection_parent] %>
|
23
23
|
|
24
|
-
model:
|
24
|
+
model: <%= namespace.camelize %>.Data.<%= class_name %>
|
File without changes
|
File without changes
|
@@ -11,7 +11,7 @@ module <%= namespace.camelize %>
|
|
11
11
|
group_id "<%= options[:group] %>"
|
12
12
|
model_class "<%= options[:model_class] %>"
|
13
13
|
view_class "<%= namespace.camelize %>.Screens.<%= class_name %>"
|
14
|
-
files ['screens/<%= name.dasherize %>.js','screens/<%= name.dasherize %>.css']
|
14
|
+
files ['<%= namespace %>/screens/<%= name.dasherize %>.js','<%= namespace %>/screens/<%= name.dasherize %>.css']
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
#= require <%= namespace %>/screens/<%= name %>
|
2
|
+
|
3
|
+
describe "<%= class_name %> Screen Suite", ->
|
4
|
+
|
5
|
+
it "can be instantiated", ->
|
6
|
+
view = new <%= namespace.camelize %>.Screens.<%= class_name %>()
|
7
|
+
expect(view).toEqual(jasmine.any(<%= namespace.camelize %>.Screens.<%= class_name %>));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe "<%= class_name %> View Suite", ->
|
2
2
|
|
3
3
|
it "can be instantiated", ->
|
4
|
-
view = new
|
5
|
-
expect(view).toEqual(jasmine.any(
|
4
|
+
view = new <%= namespace.camelize %>.Views.<%= class_name %>()
|
5
|
+
expect(view).toEqual(jasmine.any(<%= namespace.camelize %>.Views.<%= class_name %>));
|
data/lib/lanes/concerns/all.rb
CHANGED