modjs-architecture 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/modjs-architecture/{modjs.architecture → modjs.blueprint} +1 -1
- data/lib/modjs-architecture.rb +26 -16
- data/modjs-architecture.gemspec +13 -6
- data/spec/fixtures/foo.js +9 -0
- data/spec/fixtures/foo_all.js +13 -0
- data/spec/fixtures/foo_elements.js +11 -0
- data/spec/fixtures/foo_model.js +11 -0
- data/spec/fixtures/{myapp.architecture → myapp.blueprint} +1 -1
- data/spec/fixtures/{update.architecture → update.blueprint} +1 -1
- data/spec/modjs-architecture_spec.rb +13 -12
- data/spec/templates_spec.rb +70 -0
- data/templates/model.js +3 -0
- data/templates/module.js +17 -0
- metadata +25 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/modjs-architecture.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module ModJS
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
def base_dir
|
4
|
+
File.expand_path("../..", __FILE__)
|
5
|
+
end
|
6
|
+
|
7
|
+
def lib_dir
|
8
|
+
"#{ModJS::base_dir}/lib/modjs-architecture/lib"
|
9
|
+
end
|
10
|
+
|
11
|
+
module_function :base_dir, :lib_dir
|
4
12
|
|
5
13
|
class Blueprint < ArchitectureJS::Blueprint
|
6
14
|
# this line adds the default framework to ArchitectureJS
|
@@ -15,8 +23,10 @@ module ModJS
|
|
15
23
|
autoload: []
|
16
24
|
}
|
17
25
|
@config.merge! config unless config.nil?
|
18
|
-
|
26
|
+
|
19
27
|
super(@config, root)
|
28
|
+
|
29
|
+
add_templates "#{ModJS::base_dir}/templates"
|
20
30
|
@directories = %w'application elements lib models modules plugins spec'
|
21
31
|
end
|
22
32
|
|
@@ -34,26 +44,26 @@ module ModJS
|
|
34
44
|
|
35
45
|
def create_application_file
|
36
46
|
app_file = "#{@root}/#{@config[:build_dir]}/#{@config[:name]}.js"
|
37
|
-
FileUtils.cp "#{
|
47
|
+
FileUtils.cp "#{ModJS::lib_dir}/mod.js", app_file
|
38
48
|
File.open(app_file, 'a') { |f| f.write("\nvar #{@config[:name]} = new Mod.Application('#{@config[:name]}');") }
|
39
49
|
end
|
40
50
|
|
41
51
|
def copy_modjs_core_to_lib
|
42
|
-
FileUtils.cp "#{
|
52
|
+
FileUtils.cp "#{ModJS::lib_dir}/mod.js", "#{@root}/lib/"
|
43
53
|
end
|
44
54
|
|
45
55
|
def copy_spec_files
|
46
56
|
FileUtils.mkdir "#{@root}/spec/jasmine"
|
47
|
-
FileUtils.cp "#{ModJS::
|
48
|
-
FileUtils.cp "#{ModJS::
|
49
|
-
FileUtils.cp "#{ModJS::
|
50
|
-
FileUtils.cp "#{ModJS::
|
51
|
-
FileUtils.cp "#{ModJS::
|
52
|
-
FileUtils.cp "#{ModJS::
|
53
|
-
FileUtils.cp "#{ModJS::
|
54
|
-
FileUtils.cp "#{ModJS::
|
55
|
-
FileUtils.cp "#{ModJS::
|
56
|
-
FileUtils.cp "#{ModJS::
|
57
|
+
FileUtils.cp "#{ModJS::base_dir}/spec/javascripts/application_spec.js", "#{@root}/spec/application_spec.js"
|
58
|
+
FileUtils.cp "#{ModJS::base_dir}/spec/javascripts/dom_spec.js", "#{@root}/spec/dom_spec.js"
|
59
|
+
FileUtils.cp "#{ModJS::base_dir}/spec/javascripts/existence_spec.js", "#{@root}/spec/existence_spec.js"
|
60
|
+
FileUtils.cp "#{ModJS::base_dir}/spec/javascripts/module_spec.js", "#{@root}/spec/module_spec.js"
|
61
|
+
FileUtils.cp "#{ModJS::base_dir}/lib/modjs-architecture/jasmine/jasmine-html.js", "#{@root}/spec/jasmine/"
|
62
|
+
FileUtils.cp "#{ModJS::base_dir}/lib/modjs-architecture/jasmine/jasmine.css", "#{@root}/spec/jasmine/"
|
63
|
+
FileUtils.cp "#{ModJS::base_dir}/lib/modjs-architecture/jasmine/jasmine.js", "#{@root}/spec/jasmine/"
|
64
|
+
FileUtils.cp "#{ModJS::base_dir}/lib/modjs-architecture/jasmine/jasmine_favicon.png", "#{@root}/spec/jasmine/"
|
65
|
+
FileUtils.cp "#{ModJS::base_dir}/lib/modjs-architecture/jasmine/MIT.LICENSE", "#{@root}/spec/jasmine/"
|
66
|
+
FileUtils.cp "#{ModJS::base_dir}/lib/modjs-architecture/jasmine/index.html", "#{@root}/spec/jasmine/"
|
57
67
|
end
|
58
68
|
|
59
69
|
def update
|
@@ -103,7 +113,7 @@ module ModJS
|
|
103
113
|
|
104
114
|
def compile_application_file(file)
|
105
115
|
sprockets = Sprockets::Secretary.new(
|
106
|
-
root: ModJS::
|
116
|
+
root: ModJS::base_dir,
|
107
117
|
asset_root: File.expand_path(@config[:asset_root], @root),
|
108
118
|
load_path: ['repository'],
|
109
119
|
source_files: [file],
|
data/modjs-architecture.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "modjs-architecture"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dayton Nolan"]
|
12
|
-
s.date = "2012-02-
|
12
|
+
s.date = "2012-02-27"
|
13
13
|
s.description = "Mod.js is a modular javascript library that provides a base application strucure to build large javascript applications. Mod.js is designed to work with architecture.js."
|
14
14
|
s.email = "daytonn@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -38,14 +38,18 @@ Gem::Specification.new do |s|
|
|
38
38
|
"lib/modjs-architecture/jasmine/jasmine.js",
|
39
39
|
"lib/modjs-architecture/jasmine/jasmine_favicon.png",
|
40
40
|
"lib/modjs-architecture/lib/mod.js",
|
41
|
-
"lib/modjs-architecture/modjs.
|
41
|
+
"lib/modjs-architecture/modjs.blueprint",
|
42
42
|
"lib/modjs-architecture/src/mod.js",
|
43
43
|
"modjs-architecture.gemspec",
|
44
|
-
"spec/fixtures/
|
44
|
+
"spec/fixtures/foo.js",
|
45
|
+
"spec/fixtures/foo_all.js",
|
46
|
+
"spec/fixtures/foo_elements.js",
|
47
|
+
"spec/fixtures/foo_model.js",
|
48
|
+
"spec/fixtures/myapp.blueprint",
|
45
49
|
"spec/fixtures/myapp.js",
|
46
50
|
"spec/fixtures/test.js",
|
47
51
|
"spec/fixtures/test.module.js",
|
48
|
-
"spec/fixtures/update.
|
52
|
+
"spec/fixtures/update.blueprint",
|
49
53
|
"spec/fixtures/update.js",
|
50
54
|
"spec/javascripts/application_spec.js",
|
51
55
|
"spec/javascripts/dom_spec.js",
|
@@ -56,7 +60,10 @@ Gem::Specification.new do |s|
|
|
56
60
|
"spec/javascripts/support/jasmine_config.rb",
|
57
61
|
"spec/javascripts/support/jasmine_runner.rb",
|
58
62
|
"spec/modjs-architecture_spec.rb",
|
59
|
-
"spec/spec_helper.rb"
|
63
|
+
"spec/spec_helper.rb",
|
64
|
+
"spec/templates_spec.rb",
|
65
|
+
"templates/model.js",
|
66
|
+
"templates/module.js"
|
60
67
|
]
|
61
68
|
s.homepage = "http://github.com/daytonn/modjs-architecture"
|
62
69
|
s.licenses = ["MIT"]
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require "spec_helper.rb"
|
2
2
|
|
3
|
-
describe ModJS::
|
3
|
+
describe ModJS::Blueprint do
|
4
4
|
|
5
5
|
describe "defaults" do
|
6
6
|
|
7
7
|
before :each do
|
8
|
-
suppress_output { @project = ModJS::
|
8
|
+
suppress_output { @project = ModJS::Blueprint.new( { name: 'myapp' }, TMP_DIR) }
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'should have a
|
12
|
-
ModJS::
|
11
|
+
it 'should have a base_dir' do
|
12
|
+
ModJS::base_dir.should == MODJS_ROOT
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should have the correct directories' do
|
@@ -20,7 +20,7 @@ describe ModJS::Project do
|
|
20
20
|
describe 'project creation' do
|
21
21
|
before :each do
|
22
22
|
suppress_output do
|
23
|
-
@project = ModJS::
|
23
|
+
@project = ModJS::Blueprint.new( { name: 'myapp' }, TMP_DIR)
|
24
24
|
@project.create
|
25
25
|
end
|
26
26
|
end
|
@@ -39,9 +39,9 @@ describe ModJS::Project do
|
|
39
39
|
File.exists?("#{TMP_DIR}/spec").should be_true
|
40
40
|
end
|
41
41
|
|
42
|
-
it 'should create the
|
43
|
-
File.exists?("#{TMP_DIR}/myapp.
|
44
|
-
"#{TMP_DIR}/myapp.
|
42
|
+
it 'should create the blueprint file' do
|
43
|
+
File.exists?("#{TMP_DIR}/myapp.blueprint").should be_true
|
44
|
+
"#{TMP_DIR}/myapp.blueprint".should be_same_file_as "#{FIXTURES}/myapp.blueprint"
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'should create an application file in the build_dir' do
|
@@ -49,7 +49,7 @@ describe ModJS::Project do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should copy the core library into the lib folder' do
|
52
|
-
"#{TMP_DIR}/lib/mod.js".should be_same_file_as "#{ModJS::
|
52
|
+
"#{TMP_DIR}/lib/mod.js".should be_same_file_as "#{ModJS::lib_dir}/mod.js"
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should copy the jasmine tests into the spec folder' do
|
@@ -72,12 +72,12 @@ describe ModJS::Project do
|
|
72
72
|
|
73
73
|
before :each do
|
74
74
|
suppress_output do
|
75
|
-
@project = ModJS::
|
75
|
+
@project = ModJS::Blueprint.new( { name: 'myapp' }, TMP_DIR)
|
76
76
|
@project.create
|
77
77
|
end
|
78
78
|
|
79
|
-
FileUtils.rm_rf "#{TMP_DIR}/myapp.
|
80
|
-
FileUtils.cp "#{FIXTURES}/update.
|
79
|
+
FileUtils.rm_rf "#{TMP_DIR}/myapp.blueprint"
|
80
|
+
FileUtils.cp "#{FIXTURES}/update.blueprint", "#{TMP_DIR}/myapp.blueprint"
|
81
81
|
FileUtils.cp "#{FIXTURES}/test.module.js", "#{TMP_DIR}/modules/test.module.js"
|
82
82
|
|
83
83
|
suppress_output do
|
@@ -97,4 +97,5 @@ describe ModJS::Project do
|
|
97
97
|
"#{TMP_DIR}/application/test.js".should be_same_file_as "#{FIXTURES}/test.js"
|
98
98
|
end
|
99
99
|
end
|
100
|
+
|
100
101
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper.rb"
|
2
|
+
|
3
|
+
describe "ModJS templates" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
suppress_output do
|
7
|
+
@project = ModJS::Blueprint.new( { name: 'myapp' }, TMP_DIR)
|
8
|
+
@project.create
|
9
|
+
FileUtils.cd("#{TMP_DIR}")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
after :each do
|
14
|
+
FileUtils.rm_rf(TMP_DIR)
|
15
|
+
FileUtils.cd(SPEC_DIR)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should generate a module file' do
|
19
|
+
config = {
|
20
|
+
arguments: ['module', 'foo'],
|
21
|
+
template: 'module',
|
22
|
+
filename: 'foo',
|
23
|
+
options: {}
|
24
|
+
}
|
25
|
+
|
26
|
+
@project.generator.generate(config)
|
27
|
+
File.exists?("#{TMP_DIR}/foo.js").should be_true
|
28
|
+
"#{TMP_DIR}/foo.js".should be_same_file_as "#{FIXTURES}/foo.js"
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should render a module with elements' do
|
32
|
+
config = {
|
33
|
+
arguments: ['module', 'foo_elements', '-e'],
|
34
|
+
template: 'module',
|
35
|
+
filename: 'foo_elements',
|
36
|
+
options: { e: true }
|
37
|
+
}
|
38
|
+
|
39
|
+
@project.generator.generate(config)
|
40
|
+
File.exists?("#{TMP_DIR}/foo_elements.js").should be_true
|
41
|
+
"#{TMP_DIR}/foo_elements.js".should be_same_file_as "#{FIXTURES}/foo_elements.js"
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should render a module with a model' do
|
45
|
+
config = {
|
46
|
+
arguments: ['module', 'foo_model', '-m'],
|
47
|
+
template: 'module',
|
48
|
+
filename: 'foo_model',
|
49
|
+
options: { m: true }
|
50
|
+
}
|
51
|
+
|
52
|
+
@project.generator.generate(config)
|
53
|
+
File.exists?("#{TMP_DIR}/foo_model.js").should be_true
|
54
|
+
"#{TMP_DIR}/foo_model.js".should be_same_file_as "#{FIXTURES}/foo_model.js"
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should render a module with both a model and elements' do
|
58
|
+
config = {
|
59
|
+
arguments: ['module', 'foo_all', '-e', '-m'],
|
60
|
+
template: 'module',
|
61
|
+
filename: 'foo_all',
|
62
|
+
options: { e: true, m: true }
|
63
|
+
}
|
64
|
+
|
65
|
+
@project.generator.generate(config)
|
66
|
+
File.exists?("#{TMP_DIR}/foo_all.js").should be_true
|
67
|
+
"#{TMP_DIR}/foo_all.js".should be_same_file_as "#{FIXTURES}/foo_all.js"
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
data/templates/model.js
ADDED
data/templates/module.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
(function(app) {
|
2
|
+
var m = app.add_module("<%= arguments[1] %>");
|
3
|
+
<% if options[:e] %>
|
4
|
+
|
5
|
+
//= require "../elements/<%= arguments[1] %>.elements"
|
6
|
+
<% end %>
|
7
|
+
<% if options[:m] %>
|
8
|
+
|
9
|
+
//= require "../models/<%= arguments[1] %>.model"
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
m.actions = function() {
|
13
|
+
|
14
|
+
}
|
15
|
+
|
16
|
+
m.run();
|
17
|
+
})(<%= blueprint[:name] %>);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modjs-architecture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: architecture-js
|
16
|
-
requirement: &
|
16
|
+
requirement: &70121469700780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70121469700780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70121469699400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.8.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70121469699400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70121469698700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70121469698700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70121469697800 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.8.3
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70121469697800
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jasmine
|
60
|
-
requirement: &
|
60
|
+
requirement: &70121469696700 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.1.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70121469696700
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: architecture-js
|
71
|
-
requirement: &
|
71
|
+
requirement: &70121469695860 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70121469695860
|
80
80
|
description: Mod.js is a modular javascript library that provides a base application
|
81
81
|
strucure to build large javascript applications. Mod.js is designed to work with
|
82
82
|
architecture.js.
|
@@ -108,14 +108,18 @@ files:
|
|
108
108
|
- lib/modjs-architecture/jasmine/jasmine.js
|
109
109
|
- lib/modjs-architecture/jasmine/jasmine_favicon.png
|
110
110
|
- lib/modjs-architecture/lib/mod.js
|
111
|
-
- lib/modjs-architecture/modjs.
|
111
|
+
- lib/modjs-architecture/modjs.blueprint
|
112
112
|
- lib/modjs-architecture/src/mod.js
|
113
113
|
- modjs-architecture.gemspec
|
114
|
-
- spec/fixtures/
|
114
|
+
- spec/fixtures/foo.js
|
115
|
+
- spec/fixtures/foo_all.js
|
116
|
+
- spec/fixtures/foo_elements.js
|
117
|
+
- spec/fixtures/foo_model.js
|
118
|
+
- spec/fixtures/myapp.blueprint
|
115
119
|
- spec/fixtures/myapp.js
|
116
120
|
- spec/fixtures/test.js
|
117
121
|
- spec/fixtures/test.module.js
|
118
|
-
- spec/fixtures/update.
|
122
|
+
- spec/fixtures/update.blueprint
|
119
123
|
- spec/fixtures/update.js
|
120
124
|
- spec/javascripts/application_spec.js
|
121
125
|
- spec/javascripts/dom_spec.js
|
@@ -127,6 +131,9 @@ files:
|
|
127
131
|
- spec/javascripts/support/jasmine_runner.rb
|
128
132
|
- spec/modjs-architecture_spec.rb
|
129
133
|
- spec/spec_helper.rb
|
134
|
+
- spec/templates_spec.rb
|
135
|
+
- templates/model.js
|
136
|
+
- templates/module.js
|
130
137
|
homepage: http://github.com/daytonn/modjs-architecture
|
131
138
|
licenses:
|
132
139
|
- MIT
|
@@ -142,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
149
|
version: '0'
|
143
150
|
segments:
|
144
151
|
- 0
|
145
|
-
hash:
|
152
|
+
hash: 2975033321687838439
|
146
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
154
|
none: false
|
148
155
|
requirements:
|