tiny 0.2.0 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +77 -11
  2. data/lib/tiny.rb +1 -2
  3. data/lib/tiny/version.rb +1 -1
  4. data/tiny.gemspec +9 -8
  5. metadata +44 -28
data/README.md CHANGED
@@ -120,18 +120,43 @@ Tiny ActionView helpers are allready included in ActionView, no further
120
120
  step is required for using Tiny in Rails view helpers, just use `html_tag`
121
121
  instead of `tag` because ActionView allready defines `tag`.
122
122
 
123
- The advantage over Rails' markup method such as `tag` and `content\_tag` is
123
+ You will be able to call `html_tag`, `with_buffer`, `text`, `append!`,
124
+ and the rest of Tiny's markup generation methods from your view helper
125
+ modules.
126
+
127
+ The advantage over Rails' markup method such as `tag` and `content_tag` is
124
128
  that generated strings need not to be explicitly concatenated.
125
129
 
126
130
  In addition to defining view helpers to be used from templates, a
127
131
  `Widget` can substitute a template view with the benefit of inheritance.
132
+
128
133
  No template handler es provided but is not cumbersome explicitly
129
134
  rendering the Widget.
135
+ There is no enforcement on where widgets are placed but a logical
136
+ place would be under `"#{Rails.root}/app/widgets"` and autoloading the
137
+ directory in environment.rb
138
+
139
+ $ mkdir app/widgets
140
+ # config/application.rb
141
+ ...
142
+ module MyRailsApp
143
+ class Application < Rails::Application
144
+ ...
145
+ config.autoload_paths += %W(#{config.root}/widgets)
146
+ ...
147
+ end
148
+ end
130
149
 
131
- controller Products
150
+ # app/widgets/product_list.rb
151
+ class ProductList < Tiny::Widget
152
+ ...
153
+ end
154
+
155
+ # app/controllers/products_controller.rb
156
+ controller Products < ApplicationController
132
157
  def index
133
158
  products = Product.all
134
- render :text => MyProductList.new(products).to_html
159
+ render :text => ProductList.new(products).to_html
135
160
  end
136
161
  ...
137
162
  end
@@ -189,15 +214,15 @@ must be exercised because its quite a few methods.
189
214
 
190
215
  def navigation
191
216
  nav(:id) do
192
- tag(:ul) do
193
- tag(:li) do
194
- tag :a, 'Home', :class => 'home', :href => '/'
217
+ ul do
218
+ li do
219
+ a('Home', :class => 'home', :href => '/')
195
220
  end
196
- tag(:li) do
197
- tag :a, 'About', :class => 'about', :href => '/about'
221
+ li do
222
+ a('About', :class => 'about', :href => '/about')
198
223
  end
199
- tag(:li) do
200
- tag :a, 'Home', :class => 'products', :href => '/products'
224
+ li do
225
+ a('Home', :class => 'products', :href => '/products')
201
226
  end
202
227
  end
203
228
  end
@@ -361,8 +386,49 @@ Whether this is or isn't a good idea is up to you.
361
386
  </dl>
362
387
  </div>
363
388
 
389
+ ## No code is better than no code
390
+
391
+ LOC count.
392
+
393
+ Erector
394
+
395
+ $ cloc erector/lib
396
+ http://cloc.sourceforge.net v 1.56 T=0.5 s (102.0 files/s, 43438.0 lines/s)
397
+ -------------------------------------------------------------------------------
398
+ Language files blank comment code
399
+ -------------------------------------------------------------------------------
400
+ Ruby 51 433 786 20500
401
+ -------------------------------------------------------------------------------
402
+ SUM: 51 433 786 20500
403
+ -------------------------------------------------------------------------------
404
+
405
+ Markaby
406
+
407
+ $ cloc markaby/lib
408
+ http://cloc.sourceforge.net v 1.56 T=0.5 s (24.0 files/s, 2142.0 lines/s)
409
+ -------------------------------------------------------------------------------
410
+ Language files blank comment code
411
+ -------------------------------------------------------------------------------
412
+ Ruby 12 133 177 761
413
+ -------------------------------------------------------------------------------
414
+ SUM: 12 133 177 761
415
+ -------------------------------------------------------------------------------
416
+
417
+
418
+ Tiny
419
+
420
+ $ cloc tiny/lib
421
+ http://cloc.sourceforge.net v 1.56 T=0.5 s (12.0 files/s, 1650.0 lines/s)
422
+ -------------------------------------------------------------------------------
423
+ Language files blank comment code
424
+ -------------------------------------------------------------------------------
425
+ Ruby 6 71 399 355
426
+ -------------------------------------------------------------------------------
427
+ SUM: 6 71 399 355
428
+ -------------------------------------------------------------------------------
429
+
364
430
 
365
- == LICENSE:
431
+ ## LICENSE:
366
432
 
367
433
  (The MIT License)
368
434
 
data/lib/tiny.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'erubis'
2
- require 'haml'
3
2
  require 'tilt'
4
3
  require 'escape_utils'
5
4
 
@@ -278,7 +277,7 @@ module Tiny
278
277
  # @return [String] HTML markup.
279
278
  #
280
279
  def with_buffer *args, &block
281
- ::Haml::Helpers.block_is_haml?(block) ? capture_haml(*args, &block) : super
280
+ defined?(Haml) && Haml::Helpers.block_is_haml?(block) ? capture_haml(*args, &block) : super
282
281
  end
283
282
  end
284
283
 
data/lib/tiny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tiny
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.4"
3
3
  end
data/tiny.gemspec CHANGED
@@ -19,13 +19,14 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_runtime_dependency 'tilt', '~> 1.3'
22
- s.add_runtime_dependency 'escape_utils'
22
+ s.add_runtime_dependency 'erubis', '~> 2.7'
23
+ s.add_runtime_dependency 'escape_utils' # simple api
23
24
 
24
- s.add_development_dependency 'rspec'
25
- s.add_development_dependency 'capybara'
26
- s.add_development_dependency 'erubis'
27
- s.add_development_dependency 'haml'
28
- s.add_development_dependency 'tilt'
29
- s.add_development_dependency 'sinatra'
30
- s.add_development_dependency 'rails'
25
+ s.add_development_dependency 'rspec', '~> 2.11'
26
+ s.add_development_dependency 'nokogiri', '1.5.2'
27
+ s.add_development_dependency 'capybara', '~> 1.1'
28
+ s.add_development_dependency 'haml', '~> 3.1'
29
+ s.add_development_dependency 'tilt', '~> 1.3'
30
+ s.add_development_dependency 'sinatra' # I trust Sinatra
31
+ s.add_development_dependency 'rails', '~> 3.2'
31
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-14 00:00:00.000000000 Z
12
+ date: 2012-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tilt
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: erubis
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.7'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.7'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: escape_utils
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -48,81 +64,81 @@ dependencies:
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
51
- - - ! '>='
67
+ - - ~>
52
68
  - !ruby/object:Gem::Version
53
- version: '0'
69
+ version: '2.11'
54
70
  type: :development
55
71
  prerelease: false
56
72
  version_requirements: !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
- - - ! '>='
75
+ - - ~>
60
76
  - !ruby/object:Gem::Version
61
- version: '0'
77
+ version: '2.11'
62
78
  - !ruby/object:Gem::Dependency
63
- name: capybara
79
+ name: nokogiri
64
80
  requirement: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
67
- - - ! '>='
83
+ - - '='
68
84
  - !ruby/object:Gem::Version
69
- version: '0'
85
+ version: 1.5.2
70
86
  type: :development
71
87
  prerelease: false
72
88
  version_requirements: !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
- - - ! '>='
91
+ - - '='
76
92
  - !ruby/object:Gem::Version
77
- version: '0'
93
+ version: 1.5.2
78
94
  - !ruby/object:Gem::Dependency
79
- name: erubis
95
+ name: capybara
80
96
  requirement: !ruby/object:Gem::Requirement
81
97
  none: false
82
98
  requirements:
83
- - - ! '>='
99
+ - - ~>
84
100
  - !ruby/object:Gem::Version
85
- version: '0'
101
+ version: '1.1'
86
102
  type: :development
87
103
  prerelease: false
88
104
  version_requirements: !ruby/object:Gem::Requirement
89
105
  none: false
90
106
  requirements:
91
- - - ! '>='
107
+ - - ~>
92
108
  - !ruby/object:Gem::Version
93
- version: '0'
109
+ version: '1.1'
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: haml
96
112
  requirement: !ruby/object:Gem::Requirement
97
113
  none: false
98
114
  requirements:
99
- - - ! '>='
115
+ - - ~>
100
116
  - !ruby/object:Gem::Version
101
- version: '0'
117
+ version: '3.1'
102
118
  type: :development
103
119
  prerelease: false
104
120
  version_requirements: !ruby/object:Gem::Requirement
105
121
  none: false
106
122
  requirements:
107
- - - ! '>='
123
+ - - ~>
108
124
  - !ruby/object:Gem::Version
109
- version: '0'
125
+ version: '3.1'
110
126
  - !ruby/object:Gem::Dependency
111
127
  name: tilt
112
128
  requirement: !ruby/object:Gem::Requirement
113
129
  none: false
114
130
  requirements:
115
- - - ! '>='
131
+ - - ~>
116
132
  - !ruby/object:Gem::Version
117
- version: '0'
133
+ version: '1.3'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
121
137
  none: false
122
138
  requirements:
123
- - - ! '>='
139
+ - - ~>
124
140
  - !ruby/object:Gem::Version
125
- version: '0'
141
+ version: '1.3'
126
142
  - !ruby/object:Gem::Dependency
127
143
  name: sinatra
128
144
  requirement: !ruby/object:Gem::Requirement
@@ -144,17 +160,17 @@ dependencies:
144
160
  requirement: !ruby/object:Gem::Requirement
145
161
  none: false
146
162
  requirements:
147
- - - ! '>='
163
+ - - ~>
148
164
  - !ruby/object:Gem::Version
149
- version: '0'
165
+ version: '3.2'
150
166
  type: :development
151
167
  prerelease: false
152
168
  version_requirements: !ruby/object:Gem::Requirement
153
169
  none: false
154
170
  requirements:
155
- - - ! '>='
171
+ - - ~>
156
172
  - !ruby/object:Gem::Version
157
- version: '0'
173
+ version: '3.2'
158
174
  description: Tiny is a tiny framework agnostic markup builder, useful for building
159
175
  view helpers on inclusion only adds three public methods, tag (for generating html
160
176
  tags), capture and concat, works as pure ruby and with erb and haml