ymdp 0.1.6 → 0.1.7
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/History.txt +21 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/ymdp/application_view.rb +153 -116
- data/lib/ymdp/base.rb +22 -1
- data/lib/ymdp/compiler/domains.rb +1 -1
- data/lib/ymdp/compiler/git_helper.rb +18 -15
- data/lib/ymdp/compiler/template.rb +46 -40
- data/lib/ymdp/configuration/config.rb +3 -3
- data/lib/ymdp/processor/compressor.rb +66 -13
- data/lib/ymdp/processor/form_post.rb +2 -2
- data/lib/ymdp/processor/validator.rb +36 -16
- data/lib/ymdp/processor/w3c.rb +20 -18
- data/lib/ymdp/support/file.rb +45 -78
- data/lib/ymdp/translator/base.rb +39 -38
- data/spec/application_view_spec.rb +376 -0
- data/spec/compiler_spec.rb +49 -7
- data/spec/compiler_template_spec.rb +243 -11
- data/spec/compressor_spec.rb +123 -0
- data/spec/configuration_spec.rb +116 -3
- data/spec/file_spec.rb +103 -0
- data/spec/git_helper_spec.rb +53 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/stubs.rb +42 -2
- data/spec/translator_spec.rb +317 -1
- data/spec/validator_spec.rb +171 -0
- data/spec/ymdp_base_spec.rb +40 -0
- data/ymdp.gemspec +11 -4
- metadata +11 -4
- data/lib/ymdp/helpers.rb +0 -4
- data/lib/ymdp/support/blank.rb +0 -58
@@ -0,0 +1,171 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'processor/w3c'
|
3
|
+
|
4
|
+
describe "Validator" do
|
5
|
+
before(:each) do
|
6
|
+
stub_io
|
7
|
+
stub_config
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "HTML" do
|
11
|
+
before(:each) do
|
12
|
+
@resp = mock('resp', :read_body => "[Valid]")
|
13
|
+
W3CPoster.stub!(:post_file_to_w3c_validator).and_return(@resp)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should call validator" do
|
17
|
+
W3CPoster.should_receive(:post_file_to_w3c_validator).and_return(@resp)
|
18
|
+
YMDP::Validator::HTML.validate("path")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should print OK" do
|
22
|
+
$stdout.should_receive(:puts).with(/OK/)
|
23
|
+
YMDP::Validator::HTML.validate("path")
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "errors" do
|
27
|
+
before(:each) do
|
28
|
+
@resp.stub!(:read_body => "Not Valid")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should output a message" do
|
32
|
+
$stdout.should_receive(:puts).with(/not valid HTML/)
|
33
|
+
lambda {
|
34
|
+
YMDP::Validator::HTML.validate("path")
|
35
|
+
}.should raise_error("Invalid HTML")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should open the error file" do
|
39
|
+
File.should_receive(:open).with(/path_errors/, "w").and_return(@file)
|
40
|
+
lambda {
|
41
|
+
YMDP::Validator::HTML.validate("path")
|
42
|
+
}.should raise_error("Invalid HTML")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should write to the error file" do
|
46
|
+
@file.should_receive(:puts).with("Not Valid")
|
47
|
+
lambda {
|
48
|
+
YMDP::Validator::HTML.validate("path")
|
49
|
+
}.should raise_error("Invalid HTML")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should growl a message" do
|
53
|
+
@g.should_receive(:notify).with(anything, anything, /HTML validation errors/, anything, anything)
|
54
|
+
lambda {
|
55
|
+
YMDP::Validator::HTML.validate("path")
|
56
|
+
}.should raise_error("Invalid HTML")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should open the error file" do
|
60
|
+
F.should_receive(:execute).with(/open/)
|
61
|
+
lambda {
|
62
|
+
YMDP::Validator::HTML.validate("path")
|
63
|
+
}.should raise_error("Invalid HTML")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should raise an error" do
|
67
|
+
lambda {
|
68
|
+
YMDP::Validator::HTML.validate("path")
|
69
|
+
}.should raise_error("Invalid HTML")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "JavaScript" do
|
75
|
+
describe "valid" do
|
76
|
+
before(:each) do
|
77
|
+
F.stub!(:execute).with(/java/, :return => true).and_return("jslint: No problems found")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should output 'OK'" do
|
81
|
+
$stdout.should_receive(:puts).with(/OK/)
|
82
|
+
YMDP::Validator::JavaScript.validate("path")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "invalid" do
|
87
|
+
before(:each) do
|
88
|
+
@lines_with_errors = [
|
89
|
+
"line 3 character 2: Unnecessary semicolon",
|
90
|
+
"line 8 character 3: Unknown thingamajig"
|
91
|
+
].join("\n")
|
92
|
+
F.stub!(:execute).with(/java/, :return => true).and_return(@lines_with_errors)
|
93
|
+
F.stub!(:get_line_from_file).with(anything, 1)
|
94
|
+
F.stub!(:get_line_from_file).with(anything, 5)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should growl" do
|
98
|
+
@g.should_receive(:notify).with(anything, anything, /JavaScript Errors/, anything, anything)
|
99
|
+
lambda {
|
100
|
+
YMDP::Validator::JavaScript.validate("path")
|
101
|
+
}.should raise_error
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should output errors" do
|
105
|
+
$stdout.should_receive(:puts).with(/Unnecessary semicolon/)
|
106
|
+
$stdout.should_receive(:puts).with(/Unknown thingamajig/)
|
107
|
+
lambda {
|
108
|
+
YMDP::Validator::JavaScript.validate("path")
|
109
|
+
}.should raise_error
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should raise error" do
|
113
|
+
lambda {
|
114
|
+
YMDP::Validator::JavaScript.validate("path")
|
115
|
+
}.should raise_error(/JavaScript Errors/)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "JSON" do
|
121
|
+
describe "valid" do
|
122
|
+
before(:each) do
|
123
|
+
F.stub!(:execute).with(/java/, :return => true).and_return("jslint: No problems found")
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should output 'OK'" do
|
127
|
+
$stdout.should_receive(:puts).with(/OK/)
|
128
|
+
YMDP::Validator::JSON.validate("path")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "invalid" do
|
133
|
+
before(:each) do
|
134
|
+
@lines_with_errors = [
|
135
|
+
"line 3 character 2: Unnecessary semicolon",
|
136
|
+
"line 8 character 3: Unknown thingamajig"
|
137
|
+
].join("\n")
|
138
|
+
F.stub!(:execute).with(/java/, :return => true).and_return(@lines_with_errors)
|
139
|
+
F.stub!(:get_line_from_file).with(anything, 1)
|
140
|
+
F.stub!(:get_line_from_file).with(anything, 5)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should growl" do
|
144
|
+
@g.should_receive(:notify).with(anything, anything, /JavaScript Errors/, anything, anything)
|
145
|
+
lambda {
|
146
|
+
YMDP::Validator::JSON.validate("path")
|
147
|
+
}.should raise_error
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should output errors" do
|
151
|
+
$stdout.should_receive(:puts).with(/Unnecessary semicolon/)
|
152
|
+
$stdout.should_receive(:puts).with(/Unknown thingamajig/)
|
153
|
+
lambda {
|
154
|
+
YMDP::Validator::JSON.validate("path")
|
155
|
+
}.should raise_error
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should raise error" do
|
159
|
+
lambda {
|
160
|
+
YMDP::Validator::JSON.validate("path")
|
161
|
+
}.should raise_error(/JavaScript Errors/)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "Stylesheet" do
|
166
|
+
it "should validate" do
|
167
|
+
YMDP::Validator::Stylesheet.validate("path")
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
data/spec/ymdp_base_spec.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe YMDP::Base do
|
4
|
+
before(:each) do
|
5
|
+
@base_path = File.expand_path("./")
|
6
|
+
end
|
7
|
+
|
4
8
|
describe "instantiation" do
|
5
9
|
it "should instantiate" do
|
6
10
|
@ymdp = YMDP::Base.new
|
@@ -8,6 +12,12 @@ describe YMDP::Base do
|
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
15
|
+
describe "class methods" do
|
16
|
+
it "should display path" do
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
11
21
|
describe "configuration" do
|
12
22
|
before(:each) do
|
13
23
|
@ymdp = YMDP::Base.new
|
@@ -76,6 +86,20 @@ describe YMDP::Base do
|
|
76
86
|
@ymdp.validate.should == @validate
|
77
87
|
end
|
78
88
|
|
89
|
+
it "should set base_path" do
|
90
|
+
YMDP::Base.configure do |config|
|
91
|
+
config.add_path(:base_path, @base_path)
|
92
|
+
end
|
93
|
+
@ymdp.base_path.should == @base_path
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should set class base_path" do
|
97
|
+
YMDP::Base.configure do |config|
|
98
|
+
config.add_path(:base_path, @base_path)
|
99
|
+
end
|
100
|
+
YMDP::Base.base_path.should == @base_path
|
101
|
+
end
|
102
|
+
|
79
103
|
describe "content variables" do
|
80
104
|
describe "add" do
|
81
105
|
it "should add a content_variable" do
|
@@ -120,6 +144,22 @@ describe YMDP::Base do
|
|
120
144
|
@ymdp.sprint_name.should == "Gorgonzola"
|
121
145
|
end
|
122
146
|
end
|
147
|
+
|
148
|
+
describe "display_path" do
|
149
|
+
it "should strip base_path from the display" do
|
150
|
+
YMDP::Base.configure do |config|
|
151
|
+
config.add_path(:base_path, @base_path)
|
152
|
+
end
|
153
|
+
@ymdp.display_path("#{@base_path}/file")
|
154
|
+
end
|
155
|
+
|
156
|
+
it "class method should strip base_path from the display" do
|
157
|
+
YMDP::Base.configure do |config|
|
158
|
+
config.add_path(:base_path, @base_path)
|
159
|
+
end
|
160
|
+
YMDP::Base.display_path("#{@base_path}/file")
|
161
|
+
end
|
162
|
+
end
|
123
163
|
end
|
124
164
|
end
|
125
165
|
end
|
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.7"
|
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-17}
|
13
13
|
s.default_executable = %q{ymdp}
|
14
14
|
s.description = %q{Framework for developing applications in the Yahoo! Mail Development Platform.}
|
15
15
|
s.email = %q{progressions@gmail.com}
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
23
|
".gitignore",
|
24
|
+
"History.txt",
|
24
25
|
"LICENSE",
|
25
26
|
"README.rdoc",
|
26
27
|
"Rakefile",
|
@@ -44,12 +45,10 @@ Gem::Specification.new do |s|
|
|
44
45
|
"lib/ymdp/generator/templates/stylesheet.css",
|
45
46
|
"lib/ymdp/generator/templates/translation.pres",
|
46
47
|
"lib/ymdp/generator/templates/view.html.haml",
|
47
|
-
"lib/ymdp/helpers.rb",
|
48
48
|
"lib/ymdp/processor/compressor.rb",
|
49
49
|
"lib/ymdp/processor/form_post.rb",
|
50
50
|
"lib/ymdp/processor/validator.rb",
|
51
51
|
"lib/ymdp/processor/w3c.rb",
|
52
|
-
"lib/ymdp/support/blank.rb",
|
53
52
|
"lib/ymdp/support/file.rb",
|
54
53
|
"lib/ymdp/tag_helper.rb",
|
55
54
|
"lib/ymdp/tasks/keys.rake",
|
@@ -59,6 +58,7 @@ Gem::Specification.new do |s|
|
|
59
58
|
"spec/application_view_spec.rb",
|
60
59
|
"spec/compiler_spec.rb",
|
61
60
|
"spec/compiler_template_spec.rb",
|
61
|
+
"spec/compressor_spec.rb",
|
62
62
|
"spec/configuration_spec.rb",
|
63
63
|
"spec/data/Rakefile",
|
64
64
|
"spec/data/VERSION",
|
@@ -124,10 +124,13 @@ Gem::Specification.new do |s|
|
|
124
124
|
"spec/data/script/yuicompressor-2.4.2.jar",
|
125
125
|
"spec/default_settings.rb",
|
126
126
|
"spec/domains_spec.rb",
|
127
|
+
"spec/file_spec.rb",
|
128
|
+
"spec/git_helper_spec.rb",
|
127
129
|
"spec/spec.opts",
|
128
130
|
"spec/spec_helper.rb",
|
129
131
|
"spec/stubs.rb",
|
130
132
|
"spec/translator_spec.rb",
|
133
|
+
"spec/validator_spec.rb",
|
131
134
|
"spec/ymdp_base_spec.rb",
|
132
135
|
"spec/ymdp_spec.rb",
|
133
136
|
"test.rb",
|
@@ -143,15 +146,19 @@ Gem::Specification.new do |s|
|
|
143
146
|
"spec/application_view_spec.rb",
|
144
147
|
"spec/compiler_spec.rb",
|
145
148
|
"spec/compiler_template_spec.rb",
|
149
|
+
"spec/compressor_spec.rb",
|
146
150
|
"spec/configuration_spec.rb",
|
147
151
|
"spec/data/app/helpers/application_helper.rb",
|
148
152
|
"spec/data/config/constants.rb",
|
149
153
|
"spec/data/lib/init.rb",
|
150
154
|
"spec/default_settings.rb",
|
151
155
|
"spec/domains_spec.rb",
|
156
|
+
"spec/file_spec.rb",
|
157
|
+
"spec/git_helper_spec.rb",
|
152
158
|
"spec/spec_helper.rb",
|
153
159
|
"spec/stubs.rb",
|
154
160
|
"spec/translator_spec.rb",
|
161
|
+
"spec/validator_spec.rb",
|
155
162
|
"spec/ymdp_base_spec.rb",
|
156
163
|
"spec/ymdp_spec.rb"
|
157
164
|
]
|
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.7
|
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-17 00:00:00 -06:00
|
13
13
|
default_executable: ymdp
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -144,6 +144,7 @@ extra_rdoc_files:
|
|
144
144
|
files:
|
145
145
|
- .document
|
146
146
|
- .gitignore
|
147
|
+
- History.txt
|
147
148
|
- LICENSE
|
148
149
|
- README.rdoc
|
149
150
|
- Rakefile
|
@@ -167,12 +168,10 @@ files:
|
|
167
168
|
- lib/ymdp/generator/templates/stylesheet.css
|
168
169
|
- lib/ymdp/generator/templates/translation.pres
|
169
170
|
- lib/ymdp/generator/templates/view.html.haml
|
170
|
-
- lib/ymdp/helpers.rb
|
171
171
|
- lib/ymdp/processor/compressor.rb
|
172
172
|
- lib/ymdp/processor/form_post.rb
|
173
173
|
- lib/ymdp/processor/validator.rb
|
174
174
|
- lib/ymdp/processor/w3c.rb
|
175
|
-
- lib/ymdp/support/blank.rb
|
176
175
|
- lib/ymdp/support/file.rb
|
177
176
|
- lib/ymdp/tag_helper.rb
|
178
177
|
- lib/ymdp/tasks/keys.rake
|
@@ -182,6 +181,7 @@ files:
|
|
182
181
|
- spec/application_view_spec.rb
|
183
182
|
- spec/compiler_spec.rb
|
184
183
|
- spec/compiler_template_spec.rb
|
184
|
+
- spec/compressor_spec.rb
|
185
185
|
- spec/configuration_spec.rb
|
186
186
|
- spec/data/Rakefile
|
187
187
|
- spec/data/VERSION
|
@@ -247,10 +247,13 @@ files:
|
|
247
247
|
- spec/data/script/yuicompressor-2.4.2.jar
|
248
248
|
- spec/default_settings.rb
|
249
249
|
- spec/domains_spec.rb
|
250
|
+
- spec/file_spec.rb
|
251
|
+
- spec/git_helper_spec.rb
|
250
252
|
- spec/spec.opts
|
251
253
|
- spec/spec_helper.rb
|
252
254
|
- spec/stubs.rb
|
253
255
|
- spec/translator_spec.rb
|
256
|
+
- spec/validator_spec.rb
|
254
257
|
- spec/ymdp_base_spec.rb
|
255
258
|
- spec/ymdp_spec.rb
|
256
259
|
- test.rb
|
@@ -288,14 +291,18 @@ test_files:
|
|
288
291
|
- spec/application_view_spec.rb
|
289
292
|
- spec/compiler_spec.rb
|
290
293
|
- spec/compiler_template_spec.rb
|
294
|
+
- spec/compressor_spec.rb
|
291
295
|
- spec/configuration_spec.rb
|
292
296
|
- spec/data/app/helpers/application_helper.rb
|
293
297
|
- spec/data/config/constants.rb
|
294
298
|
- spec/data/lib/init.rb
|
295
299
|
- spec/default_settings.rb
|
296
300
|
- spec/domains_spec.rb
|
301
|
+
- spec/file_spec.rb
|
302
|
+
- spec/git_helper_spec.rb
|
297
303
|
- spec/spec_helper.rb
|
298
304
|
- spec/stubs.rb
|
299
305
|
- spec/translator_spec.rb
|
306
|
+
- spec/validator_spec.rb
|
300
307
|
- spec/ymdp_base_spec.rb
|
301
308
|
- spec/ymdp_spec.rb
|
data/lib/ymdp/helpers.rb
DELETED
data/lib/ymdp/support/blank.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
# An object is blank if it's false, empty, or a whitespace string.
|
3
|
-
# For example, "", " ", +nil+, [], and {} are blank.
|
4
|
-
#
|
5
|
-
# This simplifies
|
6
|
-
#
|
7
|
-
# if !address.nil? && !address.empty?
|
8
|
-
#
|
9
|
-
# to
|
10
|
-
#
|
11
|
-
# if !address.blank?
|
12
|
-
def blank?
|
13
|
-
respond_to?(:empty?) ? empty? : !self
|
14
|
-
end
|
15
|
-
|
16
|
-
# An object is present if it's not blank.
|
17
|
-
def present?
|
18
|
-
!blank?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class NilClass #:nodoc:
|
23
|
-
def blank?
|
24
|
-
true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class FalseClass #:nodoc:
|
29
|
-
def blank?
|
30
|
-
true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class TrueClass #:nodoc:
|
35
|
-
def blank?
|
36
|
-
false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class Array #:nodoc:
|
41
|
-
alias_method :blank?, :empty?
|
42
|
-
end
|
43
|
-
|
44
|
-
class Hash #:nodoc:
|
45
|
-
alias_method :blank?, :empty?
|
46
|
-
end
|
47
|
-
|
48
|
-
class String #:nodoc:
|
49
|
-
def blank?
|
50
|
-
self !~ /\S/
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class Numeric #:nodoc:
|
55
|
-
def blank?
|
56
|
-
false
|
57
|
-
end
|
58
|
-
end
|