modjs-architecture 0.6.8 → 0.7.0
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.
- data/VERSION +1 -1
- data/lib/modjs-architecture.rb +0 -34
- data/modjs-architecture.gemspec +2 -3
- data/spec/modjs-architecture_spec.rb +0 -7
- metadata +3 -4
- data/spec/templates_spec.rb +0 -82
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/lib/modjs-architecture.rb
CHANGED
@@ -83,7 +83,6 @@ module ModJS
|
|
83
83
|
|
84
84
|
def update(compress = false)
|
85
85
|
read_config
|
86
|
-
compile_templates
|
87
86
|
update_application_file
|
88
87
|
super(compress)
|
89
88
|
end
|
@@ -110,7 +109,6 @@ module ModJS
|
|
110
109
|
File.open(tmp_file, "w+") do |file|
|
111
110
|
write_dependencies file
|
112
111
|
write_core file
|
113
|
-
write_templates file
|
114
112
|
write_autoload file
|
115
113
|
end
|
116
114
|
tmp_file
|
@@ -132,10 +130,6 @@ module ModJS
|
|
132
130
|
file << "var #{@config[:name]} = new Mod.Application('#{@config[:name]}');\n\n"
|
133
131
|
end
|
134
132
|
|
135
|
-
def write_templates(file)
|
136
|
-
file << @compiled_templates
|
137
|
-
end
|
138
|
-
|
139
133
|
def write_autoload(file)
|
140
134
|
if @config[:autoload]
|
141
135
|
@config[:autoload].each do |autoload|
|
@@ -163,33 +157,5 @@ module ModJS
|
|
163
157
|
puts ArchitectureJS::Notification.error "Sprockets error: #{error.message}"
|
164
158
|
end
|
165
159
|
|
166
|
-
def compile_templates
|
167
|
-
templates_string = ''
|
168
|
-
app_name = @config[:name]
|
169
|
-
compiled_templates = fetch_templates
|
170
|
-
formatted_templates = format_templates(compiled_templates)
|
171
|
-
template = ERB.new File.read("#{ModJS::base_dir}/lib/modjs-architecture/templates/templates.erb.js")
|
172
|
-
@compiled_templates = template.result(binding)
|
173
|
-
|
174
|
-
File.open("#{@root}/#{@config[:build_dir]}/templates.js", "w+") do |f|
|
175
|
-
f << @compiled_templates
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
def fetch_templates
|
180
|
-
templates = {}
|
181
|
-
Dir.glob("#{@root}/templates/**/*.jst").each do |template|
|
182
|
-
name = File.basename(template).gsub(/\.jst$/, '')
|
183
|
-
templates[name] = EJS.compile(File.read(template))
|
184
|
-
end
|
185
|
-
templates
|
186
|
-
end
|
187
|
-
|
188
|
-
def format_templates(compiled_templates)
|
189
|
-
formatted_templates = compiled_templates.map do |name, function|
|
190
|
-
"\"#{name}\": #{function}"
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
160
|
end # class Project
|
195
161
|
end # module ArchitectureJS
|
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.7.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-
|
12
|
+
s.date = "2012-07-12"
|
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 = [
|
@@ -75,7 +75,6 @@ Gem::Specification.new do |s|
|
|
75
75
|
"spec/javascripts/support/jasmine_runner.rb",
|
76
76
|
"spec/modjs-architecture_spec.rb",
|
77
77
|
"spec/spec_helper.rb",
|
78
|
-
"spec/templates_spec.rb",
|
79
78
|
"templates/model.js",
|
80
79
|
"templates/module.js"
|
81
80
|
]
|
@@ -80,8 +80,6 @@ describe ModJS::Blueprint do
|
|
80
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
|
FileUtils.cp "#{FIXTURES}/test2.module.js", "#{TMP_DIR}/modules/test2.module.js"
|
83
|
-
FileUtils.cp "#{FIXTURES}/test.jst", "#{TMP_DIR}/templates/test.jst"
|
84
|
-
FileUtils.cp "#{FIXTURES}/test_two.jst", "#{TMP_DIR}/templates/test_two.jst"
|
85
83
|
|
86
84
|
suppress_output do
|
87
85
|
@project.update
|
@@ -104,11 +102,6 @@ describe ModJS::Blueprint do
|
|
104
102
|
File.exists?("#{TMP_DIR}/application/test.js").should be_true
|
105
103
|
end
|
106
104
|
|
107
|
-
it 'should compile .jst files into application/templates.js' do
|
108
|
-
File.exists?("#{TMP_DIR}/application/templates.js").should be_true
|
109
|
-
"#{TMP_DIR}/application/templates.js".should be_same_file_as "#{FIXTURES}/templates_compiled.js"
|
110
|
-
end
|
111
|
-
|
112
105
|
end
|
113
106
|
|
114
107
|
end
|
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.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: architecture-js
|
@@ -191,7 +191,6 @@ files:
|
|
191
191
|
- spec/javascripts/support/jasmine_runner.rb
|
192
192
|
- spec/modjs-architecture_spec.rb
|
193
193
|
- spec/spec_helper.rb
|
194
|
-
- spec/templates_spec.rb
|
195
194
|
- templates/model.js
|
196
195
|
- templates/module.js
|
197
196
|
homepage: http://github.com/daytonn/modjs-architecture
|
@@ -209,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
208
|
version: '0'
|
210
209
|
segments:
|
211
210
|
- 0
|
212
|
-
hash:
|
211
|
+
hash: -3194274414425353057
|
213
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
213
|
none: false
|
215
214
|
requirements:
|
data/spec/templates_spec.rb
DELETED
@@ -1,82 +0,0 @@
|
|
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
|
-
suppress_output { @project.generator.generate(config) }
|
27
|
-
File.exists?("#{TMP_DIR}/foo.module.js").should be_true
|
28
|
-
"#{TMP_DIR}/foo.module.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
|
-
suppress_output { @project.generator.generate(config) }
|
40
|
-
File.exists?("#{TMP_DIR}/foo_elements.module.js").should be_true
|
41
|
-
"#{TMP_DIR}/foo_elements.module.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
|
-
suppress_output { @project.generator.generate(config) }
|
53
|
-
File.exists?("#{TMP_DIR}/foo_model.module.js").should be_true
|
54
|
-
"#{TMP_DIR}/foo_model.module.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
|
-
suppress_output { @project.generator.generate(config) }
|
66
|
-
File.exists?("#{TMP_DIR}/foo_all.module.js").should be_true
|
67
|
-
"#{TMP_DIR}/foo_all.module.js".should be_same_file_as "#{FIXTURES}/foo_all.js"
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should render a module partial with the correct module name' do
|
71
|
-
config = {
|
72
|
-
arguments: ['module', '_foo'],
|
73
|
-
template: 'module',
|
74
|
-
filename: '_foo',
|
75
|
-
options: {}
|
76
|
-
}
|
77
|
-
|
78
|
-
suppress_output { @project.generator.generate(config) }
|
79
|
-
File.exists?("#{TMP_DIR}/_foo.module.js").should be_true
|
80
|
-
"#{TMP_DIR}/_foo.module.js".should be_same_file_as "#{FIXTURES}/foo.js"
|
81
|
-
end
|
82
|
-
end
|