architecture-js 0.3.0 → 0.3.1

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 CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "architecture-js"
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
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-26"
12
+ s.date = "2012-02-27"
13
13
  s.description = "Architecture.js helps you generate scaffolding, manage third-party packages, compile, and compress your application."
14
14
  s.email = "daytonn@gmail.com"
15
15
  s.executables = ["architect"]
@@ -86,6 +86,7 @@ Gem::Specification.new do |s|
86
86
  "spec/fixtures/compressed.blueprint",
87
87
  "spec/fixtures/compressed.js",
88
88
  "spec/fixtures/ejs.ejs",
89
+ "spec/fixtures/env-test.js",
89
90
  "spec/fixtures/existing.blueprint",
90
91
  "spec/fixtures/lib1.js",
91
92
  "spec/fixtures/lib1_compressed.js",
@@ -93,6 +94,7 @@ Gem::Specification.new do |s|
93
94
  "spec/fixtures/lib2_compressed.js",
94
95
  "spec/fixtures/myapp.blueprint",
95
96
  "spec/fixtures/src_file.js",
97
+ "spec/fixtures/templates/env_template.js",
96
98
  "spec/fixtures/templates/test_template_one.js",
97
99
  "spec/fixtures/templates/test_template_two.js",
98
100
  "spec/fixtures/test_blueprint.rb",
@@ -76,11 +76,15 @@ module Architect
76
76
  end
77
77
 
78
78
  project = ArchitectureJS::create_project_from_config(project_path)
79
- template = @args.first
80
- filename = @args[1]
81
- options = @template_options
82
- arguments = @args
83
- project.generator.generate(template, filename, options, arguments)
79
+
80
+ config = {
81
+ arguments: @args,
82
+ template: @args.first,
83
+ filename: @args[1],
84
+ options: @template_options
85
+ }
86
+
87
+ project.generator.generate config
84
88
  end
85
89
 
86
90
  def compile
@@ -35,10 +35,15 @@ module ArchitectureJS
35
35
  ERB.new(File.read(file), nil, '<>')
36
36
  end
37
37
 
38
- def generate(template, filename, options, arguments)
38
+ def generate(config)
39
+ template = config[:template]
39
40
  raise "There is no template named #{template} in the #{@blueprint[:name]} project" if @templates[template].nil?
40
- filename = "#{filename}#{@templates[template][:ext]}"
41
- generate_file(filename, render_template(template, options))
41
+
42
+ options = config[:options]
43
+ arguments = config[:arguments]
44
+ filename = "#{config[:filename]}#{@templates[template][:ext]}"
45
+
46
+ generate_file(filename, render_template(template, filename, arguments, options))
42
47
  end
43
48
 
44
49
  def generate_file(filename, template, path = nil)
@@ -46,7 +51,7 @@ module ArchitectureJS
46
51
  File.open("#{path}/#{filename}", "w+") { |f| f.write template }
47
52
  end
48
53
 
49
- def render_template(template, options = nil)
54
+ def render_template(template, filename, arguments, options)
50
55
  blueprint = @blueprint
51
56
  project = @project
52
57
  @templates[template][:erb].result(binding)
@@ -0,0 +1,5 @@
1
+ module
2
+ foo
3
+ -f
4
+ --name
5
+ Something
@@ -0,0 +1,3 @@
1
+ <% arguments.each do |arg| %>
2
+ <%= arg %>
3
+ <% end %>
@@ -1,6 +1,6 @@
1
1
  var <%= blueprint[:name] %> = (function() {
2
2
  function <%= blueprint[:name] %>() {
3
- <%= "var optional_variable = #{options[:optional_variable]};" if options %>
3
+ <%= "var optional_variable = #{options[:optional_variable]};" if options[:optional_variable] %>
4
4
  }
5
5
  return <%= blueprint[:name] %>;
6
6
  })();
@@ -7,6 +7,8 @@ describe ArchitectureJS::Generator do
7
7
  FileUtils.mkdir "#{TMP_DIR}/templates"
8
8
  FileUtils.cp "#{FIXTURES}/templates/test_template_one.js", "#{TMP_DIR}/test_template_one.js"
9
9
  FileUtils.cp "#{FIXTURES}/templates/test_template_two.js", "#{TMP_DIR}/test_template_two.js"
10
+ FileUtils.cp "#{FIXTURES}/templates/env_template.js", "#{TMP_DIR}/env_template.js"
11
+
10
12
  project = ArchitectureJS::Blueprint.new({ name: 'myapp' }, TMP_DIR)
11
13
  project.template_directories = ["#{FIXTURES}/templates"]
12
14
  @gen = ArchitectureJS::Generator.new(project)
@@ -34,17 +36,22 @@ describe ArchitectureJS::Generator do
34
36
  end
35
37
 
36
38
  it 'should render a template' do
37
- @gen.render_template('test_template_one').should == File.open("#{FIXTURES}/templates/test_template_one.js").read
38
- @gen.render_template('test_template_two').should == File.open("#{FIXTURES}/test_template_two.js").read
39
+ @gen.render_template('test_template_one', 'test', [], {}).should == File.open("#{FIXTURES}/templates/test_template_one.js").read
40
+ @gen.render_template('test_template_two', 'test', [], {}).should == File.open("#{FIXTURES}/test_template_two.js").read
39
41
  end
40
42
 
41
43
  it 'should render a template with options' do
42
- @gen.render_template('test_template_two', optional_variable: 'true').should == File.open("#{FIXTURES}/test_template_options.js").read
44
+ @gen.render_template('test_template_two', 'test', [], { optional_variable: 'true' }).should == File.open("#{FIXTURES}/test_template_options.js").read
43
45
  end
44
46
 
45
47
  it 'should generate a file from a template' do
46
- @gen.generate_file("test.js", @gen.render_template("test_template_two"), TMP_DIR)
48
+ @gen.generate_file("test.js", @gen.render_template("test_template_two", "test", [], {}), TMP_DIR)
47
49
  File.exists?("#{TMP_DIR}/test.js").should be_true
48
50
  File.open("#{TMP_DIR}/test.js").read.should == File.open("#{FIXTURES}/test_template_two.js").read
49
51
  end
52
+
53
+ it 'should pass the arguments to the template' do
54
+ @gen.generate_file("env-test.js", @gen.render_template("env_template", "env-test", ['module', 'foo', '-f', '--name', 'Something'], {}), TMP_DIR)
55
+ File.open("#{TMP_DIR}/env-test.js").read.should == File.open("#{FIXTURES}/env-test.js").read
56
+ end
50
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: architecture-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
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-26 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: fssm
16
- requirement: &70099801634900 !ruby/object:Gem::Requirement
16
+ requirement: &70223810592840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.2.8.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70099801634900
24
+ version_requirements: *70223810592840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jsmin
27
- requirement: &70099801634420 !ruby/object:Gem::Requirement
27
+ requirement: &70223810592360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70099801634420
35
+ version_requirements: *70223810592360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70099801633900 !ruby/object:Gem::Requirement
38
+ requirement: &70223810591820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.8.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70099801633900
46
+ version_requirements: *70223810591820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70099801633400 !ruby/object:Gem::Requirement
49
+ requirement: &70223810591320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70099801633400
57
+ version_requirements: *70223810591320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70099801632880 !ruby/object:Gem::Requirement
60
+ requirement: &70223810590840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.8.3
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70099801632880
68
+ version_requirements: *70223810590840
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ZenTest
71
- requirement: &70099801632320 !ruby/object:Gem::Requirement
71
+ requirement: &70223810590360 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 4.6.2
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70099801632320
79
+ version_requirements: *70223810590360
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: autotest-growl
82
- requirement: &70099801631800 !ruby/object:Gem::Requirement
82
+ requirement: &70223810589840 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.2.16
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70099801631800
90
+ version_requirements: *70223810589840
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: jsmin
93
- requirement: &70099801631220 !ruby/object:Gem::Requirement
93
+ requirement: &70223810589360 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70099801631220
101
+ version_requirements: *70223810589360
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: fssm
104
- requirement: &70099801630680 !ruby/object:Gem::Requirement
104
+ requirement: &70223810588880 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70099801630680
112
+ version_requirements: *70223810588880
113
113
  description: Architecture.js helps you generate scaffolding, manage third-party packages,
114
114
  compile, and compress your application.
115
115
  email: daytonn@gmail.com
@@ -188,6 +188,7 @@ files:
188
188
  - spec/fixtures/compressed.blueprint
189
189
  - spec/fixtures/compressed.js
190
190
  - spec/fixtures/ejs.ejs
191
+ - spec/fixtures/env-test.js
191
192
  - spec/fixtures/existing.blueprint
192
193
  - spec/fixtures/lib1.js
193
194
  - spec/fixtures/lib1_compressed.js
@@ -195,6 +196,7 @@ files:
195
196
  - spec/fixtures/lib2_compressed.js
196
197
  - spec/fixtures/myapp.blueprint
197
198
  - spec/fixtures/src_file.js
199
+ - spec/fixtures/templates/env_template.js
198
200
  - spec/fixtures/templates/test_template_one.js
199
201
  - spec/fixtures/templates/test_template_two.js
200
202
  - spec/fixtures/test_blueprint.rb
@@ -223,7 +225,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
225
  version: '0'
224
226
  segments:
225
227
  - 0
226
- hash: 315668935587202633
228
+ hash: -132243405050259594
227
229
  required_rubygems_version: !ruby/object:Gem::Requirement
228
230
  none: false
229
231
  requirements: