el 0.5.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,127 @@
1
+ module ELTest__ipcm
2
+
3
+ Spec.new self do
4
+
5
+ Curl = %x[which curl].strip
6
+ fail('"curl" executable not found') unless File.executable?(Curl)
7
+
8
+ Thin = %x[which thin].strip
9
+ fail('"thin" executable not found') unless File.executable?(Thin)
10
+
11
+ def get port, url
12
+ %x[#{Curl} -s localhost:#{port}/#{url.to_s.gsub(/\A\/+/, '')}].strip
13
+ end
14
+
15
+ wd = File.expand_path('../ipcm', __FILE__) + '/'
16
+ pids_dir = "#{wd}/tmp/pids/"
17
+ logs_dir = "#{wd}/log/"
18
+ ipcm_dir = "#{wd}/tmp/ipcm/"
19
+ port = 65_000
20
+ servers = 2
21
+
22
+ cleanup = proc do
23
+ FileUtils.rm_rf(pids_dir) || fail("Unable to remove #{pids_dir}")
24
+ FileUtils.rm_rf(logs_dir) || fail("Unable to remove #{logs_dir}")
25
+ FileUtils.rm_rf(ipcm_dir) || fail("Unable to remove #{ipcm_dir}")
26
+ end
27
+ start_servers = proc do
28
+ puts %x[#{Thin} -c #{wd} -p #{port} -s #{servers} start]
29
+ sleep 1
30
+ end
31
+ stop_servers = proc do
32
+ system("#{Thin} -c #{wd} -p #{port} -s #{servers} stop &> /dev/null")
33
+ end
34
+
35
+ cleanup.call
36
+ stop_servers.call
37
+ start_servers.call
38
+
39
+ pids = Dir[pids_dir + '/*.pid'].map { |f| File.read(f).to_i }
40
+
41
+ unless pids.size == servers
42
+ stop_servers.call
43
+ cleanup.call
44
+ fail 'Was unable to start app on all specified ports. \
45
+ Make sure %s ports are bind-able' % servers.times.map{ |n| port + n}.inspect
46
+ end
47
+
48
+ Context :cache do
49
+ Testing 'main app' do
50
+ body = rand.to_s
51
+ expect { get port, "cache_test/#{body}" } == body
52
+
53
+ Ensure 'cached body returned' do
54
+ expect { get port, "cache_test/#{rand}" } == body
55
+ end
56
+ end
57
+
58
+ 1.upto(servers-1).each do |n|
59
+ p = port + n
60
+ Testing "app on port #{p}" do
61
+ body = rand.to_s
62
+ expect { get p, "cache_test/#{body}" } == body
63
+
64
+ Ensure 'cached body returned' do
65
+ expect { get p, "cache_test/#{rand}" } == body
66
+ end
67
+ end
68
+ end
69
+
70
+ Testing 'cache cleaner' do
71
+ body = rand.to_s
72
+ expect { get port, "cache_test/#{body}/?clear_cache=true" } == body
73
+
74
+ Ensure 'cache cleaned also on other apps' do
75
+ 1.upto(servers-1).each do |n|
76
+ p = port + n
77
+ Testing "app on port #{p}" do
78
+ body = rand.to_s
79
+ expect { get p, "cache_test/#{body}" } == body
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ Context :compiler do
87
+ Testing 'main app' do
88
+ body = rand.to_s
89
+ expect { get port, "compiler_test/#{body}" } == body
90
+
91
+ Ensure 'compiled body returned' do
92
+ expect { get port, "compiler_test/#{rand}" } == body
93
+ end
94
+ end
95
+
96
+ 1.upto(servers-1).each do |n|
97
+ p = port + n
98
+ Testing "app on port #{p}" do
99
+ body = rand.to_s
100
+ expect { get p, "compiler_test/#{body}" } == body
101
+
102
+ Ensure 'compiled body returned' do
103
+ expect { get p, "compiler_test/#{rand}" } == body
104
+ end
105
+ end
106
+ end
107
+
108
+ Testing 'complier cleaner' do
109
+ body = rand.to_s
110
+ expect { get port, "compiler_test/#{body}/?clear_compiler=true" } == body
111
+
112
+ Ensure 'compiler cleaned also on other apps' do
113
+ 1.upto(servers-1).each do |n|
114
+ p = port + n
115
+ Testing "app on port #{p}" do
116
+ body = rand.to_s
117
+ expect { get p, "compiler_test/#{body}" } == body
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ stop_servers.call
125
+ cleanup.call
126
+ end
127
+ end
@@ -0,0 +1,101 @@
1
+ module ELTest__assets
2
+
3
+ path1 = File.expand_path('../sprockets', __FILE__)
4
+ path2 = File.expand_path('../assets', __FILE__)
5
+
6
+ class SprocketsApp < E
7
+ map :app
8
+
9
+ def finder
10
+ if asset = assets[params[:asset]]
11
+ asset.pathname
12
+ end
13
+ end
14
+ end
15
+
16
+ Spec.new self do
17
+
18
+ app E.new {
19
+ assets_url '/assets'
20
+ assets.append_path path1
21
+ assets.append_path path2
22
+ mount SprocketsApp
23
+ }
24
+
25
+ Testing :server do
26
+ map :assets
27
+
28
+ Should 'find files in assets/ folder' do
29
+ get 'master.js'
30
+ is(last_response).ok?
31
+ does(/master\.js/).match_body?
32
+
33
+ get 'master.png'
34
+ is(last_response).ok?
35
+ expect(last_response['Content-Type']) == 'image/png'
36
+ end
37
+
38
+ Should 'find files in sprockets/ folder' do
39
+ get 'app.js'
40
+ is(last_response).ok?
41
+ does(/AppClass/).match_body?
42
+ does(/UIClass/).match_body?
43
+
44
+ get 'app.css'
45
+ is(last_response).ok?
46
+ does(/body/).match_body?
47
+ does(/div/).match_body?
48
+ end
49
+ end
50
+
51
+ Testing :finder do
52
+ map :app
53
+
54
+ get :finder, asset: 'app.js'
55
+ expect(File.dirname(last_response.body)) == path1
56
+
57
+ get :finder, asset: 'master.js'
58
+ expect(File.dirname(last_response.body)) == path2
59
+ end
60
+ end
61
+
62
+ Spec.new self do
63
+ app E.new {
64
+ root File.expand_path('..', __FILE__)
65
+ assets_url '/assets'
66
+ assets.append_path 'assets'
67
+ assets.append_path 'sprockets'
68
+ mount SprocketsApp
69
+ }
70
+ map :assets
71
+
72
+ Testing 'append_path with relative paths' do
73
+ Should 'find files in assets/ folder' do
74
+ get 'master.js'
75
+ is(last_response).ok?
76
+ does(/master\.js/).match_body?
77
+
78
+ get 'master.css'
79
+ is(last_response).ok?
80
+ does(/master\.css/).match_body?
81
+ end
82
+
83
+ Should 'find files in sprockets/ folder' do
84
+ get 'app.css'
85
+ is(last_response).ok?
86
+ does(/body/).match_body?
87
+ end
88
+ end
89
+
90
+ Testing 'finder with relative paths' do
91
+ map :app
92
+
93
+ get :finder, asset: 'app.js'
94
+ expect(File.dirname(last_response.body)) == path1
95
+
96
+ get :finder, asset: 'master.js'
97
+ expect(File.dirname(last_response.body)) == path2
98
+ end
99
+
100
+ end
101
+ end
@@ -0,0 +1,170 @@
1
+ module ELTest__tag_factory
2
+ Spec.new self do
3
+ include EL::TagFactory
4
+
5
+ Testing :doctype do
6
+ check(doctype_tag) == "<!DOCTYPE html>\n"
7
+ check(doctype_tag { :smth } ) == "<!DOCTYPE html>\nsmth"
8
+ check(doctype_tag { p_tag :smth} ) == "<!DOCTYPE html>\n<p>smth</p>"
9
+ end
10
+
11
+ Should 'return closed empty tags when no text nor proc given' do
12
+ expect(html_tag) == '<html></html>'
13
+ expect(a_tag) == '<a></a>'
14
+ expect(div_tag) == '<div></div>'
15
+ end
16
+
17
+ Should 'use first argument as content' do
18
+ expect(h1_tag :foo) == '<h1>foo</h1>'
19
+ expect(p_tag :bar) == '<p>bar</p>'
20
+ end
21
+
22
+ Should 'use second arg as attrs' do
23
+ expect(a_tag :foo, href: :bar) == '<a href="bar">foo</a>'
24
+ expect(option_tag :label, value: :value) == '<option value="value">label</option>'
25
+ Ensure 'multiple attrs properly converted to string' do
26
+ expect(p_tag :smth, class: :foo, style: :bar) == '<p class="foo" style="bar">smth</p>'
27
+ end
28
+ end
29
+
30
+ Should 'work when only attrs given' do
31
+ expect(a_tag href: :foo, title: :bar) == '<a href="foo" title="bar"></a>'
32
+ end
33
+
34
+ Should 'work when attrs and proc given' do
35
+ expect(html_tag(manifest: :foo) { :body }) == '<html manifest="foo">body</html>'
36
+ end
37
+
38
+ Should 'work well with nested procs' do
39
+ expect(html_tag { div_tag :body }) == '<html>&lt;div&gt;body&lt;/div&gt;</html>'
40
+ expect(html_tag! { div_tag! { a_tag(:foo) }}) == '<html><div><a>foo</a></div></html>'
41
+ html = doctype_tag do
42
+ html_tag! do
43
+ head_tag! do
44
+ meta_tag(charset: 'UTF-8') +
45
+ title_tag(:smth)
46
+ end +
47
+ body_tag! do
48
+ div_tag :smth
49
+ end
50
+ end
51
+ end
52
+ expect(html) == '<!DOCTYPE html>
53
+ <html><head><meta charset="UTF-8"><title>smth</title></head><body><div>smth</div></body></html>'
54
+ end
55
+
56
+ Testing 'empty tags' do
57
+ expect(br_tag) == '<br>'
58
+ expect(hr_tag) == '<hr>'
59
+ expect(meta_tag charset: 'UTF-8') == '<meta charset="UTF-8">'
60
+ end
61
+
62
+ Testing :comment_tag do
63
+ expect(comment_tag :smth) == '<!-- smth -->'
64
+ expect(comment_tag { :smth }) == '<!-- smth -->'
65
+ end
66
+
67
+ Testing :js_tag do
68
+ does(js_tag 'url').match? 'src="url.js"'
69
+ does(js_tag 'url').match? 'type="text/javascript"'
70
+
71
+ Ensure 'url has priority over :src option' do
72
+ does(js_tag 'foo', src: 'bar').match? 'src="foo.js"'
73
+ end
74
+
75
+ Should 'append suffix' do
76
+ does(js_tag 'url', suffix: '-blah').match? 'src="url.js-blah"'
77
+ does(js_tag 'foo', src: 'bar', suffix: '-blah').match? 'src="foo.js-blah"'
78
+ end
79
+ end
80
+
81
+ Testing :css_tag do
82
+ does(css_tag 'url').match? 'rel="stylesheet"'
83
+ does(css_tag 'url').match? 'href="url.css"'
84
+
85
+ Ensure 'url has priority over :src option' do
86
+ does(css_tag 'foo', src: 'bar').match? 'href="foo.css"'
87
+ end
88
+
89
+ Should 'append suffix' do
90
+ does(css_tag 'url', suffix: '-blah').match? 'href="url.css-blah"'
91
+ does(css_tag 'foo', src: 'bar', suffix: '-blah').match? 'href="foo.css-blah"'
92
+ end
93
+ end
94
+
95
+ Testing :png_tag do
96
+ does(png_tag 'image').match? '<img src="image.png">'
97
+
98
+ Ensure 'url has priority over :src option' do
99
+ does(jpg_tag 'foo', src: 'bar').match? 'src="foo.jpg"'
100
+ end
101
+
102
+ Should 'append suffix' do
103
+ does(gif_tag 'url', suffix: '-blah').match? 'src="url.gif-blah"'
104
+ does(svg_tag 'foo', src: 'bar', suffix: '-blah').match? 'src="foo.svg-blah"'
105
+ end
106
+ end
107
+
108
+ end
109
+
110
+ class App < E
111
+ map '/'
112
+ format_for :foo, '.bar'
113
+ format '.html'
114
+
115
+ def index
116
+ end
117
+
118
+ def foo
119
+ end
120
+
121
+ def post_bar
122
+ end
123
+ end
124
+ App.mount
125
+
126
+ class App2 < E
127
+ map 'app2'
128
+ format '.bar'
129
+
130
+ def foo
131
+ end
132
+ end
133
+ App2.mount
134
+
135
+ Spec.new self do
136
+ app = App.new
137
+
138
+ Testing :link_to do
139
+ expect( app.link_to(:index) ) =~ %r[href="/index"]
140
+ expect( app.link_to('index.html') ) =~ %r[href="/index.html"]
141
+
142
+ expect( app.link_to(:foo) ) =~ %r[href="/foo">/foo]
143
+ expect( app.link_to(:foo, 'some-label') ) =~ %r[href="/foo">some-label]
144
+
145
+ expect( app.link_to(:foo, target: '_blank') ) =~
146
+ %r[href="/foo" target="_blank">/foo]
147
+
148
+ expect( app.link_to(:foo, 'some-label', target: '_blank') ) =~
149
+ %r[href="/foo" target="_blank">some-label]
150
+
151
+ expect( app.link_to(:foo) { 'some-label' } ) =~
152
+ %r[href="/foo">some-label]
153
+
154
+ expect( app.link_to(:foo, target: '_blank') { 'some-label' } ) =~
155
+ %r[href="/foo" target="_blank">some-label]
156
+
157
+ false?( app.link_to('foo.html') ) =~ %r[href="/foo.html"]
158
+ expect( app.link_to('foo.bar') ) =~ %r[href="/foo.bar"]
159
+
160
+ expect( app.link_to App2[:foo] ) =~ %r[href="/app2/foo"]
161
+ expect( app.link_to App2['foo.bar'] ) =~ %r[href="/app2/foo.bar"]
162
+
163
+ expect( app.link_to(:bar) ) =~ %r[href="/bar"]
164
+ expect( app.link_to('bar.html') ) =~ %r[href="/bar.html"]
165
+ expect( app.link_to(:baz) ) =~ %r[href="baz"]
166
+ expect( app.link_to('baz.html') ) =~ %r[href="baz.html"]
167
+ end
168
+
169
+ end
170
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: el
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Silviu Rusu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: e
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.4.8
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.4.8
27
+ - !ruby/object:Gem::Dependency
28
+ name: sprockets
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Espresso Lungo - Extra Libs for Espresso Framework
56
+ email:
57
+ - slivuz@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - docs/Assets.md
63
+ - docs/CacheManager.md
64
+ - docs/ContentHelpers.md
65
+ - docs/CRUD.md
66
+ - docs/TagFactory.md
67
+ - el.gemspec
68
+ - Gemfile
69
+ - lib/el/assets.rb
70
+ - lib/el/cache.rb
71
+ - lib/el/constants.rb
72
+ - lib/el/content_helpers.rb
73
+ - lib/el/crud.rb
74
+ - lib/el/ipcm.rb
75
+ - lib/el/tag_factory.rb
76
+ - lib/el/utils.rb
77
+ - lib/el.rb
78
+ - LICENSE
79
+ - Rakefile
80
+ - README.md
81
+ - test/assets/master.css
82
+ - test/assets/master.js
83
+ - test/assets/master.png
84
+ - test/helpers.rb
85
+ - test/ipcm/config.ru
86
+ - test/ipcm/view/compiler_test.erb
87
+ - test/setup.rb
88
+ - test/sprockets/app.css
89
+ - test/sprockets/app.js
90
+ - test/sprockets/ui.css
91
+ - test/sprockets/ui.js
92
+ - test/test__assets.rb
93
+ - test/test__cache.rb
94
+ - test/test__content_helpers.rb
95
+ - test/test__crud.rb
96
+ - test/test__ipcm.rb
97
+ - test/test__sprockets.rb
98
+ - test/test__tag_factory.rb
99
+ - .travis.yml
100
+ homepage: https://github.com/espresso/espresso-lungo
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: 1.9.2
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.0.4
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: el-0.5.0
124
+ test_files: []