architecture-js 0.0.0 → 0.1.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.
@@ -0,0 +1,60 @@
1
+ require "spec_helper"
2
+
3
+ describe ArchitectureJS::Command do
4
+
5
+ context 'API' do
6
+ before :each do
7
+ suppress_output do
8
+ @project = ArchitectureJS::Project.new({ name: 'myapp' }, TMP_DIR)
9
+ @project.create
10
+ end
11
+ end
12
+
13
+ after :each do
14
+ FileUtils.rm_rf TMP_DIR
15
+ end
16
+
17
+ it 'should have a watch command' do
18
+ ArchitectureJS::Command.should respond_to :watch
19
+ end
20
+
21
+ it 'should have a compile command' do
22
+ ArchitectureJS::Command.should respond_to :compile
23
+ end
24
+
25
+ it 'should have a generate command' do
26
+ ArchitectureJS::Command.should respond_to :generate
27
+ end
28
+
29
+ it 'should have a create command' do
30
+ ArchitectureJS::Command.should respond_to :create
31
+ end
32
+ end
33
+
34
+ context 'Usage' do
35
+ after :each do
36
+ FileUtils.rm_rf TMP_DIR
37
+ end
38
+
39
+ it 'should create a new application' do
40
+ suppress_output { ArchitectureJS::Command.create({ name: 'myapp', root: TMP_DIR }) }
41
+
42
+ "#{TMP_DIR}/myapp.architecture".should be_same_file_as "#{FIXTURES}/myapp.architecture"
43
+ File.directory?("#{TMP_DIR}/lib").should be_true
44
+ File.directory?("#{TMP_DIR}/src").should be_true
45
+ end
46
+
47
+ it 'should compile the application' do
48
+ suppress_output { ArchitectureJS::Command.create({ name: 'myapp', root: TMP_DIR }) }
49
+ FileUtils.cp "#{FIXTURES}/lib1.js", "#{TMP_DIR}/src/lib1.js"
50
+ FileUtils.cp "#{FIXTURES}/lib2.js", "#{TMP_DIR}/src/lib2.js"
51
+ FileUtils.cp "#{FIXTURES}/src_file.js", "#{TMP_DIR}/src/myapp.js"
52
+
53
+ suppress_output { ArchitectureJS::Command.compile({ path: TMP_DIR }) }
54
+
55
+ File.exists?("#{TMP_DIR}/lib/myapp.js").should be_true
56
+ "#{TMP_DIR}/lib/myapp.js".should be_same_file_as "#{FIXTURES}/compiled_src.js"
57
+ end
58
+
59
+ end # Usage
60
+ end
@@ -0,0 +1,2 @@
1
+ var file_one = 'one';
2
+ var file_two = 'two';
@@ -0,0 +1,6 @@
1
+ var <%= project.config[:name] %> = (function() {
2
+ function <%= project.config[:name] %>() {
3
+ <%= "var optional_variable = #{options[:optional_variable]};" if options %>
4
+ }
5
+ return <%= project.config[:name] %>;
6
+ })();
@@ -0,0 +1,6 @@
1
+ name: test
2
+ framework: none
3
+ src_dir: source
4
+ build_dir: dest
5
+ asset_root: ../
6
+ output: compressed
@@ -0,0 +1 @@
1
+ var file_one = 'one';
@@ -0,0 +1 @@
1
+ var file_two = 'two';
@@ -0,0 +1,6 @@
1
+ framework: none
2
+ src_dir: src
3
+ build_dir: lib
4
+ asset_root: ../
5
+ output: compressed
6
+ name: myapp
@@ -0,0 +1,2 @@
1
+ //= require "../lib/lib1"
2
+ //= require "../lib/lib2"
@@ -0,0 +1,6 @@
1
+ var <%= project.config[:name] %> = (function() {
2
+ function <%= project.config[:name] %>() {
3
+ <%= "var optional_variable = #{options[:optional_variable]};" if options %>
4
+ }
5
+ return <%= project.config[:name] %>;
6
+ })();
@@ -0,0 +1,6 @@
1
+ var myapp = (function() {
2
+ function myapp() {
3
+
4
+ }
5
+ return myapp;
6
+ })();
@@ -0,0 +1,6 @@
1
+ var myapp = (function() {
2
+ function myapp() {
3
+ var optional_variable = true;
4
+ }
5
+ return myapp;
6
+ })();
@@ -0,0 +1,49 @@
1
+ require "spec_helper"
2
+
3
+ describe ArchitectureJS::Generator do
4
+
5
+ before :each do
6
+ FileUtils.mkdir TMP_DIR
7
+ FileUtils.mkdir "#{TMP_DIR}/templates"
8
+ FileUtils.cp "#{FIXTURES}/test_template.erb", "#{TMP_DIR}/templates/test_template.erb"
9
+ FileUtils.cp "#{FIXTURES}/ejs_template.ejs", "#{TMP_DIR}/templates/ejs_template.ejs"
10
+ @gen = ArchitectureJS::Generator.new(ArchitectureJS::Project.new({ name: 'myapp' }, TMP_DIR))
11
+ end
12
+
13
+ after :each do
14
+ FileUtils.rm_rf TMP_DIR if File.exists? TMP_DIR
15
+ end
16
+
17
+ it "should have a project" do
18
+ @gen.project.class.should == ArchitectureJS::Project
19
+ end
20
+
21
+ it "should have template_paths" do
22
+ @gen.template_paths.should == ["#{ArchitectureJS::BASE_DIR}/templates", "#{TMP_DIR}/templates"]
23
+ end
24
+
25
+ it "should get a template name" do
26
+ @gen.get_template_name("/Volumes/Storage/Development/architecture-js/spec/tmp/templates/ejs_template.ejs").should == 'ejs'
27
+ @gen.get_template_name("/Volumes/Storage/Development/architecture-js/spec/tmp/templates/test_template.erb").should == 'test'
28
+ end
29
+
30
+ it "should find all the templates" do
31
+ @gen.templates['test'].should_not be_nil
32
+ @gen.templates['ejs'].should_not be_nil
33
+ end
34
+
35
+ it 'should render a template' do
36
+ @gen.render_template('test').should == File.open("#{FIXTURES}/test_template.js").read
37
+ end
38
+
39
+ it 'should render a template with options' do
40
+ @gen.render_template('test', optional_variable: 'true').should == File.open("#{FIXTURES}/test_template_options.js").read
41
+ end
42
+
43
+ it 'should render templates with different file extensions' do
44
+ @gen.templates['ejs'].is_a?(ERB).should be_true
45
+ @gen.render_template('ejs').should == File.open("#{FIXTURES}/test_template.js").read
46
+ @gen.render_template('ejs', optional_variable: 'true').should == File.open("#{FIXTURES}/test_template_options.js").read
47
+ end
48
+
49
+ end
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ describe ArchitectureJS::Helpers do
4
+ it 'should create a module filename from a POSIX path' do
5
+ ArchitectureJS::Helpers.get_file_name('/some/path/some.module.js').should === 'some'
6
+ end
7
+
8
+ it 'should create a module filename from a Windows path' do
9
+ ArchitectureJS::Helpers.get_file_name('D:\\\\some\path\some.module.js').should === 'some'
10
+ end
11
+
12
+ it 'should convert an array to yaml notation' do
13
+ yml = ArchitectureJS::Helpers.array_to_yml ['one', 'two', 'three']
14
+ yml.should == "['one', 'two', 'three']"
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe ArchitectureJS::Notification do
4
+ it 'should have a notify method' do
5
+ ArchitectureJS::Notification.notify(:none, 'hello').should == 'hello'
6
+ end
7
+
8
+ it 'should have a notice method' do
9
+ ArchitectureJS::Notification.notice('hello').should === 'hello'
10
+ end
11
+
12
+ it 'should have a log method' do
13
+ ArchitectureJS::Notification.log('hello').should === "\e[32m>>>\e[0m hello"
14
+ end
15
+
16
+ it 'should have an event method' do
17
+ ArchitectureJS::Notification.event('hello').should === "\e[33m<<<\e[0m hello"
18
+ end
19
+
20
+ it 'should have an added method' do
21
+ ArchitectureJS::Notification.added('hello').should === "\e[32m+++\e[0m hello"
22
+ end
23
+
24
+ it 'should have an error method' do
25
+ ArchitectureJS::Notification.error('hello').should === "\e[0;31m!!!\e[0m hello"
26
+ end
27
+ end
@@ -0,0 +1,103 @@
1
+ require "spec_helper.rb"
2
+
3
+ describe ArchitectureJS::Project do
4
+
5
+ it "should exist" do
6
+ ArchitectureJS::Project.should_not be_nil
7
+ end
8
+
9
+ context 'Instantiation' do
10
+ before :each do
11
+ FileUtils.mkdir TMP_DIR
12
+ suppress_output do
13
+ @project = ArchitectureJS::Project.new({ name: 'myapp' }, TMP_DIR)
14
+ end
15
+ end
16
+
17
+ it "should add the 'none' framework to ArchitectureJS" do
18
+ ArchitectureJS::FRAMEWORKS['none'].should == ArchitectureJS::Project
19
+ end
20
+
21
+ after :each do
22
+ FileUtils.rm_rf "#{TMP_DIR}" if File.exists? "#{TMP_DIR}"
23
+ end
24
+
25
+ it 'should have an empty src_files array' do
26
+ @project.src_files.should == Array.new
27
+ end
28
+
29
+ it 'should have a read_config method' do
30
+ @project.respond_to?("read_config").should be_true
31
+ end
32
+
33
+ it 'should have a write_config method' do
34
+ @project.respond_to?("write_config").should be_true
35
+ end
36
+
37
+ it "should have directories" do
38
+ @project.directories.should == ['lib', 'src']
39
+ end
40
+
41
+ it "should have template_directories" do
42
+ @project.template_directories.should == ["#{ArchitectureJS::BASE_DIR}/templates", "#{TMP_DIR}/templates"]
43
+ end
44
+
45
+ it "should have a watch_directories array" do
46
+ @project.watch_directories.should == ['src']
47
+ end
48
+
49
+ it "should have a generator" do
50
+ @project.generator.should_not be_nil
51
+ end
52
+ end # Instantiation
53
+
54
+ context "Project Creation" do
55
+ before :each do
56
+ FileUtils.mkdir("#{TMP_DIR}")
57
+ suppress_output do
58
+ @project = ArchitectureJS::Project.new({ name: 'myapp' }, TMP_DIR)
59
+ @project.create
60
+ end
61
+ end
62
+
63
+ after :each do
64
+ FileUtils.rm_rf "#{TMP_DIR}" if File.exists? "#{TMP_DIR}"
65
+ end
66
+
67
+ it 'should create a project directory structure' do
68
+ File.directory?("#{TMP_DIR}/lib").should be_true
69
+ File.directory?("#{TMP_DIR}/src").should be_true
70
+ end
71
+
72
+ it 'should create a config file' do
73
+ File.exists?("#{TMP_DIR}/myapp.architecture").should be_true
74
+ "#{TMP_DIR}/myapp.architecture".should be_same_file_as "#{FIXTURES}/myapp.architecture"
75
+ end
76
+
77
+ end # Project Creation
78
+
79
+ context "Project Update" do
80
+ before :each do
81
+ FileUtils.mkdir("#{TMP_DIR}")
82
+ suppress_output do
83
+ @project = ArchitectureJS::Project.new({ name: 'myapp' },TMP_DIR)
84
+ @project.create
85
+ FileUtils.cp "#{FIXTURES}/lib1.js", "#{TMP_DIR}/lib/lib1.js"
86
+ FileUtils.cp "#{FIXTURES}/lib2.js", "#{TMP_DIR}/lib/lib2.js"
87
+ FileUtils.cp "#{FIXTURES}/src_file.js", "#{TMP_DIR}/src/myapp.js"
88
+ @project.update
89
+ end
90
+ end
91
+
92
+ after :each do
93
+ FileUtils.rm_rf "#{TMP_DIR}" if File.exists? "#{TMP_DIR}"
94
+ end
95
+
96
+ it 'should compile the source files into the destination folder' do
97
+ File.exists?("#{TMP_DIR}/lib/myapp.js").should be_true
98
+ "#{TMP_DIR}/lib/myapp.js".should be_same_file_as "#{FIXTURES}/compiled_src.js"
99
+ end
100
+
101
+ end # Project Update
102
+
103
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,37 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'architecture-js'
1
+ $: << File.join(File.dirname(__FILE__), "../lib")
5
2
 
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
3
+ require 'architecture-js'
4
+ require 'fileutils'
5
+ require 'rspec'
6
+ require 'digest/md5'
9
7
 
10
8
  RSpec.configure do |config|
9
+ config.color_enabled = true
10
+ end
11
+
12
+ RSpec::Matchers.define(:be_same_file_as) do |epxected_file_path|
13
+ match do |actual_file_path|
14
+ md5_hash(actual_file_path).should == md5_hash(epxected_file_path)
15
+ end
11
16
 
17
+ def md5_hash(file_path)
18
+ Digest::MD5.hexdigest(File.read(file_path))
19
+ end
12
20
  end
21
+
22
+ def suppress_output(&block)
23
+ original_stdout = $stdout
24
+ $stdout = fake = StringIO.new
25
+
26
+ begin
27
+ yield
28
+ ensure
29
+ $stdout = original_stdout
30
+ end
31
+
32
+ fake.string
33
+ end
34
+
35
+ SPEC_DIR = "#{ArchitectureJS::BASE_DIR}/spec"
36
+ TMP_DIR = "#{SPEC_DIR}/tmp"
37
+ FIXTURES = "#{SPEC_DIR}/fixtures"
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.0.0
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,44 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-16 00:00:00.000000000Z
12
+ date: 2011-12-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rspec
16
- requirement: &70344192156440 !ruby/object:Gem::Requirement
15
+ name: fssm
16
+ requirement: &70107388112360 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70107388112360
25
+ - !ruby/object:Gem::Dependency
26
+ name: jsmin
27
+ requirement: &70107388111760 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
20
31
  - !ruby/object:Gem::Version
21
- version: 2.3.0
22
- type: :development
32
+ version: 1.0.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70107388111760
36
+ - !ruby/object:Gem::Dependency
37
+ name: sprockets
38
+ requirement: &70107388111180 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.2
44
+ type: :runtime
23
45
  prerelease: false
24
- version_requirements: *70344192156440
46
+ version_requirements: *70107388111180
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: bundler
27
- requirement: &70344192155960 !ruby/object:Gem::Requirement
49
+ requirement: &70107388110660 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ~>
@@ -32,10 +54,10 @@ dependencies:
32
54
  version: 1.0.0
33
55
  type: :development
34
56
  prerelease: false
35
- version_requirements: *70344192155960
57
+ version_requirements: *70107388110660
36
58
  - !ruby/object:Gem::Dependency
37
59
  name: jeweler
38
- requirement: &70344192155480 !ruby/object:Gem::Requirement
60
+ requirement: &70107388110060 !ruby/object:Gem::Requirement
39
61
  none: false
40
62
  requirements:
41
63
  - - ~>
@@ -43,10 +65,54 @@ dependencies:
43
65
  version: 1.5.2
44
66
  type: :development
45
67
  prerelease: false
46
- version_requirements: *70344192155480
68
+ version_requirements: *70107388110060
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ requirement: &70107388109480 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70107388109480
47
80
  - !ruby/object:Gem::Dependency
48
81
  name: rcov
49
- requirement: &70344192155000 !ruby/object:Gem::Requirement
82
+ requirement: &70107388108960 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70107388108960
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec
93
+ requirement: &70107388108340 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 2.3.0
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70107388108340
102
+ - !ruby/object:Gem::Dependency
103
+ name: ZenTest
104
+ requirement: &70107388107860 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 4.4.2
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70107388107860
113
+ - !ruby/object:Gem::Dependency
114
+ name: rdoc
115
+ requirement: &70107388107380 !ruby/object:Gem::Requirement
50
116
  none: false
51
117
  requirements:
52
118
  - - ! '>='
@@ -54,11 +120,45 @@ dependencies:
54
120
  version: '0'
55
121
  type: :development
56
122
  prerelease: false
57
- version_requirements: *70344192155000
123
+ version_requirements: *70107388107380
124
+ - !ruby/object:Gem::Dependency
125
+ name: jsmin
126
+ requirement: &70107388106900 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: *70107388106900
135
+ - !ruby/object:Gem::Dependency
136
+ name: fssm
137
+ requirement: &70107388106400 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :runtime
144
+ prerelease: false
145
+ version_requirements: *70107388106400
146
+ - !ruby/object:Gem::Dependency
147
+ name: sprockets
148
+ requirement: &70107388105860 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - =
152
+ - !ruby/object:Gem::Version
153
+ version: 1.0.2
154
+ type: :runtime
155
+ prerelease: false
156
+ version_requirements: *70107388105860
58
157
  description: Architecture.js helps you generate scaffolding, manage third-party packages,
59
158
  compile, and compress your application.
60
159
  email: daytonn@gmail.com
61
- executables: []
160
+ executables:
161
+ - architect
62
162
  extensions: []
63
163
  extra_rdoc_files:
64
164
  - LICENSE.txt
@@ -73,9 +173,32 @@ files:
73
173
  - Rakefile
74
174
  - VERSION
75
175
  - architecture-js.gemspec
176
+ - bin/architect
76
177
  - lib/architecture-js.rb
178
+ - lib/architecture-js/command.rb
179
+ - lib/architecture-js/dependencies.rb
180
+ - lib/architecture-js/generator.rb
181
+ - lib/architecture-js/helpers.rb
182
+ - lib/architecture-js/notification.rb
183
+ - lib/architecture-js/project.rb
77
184
  - spec/.DS_Store
78
185
  - spec/architecture-js_spec.rb
186
+ - spec/cli_spec.rb
187
+ - spec/command_spec.rb
188
+ - spec/fixtures/compiled_src.js
189
+ - spec/fixtures/ejs_template.ejs
190
+ - spec/fixtures/existing.architecture
191
+ - spec/fixtures/lib1.js
192
+ - spec/fixtures/lib2.js
193
+ - spec/fixtures/myapp.architecture
194
+ - spec/fixtures/src_file.js
195
+ - spec/fixtures/test_template.erb
196
+ - spec/fixtures/test_template.js
197
+ - spec/fixtures/test_template_options.js
198
+ - spec/generator_spec.rb
199
+ - spec/helpers_spec.rb
200
+ - spec/notification_spec.rb
201
+ - spec/project_spec.rb
79
202
  - spec/spec_helper.rb
80
203
  homepage: http://github.com/daytonn/architecture.js
81
204
  licenses:
@@ -92,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
215
  version: '0'
93
216
  segments:
94
217
  - 0
95
- hash: -868977265340122418
218
+ hash: 222919537146508532
96
219
  required_rubygems_version: !ruby/object:Gem::Requirement
97
220
  none: false
98
221
  requirements:
@@ -108,4 +231,10 @@ summary: architecture.js is a command line application to dynamically build and
108
231
  complex javascript applications.
109
232
  test_files:
110
233
  - spec/architecture-js_spec.rb
234
+ - spec/cli_spec.rb
235
+ - spec/command_spec.rb
236
+ - spec/generator_spec.rb
237
+ - spec/helpers_spec.rb
238
+ - spec/notification_spec.rb
239
+ - spec/project_spec.rb
111
240
  - spec/spec_helper.rb