tipsy 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/Gemfile +9 -0
  2. data/README.md +2 -2
  3. data/Rakefile +10 -0
  4. data/bin/tipsy +16 -5
  5. data/lib/tipsy.rb +26 -14
  6. data/lib/tipsy/application.rb +14 -16
  7. data/lib/tipsy/builder.rb +17 -4
  8. data/lib/tipsy/builders/base.rb +64 -0
  9. data/lib/tipsy/builders/export.rb +16 -0
  10. data/lib/tipsy/builders/project.rb +40 -0
  11. data/lib/tipsy/builders/remote.rb +14 -0
  12. data/lib/tipsy/compressors/css.rb +11 -0
  13. data/lib/tipsy/compressors/javascript.rb +25 -0
  14. data/lib/tipsy/helpers.rb +24 -1
  15. data/lib/tipsy/helpers/asset_paths.rb +19 -0
  16. data/lib/tipsy/helpers/asset_tags.rb +32 -0
  17. data/lib/tipsy/helpers/capture.rb +33 -0
  18. data/lib/tipsy/helpers/sass.rb +40 -0
  19. data/lib/tipsy/helpers/tag.rb +12 -0
  20. data/lib/tipsy/logger.rb +54 -3
  21. data/lib/tipsy/project/Gemfile +8 -0
  22. data/lib/tipsy/project/config.erb +5 -2
  23. data/lib/tipsy/sass/template.rb +137 -0
  24. data/lib/tipsy/server.rb +50 -7
  25. data/lib/tipsy/version.rb +1 -1
  26. data/lib/tipsy/view.rb +24 -10
  27. data/test/fixtures/about.html +1 -0
  28. data/test/fixtures/contact.html +1 -0
  29. data/test/fixtures/index.html +1 -0
  30. data/test/functional/page_test.rb +33 -0
  31. data/test/root/{assets → development/assets}/javascripts/test.js +0 -0
  32. data/test/root/{assets → development/assets}/stylesheets/screen.css.scss +0 -0
  33. data/test/root/{config.rb → development/config.rb} +0 -0
  34. data/test/root/{views → development/views}/_layout.html.erb +0 -0
  35. data/test/root/{views → development/views}/index.html.erb +0 -0
  36. data/test/root/test/assets/javascripts/test.js +0 -0
  37. data/test/root/test/assets/stylesheets/screen.css.scss +3 -0
  38. data/test/root/test/config.rb +6 -0
  39. data/test/root/test/views/_layout.html.erb +1 -0
  40. data/test/root/test/views/about/index.html +1 -0
  41. data/test/root/test/views/contact.html +1 -0
  42. data/test/root/test/views/index.html.erb +1 -0
  43. data/test/test_helper.rb +33 -0
  44. data/test/unit/helpers/asset_paths_test.rb +14 -0
  45. data/test/unit/helpers_test.rb +22 -0
  46. data/test/unit/server_test.rb +1 -0
  47. data/tipsy.gemspec +5 -4
  48. metadata +83 -35
  49. data/config.ru +0 -26
  50. data/lib/tipsy/generator.rb +0 -53
data/lib/tipsy/view.rb CHANGED
@@ -3,6 +3,9 @@ require 'tipsy/helpers'
3
3
  require 'hike'
4
4
 
5
5
  module Tipsy
6
+ ##
7
+ # Handles rendering of templates and layouts
8
+ #
6
9
  class View
7
10
 
8
11
  attr_reader :content_type
@@ -23,8 +26,9 @@ module Tipsy
23
26
 
24
27
  def render
25
28
  unless template.nil?
26
- tilt = Tilt.new(template, nil, :outvar => '@_output_buffer')
27
- context = Context.new(request)
29
+ handler = Tilt[template] || Tilt::ErubisTemplate
30
+ tilt = handler.new(template, nil, :outvar => '@_output_buffer')
31
+ context = Context.new(request, template, trail)
28
32
  contents = unless layout.nil?
29
33
  wrapped = Tilt.new(layout, nil, :outvar => '@_output_buffer')
30
34
  contents = wrapped.render(context) do |*args|
@@ -47,18 +51,28 @@ module Tipsy
47
51
  def layout
48
52
  @layout ||= (trail.find(File.join(view_path, '_layout')) || trail.find('_layout'))
49
53
  end
50
-
54
+
55
+ ##
56
+ # A rendering context. This class is the context all views are stemmed from.
57
+ #
51
58
  class Context
52
- include Tipsy::Helpers
53
-
54
- attr_accessor :request, :content, :root
59
+ include Tipsy::Helpers
60
+ attr_reader :request, :root, :template_file_name, :view_trail
55
61
 
56
- def initialize(req)
57
- @request = req, @root = Tipsy.root
58
- super
62
+ def initialize(req, tpl, trail)
63
+ @request = req
64
+ @root = Tipsy.root
65
+ @template_file_name = tpl
66
+ @view_trail = trail
67
+ __initialize_helpers
59
68
  end
60
-
61
69
  end
62
70
 
63
71
  end
72
+ end
73
+
74
+ begin
75
+ require 'erubis'
76
+ Tilt.prefer Tilt::ErubisTemplate, 'erb'
77
+ rescue LoadError
64
78
  end
@@ -0,0 +1 @@
1
+ about page
@@ -0,0 +1 @@
1
+ test contact
@@ -0,0 +1 @@
1
+ index file
@@ -0,0 +1,33 @@
1
+ require 'test_helper'
2
+
3
+ class PageTest < Test::Unit::TestCase
4
+ include Rack::Test::Methods
5
+ include Tipsy::Test::Helpers
6
+
7
+ def app
8
+ Tipsy::Test.app
9
+ end
10
+
11
+ def test_the_home_page_is_successful
12
+ get "/"
13
+ assert last_response.ok?
14
+ end
15
+
16
+ def test_the_home_page_renders_index
17
+ get "/"
18
+ to_html(last_response.body).should == fixture('index.html')
19
+ end
20
+
21
+ def test_the_about_page_renders_about
22
+ get '/about'
23
+ assert last_response.ok?
24
+ to_html(last_response.body).should == fixture('about.html')
25
+ end
26
+
27
+ def test_find_page_above_folder
28
+ get '/contact'
29
+ assert last_response.ok?
30
+ to_html(last_response.body).should == fixture('contact.html')
31
+ end
32
+
33
+ end
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ //= require_self
2
+ body{ background:black; }
3
+ p{ font-size:10px; }
@@ -0,0 +1,6 @@
1
+ class TestRoot < Tipsy::Application
2
+
3
+ # Configure assets that should be precompiled
4
+ config.assets << "application.js"
5
+
6
+ end
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1 @@
1
+ about page
@@ -0,0 +1 @@
1
+ test contact
@@ -0,0 +1 @@
1
+ index file
@@ -0,0 +1,33 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require "rack/test"
3
+ require "test/unit"
4
+ require "minitest/unit"
5
+ require "turn"
6
+ require "tipsy"
7
+ require 'matchy'
8
+
9
+ module Tipsy
10
+ module Test
11
+
12
+ def self.app
13
+ @app ||= Tipsy::Server.init!
14
+ end
15
+
16
+ module Helpers
17
+
18
+ def to_html(string)
19
+ string.strip
20
+ end
21
+
22
+ def fixture(name)
23
+ path = File.join(File.expand_path('../fixtures', __FILE__), name)
24
+ File.read(path).to_s.strip
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ Tipsy.root = File.join(File.dirname(__FILE__), '.', 'root', 'test')
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class AssetPathsTest < Test::Unit::TestCase
4
+ include Tipsy::Helpers
5
+
6
+ def test_asset_path_helper
7
+ asset_path("something.js").should == '/assets/something.js'
8
+ end
9
+
10
+ def test_absolute_asset_path
11
+ asset_path("/js/something.js").should == '/js/something.js'
12
+ end
13
+
14
+ end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ class HelpersTest < Test::Unit::TestCase
4
+ include Tipsy::Helpers
5
+
6
+ def test_tag_helper
7
+ tag(:img, :src => 'test.png').should == '<img src="test.png" />'
8
+ end
9
+
10
+ def test_content_tag_helper
11
+ content_tag(:p, 'hello', :class => 'test').should == '<p class="test">hello</p>'
12
+ end
13
+
14
+ def test_link_to_helper
15
+ link_to('link', '/home').should == '<a href="/home">link</a>'
16
+ end
17
+
18
+ def test_mail_to_helper
19
+ mail_to('test@test.com').should == '<a href="mailto:test@test.com">test@test.com</a>'
20
+ end
21
+
22
+ end
@@ -0,0 +1 @@
1
+ require 'test_helper'
data/tipsy.gemspec CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |s|
7
7
  s.name = "tipsy"
8
8
  s.version = Tipsy::VERSION
9
9
  s.authors = ["Brent Kirby"]
10
- s.email = ["brent@kurbmedia.com"]
11
- s.homepage = ""
10
+ s.email = ["info@kurbmedia.com"]
11
+ s.homepage = "https://github.com/kurbmedia/tipsy"
12
12
  s.summary = %q{A mini Rack application server for developing static sites.}
13
- s.description = %q{Tipsy is a mini Rack application for working with static websites using Tilt, Compass, and Sprockets.}
13
+ s.description = %q{Tipsy is a mini Rack application for working with static websites using Tilt, and Sprockets.}
14
14
 
15
15
  s.rubyforge_project = "tipsy"
16
16
 
@@ -24,7 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency("tilt", "~> 1.3")
25
25
  s.add_dependency("i18n", "~> 0.5")
26
26
  s.add_dependency("sass", "~> 3.1")
27
- s.add_dependency("active_support", ">= 3.0")
27
+ s.add_dependency("compass", "~> 11.5")
28
+ s.add_dependency("activesupport", ">= 3.0")
28
29
  s.add_dependency('sprockets', '~> 2.0.0.beta.12')
29
30
 
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tipsy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-06 00:00:00.000000000 -04:00
13
- default_executable:
12
+ date: 2011-08-08 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rack
17
- requirement: &70334947082500 !ruby/object:Gem::Requirement
16
+ requirement: &70124632101280 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: '1.2'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *70334947082500
24
+ version_requirements: *70124632101280
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: rack-test
28
- requirement: &70334947081980 !ruby/object:Gem::Requirement
27
+ requirement: &70124632100660 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ~>
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: '0.5'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *70334947081980
35
+ version_requirements: *70124632100660
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: tilt
39
- requirement: &70334947081520 !ruby/object:Gem::Requirement
38
+ requirement: &70124632100080 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: '1.3'
45
44
  type: :runtime
46
45
  prerelease: false
47
- version_requirements: *70334947081520
46
+ version_requirements: *70124632100080
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: i18n
50
- requirement: &70334947081020 !ruby/object:Gem::Requirement
49
+ requirement: &70124632099500 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ~>
@@ -55,10 +54,10 @@ dependencies:
55
54
  version: '0.5'
56
55
  type: :runtime
57
56
  prerelease: false
58
- version_requirements: *70334947081020
57
+ version_requirements: *70124632099500
59
58
  - !ruby/object:Gem::Dependency
60
59
  name: sass
61
- requirement: &70334947080560 !ruby/object:Gem::Requirement
60
+ requirement: &70124632098860 !ruby/object:Gem::Requirement
62
61
  none: false
63
62
  requirements:
64
63
  - - ~>
@@ -66,10 +65,21 @@ dependencies:
66
65
  version: '3.1'
67
66
  type: :runtime
68
67
  prerelease: false
69
- version_requirements: *70334947080560
68
+ version_requirements: *70124632098860
70
69
  - !ruby/object:Gem::Dependency
71
- name: active_support
72
- requirement: &70334947080100 !ruby/object:Gem::Requirement
70
+ name: compass
71
+ requirement: &70124632098360 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '11.5'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: *70124632098360
80
+ - !ruby/object:Gem::Dependency
81
+ name: activesupport
82
+ requirement: &70124632097860 !ruby/object:Gem::Requirement
73
83
  none: false
74
84
  requirements:
75
85
  - - ! '>='
@@ -77,10 +87,10 @@ dependencies:
77
87
  version: '3.0'
78
88
  type: :runtime
79
89
  prerelease: false
80
- version_requirements: *70334947080100
90
+ version_requirements: *70124632097860
81
91
  - !ruby/object:Gem::Dependency
82
92
  name: sprockets
83
- requirement: &70334947079640 !ruby/object:Gem::Requirement
93
+ requirement: &70124632091080 !ruby/object:Gem::Requirement
84
94
  none: false
85
95
  requirements:
86
96
  - - ~>
@@ -88,11 +98,11 @@ dependencies:
88
98
  version: 2.0.0.beta.12
89
99
  type: :runtime
90
100
  prerelease: false
91
- version_requirements: *70334947079640
101
+ version_requirements: *70124632091080
92
102
  description: Tipsy is a mini Rack application for working with static websites using
93
- Tilt, Compass, and Sprockets.
103
+ Tilt, and Sprockets.
94
104
  email:
95
- - brent@kurbmedia.com
105
+ - info@kurbmedia.com
96
106
  executables:
97
107
  - tipsy
98
108
  extensions: []
@@ -103,32 +113,55 @@ files:
103
113
  - README.md
104
114
  - Rakefile
105
115
  - bin/tipsy
106
- - config.ru
107
116
  - lib/tipsy.rb
108
117
  - lib/tipsy/application.rb
109
118
  - lib/tipsy/builder.rb
110
- - lib/tipsy/generator.rb
119
+ - lib/tipsy/builders/base.rb
120
+ - lib/tipsy/builders/export.rb
121
+ - lib/tipsy/builders/project.rb
122
+ - lib/tipsy/builders/remote.rb
123
+ - lib/tipsy/compressors/css.rb
124
+ - lib/tipsy/compressors/javascript.rb
111
125
  - lib/tipsy/helpers.rb
126
+ - lib/tipsy/helpers/asset_paths.rb
127
+ - lib/tipsy/helpers/asset_tags.rb
112
128
  - lib/tipsy/helpers/capture.rb
129
+ - lib/tipsy/helpers/sass.rb
113
130
  - lib/tipsy/helpers/tag.rb
114
131
  - lib/tipsy/logger.rb
132
+ - lib/tipsy/project/Gemfile
115
133
  - lib/tipsy/project/assets/javascripts/site.js
116
134
  - lib/tipsy/project/assets/stylesheets/screen.css.scss
117
135
  - lib/tipsy/project/config.erb
118
136
  - lib/tipsy/project/helpers/site_helper.rb
119
137
  - lib/tipsy/project/views/_layout.html.erb
138
+ - lib/tipsy/sass/template.rb
120
139
  - lib/tipsy/server.rb
121
140
  - lib/tipsy/version.rb
122
141
  - lib/tipsy/view.rb
142
+ - test/fixtures/about.html
143
+ - test/fixtures/contact.html
144
+ - test/fixtures/index.html
145
+ - test/functional/page_test.rb
123
146
  - test/root/.gitignore
124
- - test/root/assets/javascripts/test.js
125
- - test/root/assets/stylesheets/screen.css.scss
126
- - test/root/config.rb
127
- - test/root/views/_layout.html.erb
128
- - test/root/views/index.html.erb
147
+ - test/root/development/assets/javascripts/test.js
148
+ - test/root/development/assets/stylesheets/screen.css.scss
149
+ - test/root/development/config.rb
150
+ - test/root/development/views/_layout.html.erb
151
+ - test/root/development/views/index.html.erb
152
+ - test/root/test/assets/javascripts/test.js
153
+ - test/root/test/assets/stylesheets/screen.css.scss
154
+ - test/root/test/config.rb
155
+ - test/root/test/views/_layout.html.erb
156
+ - test/root/test/views/about/index.html
157
+ - test/root/test/views/contact.html
158
+ - test/root/test/views/index.html.erb
159
+ - test/test_helper.rb
160
+ - test/unit/helpers/asset_paths_test.rb
161
+ - test/unit/helpers_test.rb
162
+ - test/unit/server_test.rb
129
163
  - tipsy.gemspec
130
- has_rdoc: true
131
- homepage: ''
164
+ homepage: https://github.com/kurbmedia/tipsy
132
165
  licenses: []
133
166
  post_install_message:
134
167
  rdoc_options: []
@@ -148,14 +181,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
181
  version: '0'
149
182
  requirements: []
150
183
  rubyforge_project: tipsy
151
- rubygems_version: 1.6.2
184
+ rubygems_version: 1.8.7
152
185
  signing_key:
153
186
  specification_version: 3
154
187
  summary: A mini Rack application server for developing static sites.
155
188
  test_files:
189
+ - test/fixtures/about.html
190
+ - test/fixtures/contact.html
191
+ - test/fixtures/index.html
192
+ - test/functional/page_test.rb
156
193
  - test/root/.gitignore
157
- - test/root/assets/javascripts/test.js
158
- - test/root/assets/stylesheets/screen.css.scss
159
- - test/root/config.rb
160
- - test/root/views/_layout.html.erb
161
- - test/root/views/index.html.erb
194
+ - test/root/development/assets/javascripts/test.js
195
+ - test/root/development/assets/stylesheets/screen.css.scss
196
+ - test/root/development/config.rb
197
+ - test/root/development/views/_layout.html.erb
198
+ - test/root/development/views/index.html.erb
199
+ - test/root/test/assets/javascripts/test.js
200
+ - test/root/test/assets/stylesheets/screen.css.scss
201
+ - test/root/test/config.rb
202
+ - test/root/test/views/_layout.html.erb
203
+ - test/root/test/views/about/index.html
204
+ - test/root/test/views/contact.html
205
+ - test/root/test/views/index.html.erb
206
+ - test/test_helper.rb
207
+ - test/unit/helpers/asset_paths_test.rb
208
+ - test/unit/helpers_test.rb
209
+ - test/unit/server_test.rb