ymdp 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/History.txt +9 -0
- data/Rakefile +4 -1
- data/VERSION +1 -1
- data/features/ymdp.feature +2 -2
- data/lib/ymdp.rb +1 -2
- data/lib/ymdp/compiler/git_helper.rb +1 -1
- data/lib/ymdp/compiler/template.rb +8 -4
- data/lib/ymdp/configuration/constants.rb +4 -1
- data/lib/ymdp/tasks/ymdp.rake +6 -22
- data/lib/ymdp/view/application_view.rb +12 -9
- data/spec/application_view_spec.rb +42 -29
- data/spec/compiler_spec.rb +1 -1
- data/spec/compiler_template_spec.rb +9 -5
- data/spec/default_settings.rb +0 -1
- data/ymdp.gemspec +8 -14
- metadata +13 -12
- data/lib/ymdp/compressor/compressor.rb +0 -134
- data/lib/ymdp/compressor/yuicompressor-2.4.2.jar +0 -0
- data/lib/ymdp/support/file.rb +0 -63
- data/lib/ymdp/validator/jslint.js +0 -5072
- data/lib/ymdp/validator/validator.rb +0 -122
- data/spec/compressor_spec.rb +0 -127
- data/spec/validator_spec.rb +0 -195
data/spec/compiler_spec.rb
CHANGED
@@ -83,7 +83,8 @@ describe "Template" do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should validate" do
|
86
|
-
|
86
|
+
@json_validator = mock('json_validator', :validate => true)
|
87
|
+
Epic::Validator::JSON.should_receive(:new).and_return(@json_validator)
|
87
88
|
@js_template.validate
|
88
89
|
end
|
89
90
|
end
|
@@ -113,6 +114,8 @@ describe "Template" do
|
|
113
114
|
end
|
114
115
|
|
115
116
|
it "should build" do
|
117
|
+
@js_template.configuration.compress["embedded_js"] = false
|
118
|
+
|
116
119
|
File.stub!(:read).with("filename.js").and_return("unprocessed")
|
117
120
|
|
118
121
|
# process the contents of filename.html.erb through ERB
|
@@ -120,20 +123,20 @@ describe "Template" do
|
|
120
123
|
@erb = mock('erb', :result => "processed template output")
|
121
124
|
ERB.should_receive(:new).with("unprocessed", anything, anything).and_return(@erb)
|
122
125
|
|
126
|
+
Epic::Compressor.stub!(:new).and_return(mock('compressor', :compress => "compressed template output"))
|
127
|
+
|
123
128
|
F.stub!(:save_to_file).with("processed template output")
|
124
129
|
|
125
130
|
@js_template.build.should == "processed template output"
|
126
131
|
end
|
127
132
|
|
128
133
|
it "should compress" do
|
129
|
-
@config.stub!(:compress_embedded_js?).and_return(true)
|
130
|
-
|
131
134
|
# process the contents of filename.html.erb through ERB
|
132
135
|
#
|
133
136
|
@erb = mock('erb', :result => "processed template output")
|
134
137
|
ERB.should_receive(:new).with("unprocessed", anything, anything).and_return(@erb)
|
135
138
|
|
136
|
-
|
139
|
+
Epic::Compressor.stub!(:new).and_return(mock('compressor', :compress => "compressed template"))
|
137
140
|
File.stub!(:read).with("filename.js").and_return("unprocessed")
|
138
141
|
|
139
142
|
F.stub!(:save_to_file)
|
@@ -210,7 +213,8 @@ describe "Template" do
|
|
210
213
|
@processed_haml = "processed haml"
|
211
214
|
stub_haml_class
|
212
215
|
|
213
|
-
|
216
|
+
@html_validator = mock('html_validator', :validate => true)
|
217
|
+
Epic::Validator::HTML.stub!(:new).and_return(@html_validator)
|
214
218
|
end
|
215
219
|
|
216
220
|
it "should not build if it's a partial" do
|
data/spec/default_settings.rb
CHANGED
data/ymdp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ymdp}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeff Coleman"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-30}
|
13
13
|
s.description = %q{Framework for developing applications in the Yahoo! Mail Development Platform.}
|
14
14
|
s.email = %q{progressions@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -47,19 +47,14 @@ Gem::Specification.new do |s|
|
|
47
47
|
"lib/ymdp/compiler/git_helper.rb",
|
48
48
|
"lib/ymdp/compiler/options.rb",
|
49
49
|
"lib/ymdp/compiler/template.rb",
|
50
|
-
"lib/ymdp/compressor/compressor.rb",
|
51
|
-
"lib/ymdp/compressor/yuicompressor-2.4.2.jar",
|
52
50
|
"lib/ymdp/configuration/config.rb",
|
53
51
|
"lib/ymdp/configuration/constants.rb",
|
54
52
|
"lib/ymdp/generator/templates/javascript.js",
|
55
53
|
"lib/ymdp/generator/templates/stylesheet.css",
|
56
54
|
"lib/ymdp/generator/templates/translation.pres",
|
57
55
|
"lib/ymdp/generator/templates/view.html.haml",
|
58
|
-
"lib/ymdp/support/file.rb",
|
59
56
|
"lib/ymdp/tasks/keys.rake",
|
60
57
|
"lib/ymdp/tasks/ymdp.rake",
|
61
|
-
"lib/ymdp/validator/jslint.js",
|
62
|
-
"lib/ymdp/validator/validator.rb",
|
63
58
|
"lib/ymdp/view/application.rb",
|
64
59
|
"lib/ymdp/view/application_view.rb",
|
65
60
|
"lib/ymdp/view/asset_tag_helper.rb",
|
@@ -68,7 +63,6 @@ Gem::Specification.new do |s|
|
|
68
63
|
"spec/application_view_spec.rb",
|
69
64
|
"spec/compiler_spec.rb",
|
70
65
|
"spec/compiler_template_spec.rb",
|
71
|
-
"spec/compressor_spec.rb",
|
72
66
|
"spec/configuration_spec.rb",
|
73
67
|
"spec/default_settings.rb",
|
74
68
|
"spec/domains_spec.rb",
|
@@ -77,7 +71,6 @@ Gem::Specification.new do |s|
|
|
77
71
|
"spec/spec.opts",
|
78
72
|
"spec/spec_helper.rb",
|
79
73
|
"spec/stubs.rb",
|
80
|
-
"spec/validator_spec.rb",
|
81
74
|
"spec/ymdp_base_spec.rb",
|
82
75
|
"spec/ymdp_spec.rb",
|
83
76
|
"ymdp.gemspec"
|
@@ -92,7 +85,6 @@ Gem::Specification.new do |s|
|
|
92
85
|
"spec/application_view_spec.rb",
|
93
86
|
"spec/compiler_spec.rb",
|
94
87
|
"spec/compiler_template_spec.rb",
|
95
|
-
"spec/compressor_spec.rb",
|
96
88
|
"spec/configuration_spec.rb",
|
97
89
|
"spec/default_settings.rb",
|
98
90
|
"spec/domains_spec.rb",
|
@@ -100,7 +92,6 @@ Gem::Specification.new do |s|
|
|
100
92
|
"spec/git_helper_spec.rb",
|
101
93
|
"spec/spec_helper.rb",
|
102
94
|
"spec/stubs.rb",
|
103
|
-
"spec/validator_spec.rb",
|
104
95
|
"spec/ymdp_base_spec.rb",
|
105
96
|
"spec/ymdp_spec.rb"
|
106
97
|
]
|
@@ -111,6 +102,7 @@ Gem::Specification.new do |s|
|
|
111
102
|
|
112
103
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
113
104
|
s.add_development_dependency(%q<rspec>, [">= 1.2.6"])
|
105
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
114
106
|
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
115
107
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
116
108
|
s.add_runtime_dependency(%q<hpricot>, [">= 0"])
|
@@ -125,9 +117,10 @@ Gem::Specification.new do |s|
|
|
125
117
|
s.add_runtime_dependency(%q<ymdp_generator>, [">= 0"])
|
126
118
|
s.add_runtime_dependency(%q<ymdt>, [">= 0"])
|
127
119
|
s.add_runtime_dependency(%q<yrb>, [">= 0"])
|
128
|
-
s.add_runtime_dependency(%q<
|
120
|
+
s.add_runtime_dependency(%q<epic>, [">= 0"])
|
129
121
|
else
|
130
122
|
s.add_dependency(%q<rspec>, [">= 1.2.6"])
|
123
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
131
124
|
s.add_dependency(%q<haml>, [">= 0"])
|
132
125
|
s.add_dependency(%q<json>, [">= 0"])
|
133
126
|
s.add_dependency(%q<hpricot>, [">= 0"])
|
@@ -142,10 +135,11 @@ Gem::Specification.new do |s|
|
|
142
135
|
s.add_dependency(%q<ymdp_generator>, [">= 0"])
|
143
136
|
s.add_dependency(%q<ymdt>, [">= 0"])
|
144
137
|
s.add_dependency(%q<yrb>, [">= 0"])
|
145
|
-
s.add_dependency(%q<
|
138
|
+
s.add_dependency(%q<epic>, [">= 0"])
|
146
139
|
end
|
147
140
|
else
|
148
141
|
s.add_dependency(%q<rspec>, [">= 1.2.6"])
|
142
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
149
143
|
s.add_dependency(%q<haml>, [">= 0"])
|
150
144
|
s.add_dependency(%q<json>, [">= 0"])
|
151
145
|
s.add_dependency(%q<hpricot>, [">= 0"])
|
@@ -160,7 +154,7 @@ Gem::Specification.new do |s|
|
|
160
154
|
s.add_dependency(%q<ymdp_generator>, [">= 0"])
|
161
155
|
s.add_dependency(%q<ymdt>, [">= 0"])
|
162
156
|
s.add_dependency(%q<yrb>, [">= 0"])
|
163
|
-
s.add_dependency(%q<
|
157
|
+
s.add_dependency(%q<epic>, [">= 0"])
|
164
158
|
end
|
165
159
|
end
|
166
160
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ymdp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Coleman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-30 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.2.6
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: cucumber
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: haml
|
27
37
|
type: :runtime
|
@@ -163,7 +173,7 @@ dependencies:
|
|
163
173
|
version: "0"
|
164
174
|
version:
|
165
175
|
- !ruby/object:Gem::Dependency
|
166
|
-
name:
|
176
|
+
name: epic
|
167
177
|
type: :runtime
|
168
178
|
version_requirement:
|
169
179
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -212,19 +222,14 @@ files:
|
|
212
222
|
- lib/ymdp/compiler/git_helper.rb
|
213
223
|
- lib/ymdp/compiler/options.rb
|
214
224
|
- lib/ymdp/compiler/template.rb
|
215
|
-
- lib/ymdp/compressor/compressor.rb
|
216
|
-
- lib/ymdp/compressor/yuicompressor-2.4.2.jar
|
217
225
|
- lib/ymdp/configuration/config.rb
|
218
226
|
- lib/ymdp/configuration/constants.rb
|
219
227
|
- lib/ymdp/generator/templates/javascript.js
|
220
228
|
- lib/ymdp/generator/templates/stylesheet.css
|
221
229
|
- lib/ymdp/generator/templates/translation.pres
|
222
230
|
- lib/ymdp/generator/templates/view.html.haml
|
223
|
-
- lib/ymdp/support/file.rb
|
224
231
|
- lib/ymdp/tasks/keys.rake
|
225
232
|
- lib/ymdp/tasks/ymdp.rake
|
226
|
-
- lib/ymdp/validator/jslint.js
|
227
|
-
- lib/ymdp/validator/validator.rb
|
228
233
|
- lib/ymdp/view/application.rb
|
229
234
|
- lib/ymdp/view/application_view.rb
|
230
235
|
- lib/ymdp/view/asset_tag_helper.rb
|
@@ -233,7 +238,6 @@ files:
|
|
233
238
|
- spec/application_view_spec.rb
|
234
239
|
- spec/compiler_spec.rb
|
235
240
|
- spec/compiler_template_spec.rb
|
236
|
-
- spec/compressor_spec.rb
|
237
241
|
- spec/configuration_spec.rb
|
238
242
|
- spec/default_settings.rb
|
239
243
|
- spec/domains_spec.rb
|
@@ -242,7 +246,6 @@ files:
|
|
242
246
|
- spec/spec.opts
|
243
247
|
- spec/spec_helper.rb
|
244
248
|
- spec/stubs.rb
|
245
|
-
- spec/validator_spec.rb
|
246
249
|
- spec/ymdp_base_spec.rb
|
247
250
|
- spec/ymdp_spec.rb
|
248
251
|
- ymdp.gemspec
|
@@ -279,7 +282,6 @@ test_files:
|
|
279
282
|
- spec/application_view_spec.rb
|
280
283
|
- spec/compiler_spec.rb
|
281
284
|
- spec/compiler_template_spec.rb
|
282
|
-
- spec/compressor_spec.rb
|
283
285
|
- spec/configuration_spec.rb
|
284
286
|
- spec/default_settings.rb
|
285
287
|
- spec/domains_spec.rb
|
@@ -287,6 +289,5 @@ test_files:
|
|
287
289
|
- spec/git_helper_spec.rb
|
288
290
|
- spec/spec_helper.rb
|
289
291
|
- spec/stubs.rb
|
290
|
-
- spec/validator_spec.rb
|
291
292
|
- spec/ymdp_base_spec.rb
|
292
293
|
- spec/ymdp_spec.rb
|
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'ymdp/base'
|
3
|
-
require 'active_support'
|
4
|
-
require 'support/file'
|
5
|
-
|
6
|
-
module YMDP
|
7
|
-
module Compressor #:nodoc:
|
8
|
-
# Compresses a file using the specified compressor/minifier (currently YUI Compressor 2.4.2).
|
9
|
-
#
|
10
|
-
# === Usage
|
11
|
-
#
|
12
|
-
# YMDP::Compressor::Base.compress("filename.js", "type" => "js")
|
13
|
-
#
|
14
|
-
# YMDP::Compressor::Base.compress("filename.css", "type" => "css")
|
15
|
-
#
|
16
|
-
# Outputs the compressed file to <tt>_path_.min.</tt>
|
17
|
-
#
|
18
|
-
# === Options
|
19
|
-
#
|
20
|
-
# "type":: "js" or "css". Identifies the file type.
|
21
|
-
#
|
22
|
-
# "obfuscate":: true or false. Change internal variable names within the code.
|
23
|
-
#
|
24
|
-
# "verbose":: true or false. Output warnings about code quality.
|
25
|
-
#
|
26
|
-
# "preserve_semi":: true or false. Preserve unnecessary semicolons.
|
27
|
-
#
|
28
|
-
# TODO: Make it support multiple compressors.
|
29
|
-
#
|
30
|
-
# TODO: Convert it to an object, so you instantiate the Compressor class and then call it
|
31
|
-
# on a file or a string.
|
32
|
-
#
|
33
|
-
# TODO: Get some stringify_keys! action going so you can send in symbols or strings.
|
34
|
-
#
|
35
|
-
class Base < YMDP::Base
|
36
|
-
def self.compress(path, options={})
|
37
|
-
options.stringify_keys!
|
38
|
-
compressed_display_path = display_path(path)
|
39
|
-
compressed_path = "#{path}.min"
|
40
|
-
|
41
|
-
options["type"] ||= "js"
|
42
|
-
options["type"] = options["type"].to_s
|
43
|
-
|
44
|
-
# if the compressed_file exists, don't create it again
|
45
|
-
#
|
46
|
-
unless File.exists?(compressed_path)
|
47
|
-
$stdout.print " #{compressed_display_path} compressing . . . "
|
48
|
-
compressed = ''
|
49
|
-
|
50
|
-
# set options and defaults
|
51
|
-
#
|
52
|
-
if options.delete("obfuscate")
|
53
|
-
options["nomunge"] = ""
|
54
|
-
end
|
55
|
-
if options.delete("verbose")
|
56
|
-
options["verbose"] = ""
|
57
|
-
end
|
58
|
-
options["charset"] = "utf-8"
|
59
|
-
|
60
|
-
if options["type"].to_s == "js" && !options["preserve_semi"]
|
61
|
-
options["preserve-semi"] = ""
|
62
|
-
end
|
63
|
-
|
64
|
-
# join the options together for appending to the command line
|
65
|
-
#
|
66
|
-
options_string = options.map {|k,v| "--#{k} #{v}"}.join(" ")
|
67
|
-
|
68
|
-
|
69
|
-
# call the compressor
|
70
|
-
#
|
71
|
-
|
72
|
-
compressor_path = File.expand_path("#{File.dirname(__FILE__)}/yuicompressor-2.4.2.jar")
|
73
|
-
raise "#{compressor_path} does not exist" unless File.exists?(compressor_path)
|
74
|
-
|
75
|
-
command = "java -jar #{compressor_path} #{options_string} #{path} -o #{compressed_path} 2>&1"
|
76
|
-
result = F.execute(command, :return => true)
|
77
|
-
|
78
|
-
result.split("\n").each do |line|
|
79
|
-
if line =~ /\[ERROR\] (\d+):(\d+):(.*)/
|
80
|
-
line_number = $1.to_i
|
81
|
-
error = "Error at #{compressed_display_path} line #{line_number} character #{$2}: #{$3}"
|
82
|
-
error += F.get_line_from_file(path, line_number)
|
83
|
-
|
84
|
-
$stdout.puts error
|
85
|
-
g(error)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
if result =~ /ERROR/
|
90
|
-
raise "JavaScript errors in #{compressed_display_path}"
|
91
|
-
else
|
92
|
-
$stdout.puts "OK"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# The compressed file should exist now. If it does, use it. If not, raise an error.
|
97
|
-
#
|
98
|
-
if File.exists?(compressed_path)
|
99
|
-
compressed = File.read(compressed_path)
|
100
|
-
else
|
101
|
-
raise "File does not exist: #{compressed_display_path}"
|
102
|
-
end
|
103
|
-
|
104
|
-
compressed
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# Compresses a CSS file using the specified compressor/minifier (currently YUI Compressor 2.4.2).
|
109
|
-
#
|
110
|
-
# === Usage
|
111
|
-
#
|
112
|
-
# YMDP::Compressor::Stylesheet.compress("filename.css")
|
113
|
-
#
|
114
|
-
class Stylesheet < Base
|
115
|
-
# TODO: Add options hash
|
116
|
-
def self.compress(path)
|
117
|
-
super(path, "type" => "css")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Compresses a JavaScript file using the specified compressor/minifier (currently YUI Compressor 2.4.2).
|
122
|
-
#
|
123
|
-
# === Usage
|
124
|
-
#
|
125
|
-
# YMDP::Compressor::JavaScript.compress("filename.js")
|
126
|
-
#
|
127
|
-
class JavaScript < Base
|
128
|
-
# TODO: Add options hash
|
129
|
-
def self.compress(filename)
|
130
|
-
super(filename, "type" => "js")
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
Binary file
|
data/lib/ymdp/support/file.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
# Provides a wrapper around common calls that interact with the file system.
|
2
|
-
#
|
3
|
-
module F
|
4
|
-
|
5
|
-
module_function
|
6
|
-
|
7
|
-
# Concatenates together the contents of all the files in the <tt>source_path</tt>
|
8
|
-
# into the <tt>destination_path</tt>.
|
9
|
-
#
|
10
|
-
def concat_files(source_path, destination_path)
|
11
|
-
File.open(destination_path, "a") do |output|
|
12
|
-
Dir[source_path].each do |path|
|
13
|
-
output.puts File.read(path)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# Saves the <tt>output</tt> string to the <tt>destination_path</tt> given.
|
19
|
-
#
|
20
|
-
# Returns <tt>true</tt> if the destination file was newly created, <tt>false</tt> if
|
21
|
-
# it already existed.
|
22
|
-
#
|
23
|
-
def save_to_file(output, destination_path)
|
24
|
-
if File.exists?(destination_path)
|
25
|
-
false
|
26
|
-
else
|
27
|
-
File.open(destination_path, "w") do |w|
|
28
|
-
w.write(output)
|
29
|
-
end
|
30
|
-
true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Given a <tt>path</tt> and <tt>line_number</tt>, returns the line and two lines previous
|
35
|
-
#
|
36
|
-
# Used for displaying validation errors.
|
37
|
-
#
|
38
|
-
def get_line_from_file(path, line_number)
|
39
|
-
line_number = line_number.to_i
|
40
|
-
output = "\n"
|
41
|
-
lines = File.readlines(path)
|
42
|
-
|
43
|
-
3.times do |i|
|
44
|
-
line = lines[line_number-(3-i)]
|
45
|
-
output += line if line
|
46
|
-
end
|
47
|
-
|
48
|
-
output += "\n"
|
49
|
-
output
|
50
|
-
end
|
51
|
-
|
52
|
-
# Execute a system command. If the parameter <tt>:return</tt> is true, execute the command
|
53
|
-
# with the backtick (`) command and return the results. Otherwise, just execute the command
|
54
|
-
# and let the output go to the screen.
|
55
|
-
#
|
56
|
-
def execute(command, params={})
|
57
|
-
if params[:return]
|
58
|
-
`#{command}`
|
59
|
-
else
|
60
|
-
Kernel.system command
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|