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 CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.2.0
@@ -1,4 +1,4 @@
1
- framework: none
1
+ blueprint: default
2
2
  src_dir: src
3
3
  build_dir: lib
4
4
  asset_root: ../
@@ -1,6 +1,14 @@
1
1
  module ModJS
2
- BASE_DIR = File.expand_path("../..", __FILE__)
3
- LIB_DIR = "#{BASE_DIR}/lib/modjs-architecture/lib"
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
- # TODO add default template directory and templates
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 "#{LIB_DIR}/mod.js", app_file
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 "#{LIB_DIR}/mod.js", "#{@root}/lib/"
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::BASE_DIR}/spec/javascripts/application_spec.js", "#{@root}/spec/application_spec.js"
48
- FileUtils.cp "#{ModJS::BASE_DIR}/spec/javascripts/dom_spec.js", "#{@root}/spec/dom_spec.js"
49
- FileUtils.cp "#{ModJS::BASE_DIR}/spec/javascripts/existence_spec.js", "#{@root}/spec/existence_spec.js"
50
- FileUtils.cp "#{ModJS::BASE_DIR}/spec/javascripts/module_spec.js", "#{@root}/spec/module_spec.js"
51
- FileUtils.cp "#{ModJS::BASE_DIR}/lib/modjs-architecture/jasmine/jasmine-html.js", "#{@root}/spec/jasmine/"
52
- FileUtils.cp "#{ModJS::BASE_DIR}/lib/modjs-architecture/jasmine/jasmine.css", "#{@root}/spec/jasmine/"
53
- FileUtils.cp "#{ModJS::BASE_DIR}/lib/modjs-architecture/jasmine/jasmine.js", "#{@root}/spec/jasmine/"
54
- FileUtils.cp "#{ModJS::BASE_DIR}/lib/modjs-architecture/jasmine/jasmine_favicon.png", "#{@root}/spec/jasmine/"
55
- FileUtils.cp "#{ModJS::BASE_DIR}/lib/modjs-architecture/jasmine/MIT.LICENSE", "#{@root}/spec/jasmine/"
56
- FileUtils.cp "#{ModJS::BASE_DIR}/lib/modjs-architecture/jasmine/index.html", "#{@root}/spec/jasmine/"
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::BASE_DIR,
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],
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "modjs-architecture"
8
- s.version = "0.1.6"
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-21"
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.architecture",
41
+ "lib/modjs-architecture/modjs.blueprint",
42
42
  "lib/modjs-architecture/src/mod.js",
43
43
  "modjs-architecture.gemspec",
44
- "spec/fixtures/myapp.architecture",
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.architecture",
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"]
@@ -0,0 +1,9 @@
1
+ (function(app) {
2
+ var m = app.add_module("foo");
3
+
4
+ m.actions = function() {
5
+
6
+ }
7
+
8
+ m.run();
9
+ })(myapp);
@@ -0,0 +1,13 @@
1
+ (function(app) {
2
+ var m = app.add_module("foo_all");
3
+
4
+ //= require "../elements/foo_all.elements"
5
+
6
+ //= require "../models/foo_all.model"
7
+
8
+ m.actions = function() {
9
+
10
+ }
11
+
12
+ m.run();
13
+ })(myapp);
@@ -0,0 +1,11 @@
1
+ (function(app) {
2
+ var m = app.add_module("foo_elements");
3
+
4
+ //= require "../elements/foo_elements.elements"
5
+
6
+ m.actions = function() {
7
+
8
+ }
9
+
10
+ m.run();
11
+ })(myapp);
@@ -0,0 +1,11 @@
1
+ (function(app) {
2
+ var m = app.add_module("foo_model");
3
+
4
+ //= require "../models/foo_model.model"
5
+
6
+ m.actions = function() {
7
+
8
+ }
9
+
10
+ m.run();
11
+ })(myapp);
@@ -1,4 +1,4 @@
1
- framework: modjs
1
+ blueprint: modjs
2
2
  src_dir: modules
3
3
  build_dir: application
4
4
  asset_root: ../
@@ -1,4 +1,4 @@
1
- framework: modjs
1
+ blueprint: modjs
2
2
  src_dir: modules
3
3
  build_dir: application
4
4
  asset_root: ../
@@ -1,15 +1,15 @@
1
1
  require "spec_helper.rb"
2
2
 
3
- describe ModJS::Project do
3
+ describe ModJS::Blueprint do
4
4
 
5
5
  describe "defaults" do
6
6
 
7
7
  before :each do
8
- suppress_output { @project = ModJS::Project.new( { name: 'myapp' }, TMP_DIR) }
8
+ suppress_output { @project = ModJS::Blueprint.new( { name: 'myapp' }, TMP_DIR) }
9
9
  end
10
10
 
11
- it 'should have a BASE_DIR constant' do
12
- ModJS::BASE_DIR = MODJS_ROOT
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::Project.new( { name: 'myapp' }, TMP_DIR)
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 architecture file' do
43
- File.exists?("#{TMP_DIR}/myapp.architecture").should be_true
44
- "#{TMP_DIR}/myapp.architecture".should be_same_file_as "#{FIXTURES}/myapp.architecture"
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::LIB_DIR}/mod.js"
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::Project.new( { name: 'myapp' }, TMP_DIR)
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.architecture"
80
- FileUtils.cp "#{FIXTURES}/update.architecture", "#{TMP_DIR}/myapp.architecture"
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
@@ -0,0 +1,3 @@
1
+ m.set_data({
2
+
3
+ });
@@ -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.1.6
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-21 00:00:00.000000000Z
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: &70130159837360 !ruby/object:Gem::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: *70130159837360
24
+ version_requirements: *70121469700780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70130159814540 !ruby/object:Gem::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: *70130159814540
35
+ version_requirements: *70121469699400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70130159813940 !ruby/object:Gem::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: *70130159813940
46
+ version_requirements: *70121469698700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70130159813400 !ruby/object:Gem::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: *70130159813400
57
+ version_requirements: *70121469697800
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jasmine
60
- requirement: &70130159812800 !ruby/object:Gem::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: *70130159812800
68
+ version_requirements: *70121469696700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: architecture-js
71
- requirement: &70130159812080 !ruby/object:Gem::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: *70130159812080
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.architecture
111
+ - lib/modjs-architecture/modjs.blueprint
112
112
  - lib/modjs-architecture/src/mod.js
113
113
  - modjs-architecture.gemspec
114
- - spec/fixtures/myapp.architecture
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.architecture
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: 2379399736139929132
152
+ hash: 2975033321687838439
146
153
  required_rubygems_version: !ruby/object:Gem::Requirement
147
154
  none: false
148
155
  requirements: