merb_helpers 0.9.3 → 0.9.4

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/Rakefile CHANGED
@@ -1,61 +1,72 @@
1
1
  require 'rubygems'
2
2
  require 'rake/gempackagetask'
3
- require 'rake/rdoctask'
4
- require 'spec/rake/spectask'
3
+ require "rake/rdoctask"
4
+ require "extlib"
5
+ require 'merb-core/tasks/merb_rake_helper'
6
+ require "spec/rake/spectask"
5
7
 
6
- PLUGIN = "merb_helpers"
7
- NAME = "merb_helpers"
8
- VERSION = "0.9.3"
9
- AUTHOR = "Yehuda Katz"
10
- EMAIL = "wycats@gmail.com"
11
- HOMEPAGE = "http://merb.rubyforge.org/"
12
- SUMMARY = "Helper support for merb (similar to the Rails form helpers)"
8
+ ##############################################################################
9
+ # Package && release
10
+ ##############################################################################
11
+ RUBY_FORGE_PROJECT = "merb"
12
+ PROJECT_URL = "http://merbivore.com"
13
+ PROJECT_SUMMARY = "Helper support for merb (similar to the Rails form helpers)"
14
+ PROJECT_DESCRIPTION = PROJECT_SUMMARY
13
15
 
14
- windows = (PLATFORM =~ /win32|cygwin/)
16
+ GEM_AUTHOR = "Yehuda Katz"
17
+ GEM_EMAIL = "ykatz@engineyard.com"
15
18
 
16
- SUDO = windows ? "" : "sudo"
19
+ GEM_NAME = "merb_helpers"
20
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
21
+ GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.4") + PKG_BUILD
22
+
23
+ RELEASE_NAME = "REL #{GEM_VERSION}"
24
+
25
+ require "extlib/tasks/release"
17
26
 
18
27
  spec = Gem::Specification.new do |s|
19
- s.name = NAME
20
- s.version = VERSION
28
+ s.rubyforge_project = RUBY_FORGE_PROJECT
29
+ s.name = GEM_NAME
30
+ s.version = GEM_VERSION
21
31
  s.platform = Gem::Platform::RUBY
22
32
  s.has_rdoc = true
23
33
  s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
24
- s.summary = SUMMARY
25
- s.description = s.summary
26
- s.author = AUTHOR
27
- s.email = EMAIL
28
- s.homepage = HOMEPAGE
29
- s.add_dependency("merb-core", ">=0.9.3")
34
+ s.summary = PROJECT_SUMMARY
35
+ s.description = PROJECT_DESCRIPTION
36
+ s.author = GEM_AUTHOR
37
+ s.email = GEM_EMAIL
38
+ s.homepage = PROJECT_URL
39
+ s.add_dependency('merb-core', '>= 0.9.4')
30
40
  s.require_path = 'lib'
31
- s.autorequire = PLUGIN
32
41
  s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
33
42
  end
34
43
 
35
-
36
44
  Rake::GemPackageTask.new(spec) do |pkg|
37
45
  pkg.gem_spec = spec
38
46
  end
39
47
 
40
- desc "Run :package and install resulting .gem"
48
+ ##############################################################################
49
+ # Installation
50
+ ##############################################################################
51
+ desc "Install the gem"
41
52
  task :install => [:package] do
42
- sh %{#{SUDO} gem install pkg/#{NAME}-#{VERSION} --no-rdoc --no-ri --no-update-sources}
53
+ sh %{#{sudo} gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}
43
54
  end
44
55
 
45
- Rake::RDocTask.new do |rdoc|
46
- files = ['README', 'LICENSE',
47
- 'lib/**/*.rb']
48
- rdoc.rdoc_files.add(files)
49
- rdoc.main = 'README'
50
- rdoc.title = 'Merb Helper Docs'
51
- rdoc.rdoc_dir = 'doc/rdoc'
52
- rdoc.options << '--line-numbers' << '--inline-source'
56
+ namespace :jruby do
57
+ desc "Run :package and install the resulting .gem with jruby"
58
+ task :install => :package do
59
+ sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
60
+ end
53
61
  end
54
62
 
55
-
56
- Spec::Rake::SpecTask.new do |t|
57
- t.spec_opts = ["--format", "specdoc", "--colour"]
58
- t.spec_files = Dir['spec/**/*_spec.rb'].sort
63
+ ##############################################################################
64
+ # Specs
65
+ ##############################################################################
66
+ desc "Run all specs"
67
+ Spec::Rake::SpecTask.new("specs") do |t|
68
+ t.spec_opts = ["--format", "specdoc", "--colour"]
69
+ t.spec_files = Dir["spec/**/*_spec.rb"].sort
59
70
  end
60
71
 
61
72
  desc "Run all specs and generate an rcov report"
@@ -67,4 +78,15 @@ Spec::Rake::SpecTask.new('rcov') do |t|
67
78
  t.rcov_opts = ['--exclude', 'gems', '--exclude', 'spec']
68
79
  end
69
80
 
70
-
81
+ ##############################################################################
82
+ # Documentation
83
+ ##############################################################################
84
+ Rake::RDocTask.new do |rdoc|
85
+ files = ['README', 'LICENSE',
86
+ 'lib/**/*.rb']
87
+ rdoc.rdoc_files.add(files)
88
+ rdoc.main = 'README'
89
+ rdoc.title = 'Merb Helper Docs'
90
+ rdoc.rdoc_dir = 'doc/rdoc'
91
+ rdoc.options << '--line-numbers' << '--inline-source'
92
+ end
@@ -0,0 +1,31 @@
1
+ class Date
2
+ include OrdinalizedFormatting
3
+
4
+ # Converts a Date instance to a Time, where the time is set to the beginning of the day.
5
+ # The timezone can be either :local or :utc (default :utc).
6
+ #
7
+ # ==== Examples:
8
+ # date = Date.new(2007, 11, 10)
9
+ # date.to_s # => 2007-11-10
10
+ #
11
+ # date.to_time # => Sat Nov 10 00:00:00 UTC 2007
12
+ # date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007
13
+ # date.to_time(:local) # => Sat Nov 10 00:00:00 -0800 2007
14
+ #
15
+ def to_time(form = :utc)
16
+ ::Time.send("#{form}", year, month, day)
17
+ end
18
+
19
+ def to_date; self; end
20
+ end
21
+
22
+ class Time
23
+ include OrdinalizedFormatting
24
+
25
+ # Ruby 1.8-cvs and 1.9 define private Time#to_date
26
+ %w(to_date to_datetime).each do |method|
27
+ public method if private_instance_methods.include?(method)
28
+ end
29
+
30
+ def to_time; self; end
31
+ end
@@ -1,52 +1,3 @@
1
-
2
- # Everything above here has pretty much been implemented in the assistance gem...
3
-
4
- # Time.now.to_ordinalized_s :long
5
- # => "February 28th, 2006 21:10"
6
- module OrdinalizedFormatting
7
-
8
- def self.extended(obj)
9
- include Merb::Helpers::DateAndTime
10
- end
11
-
12
- def to_ordinalized_s(format = :default)
13
- format = Merb::Helpers::DateAndTime.date_formats[format]
14
- return self.to_s if format.nil?
15
- strftime_ordinalized(format)
16
- end
17
-
18
- def strftime_ordinalized(fmt)
19
- strftime(fmt.gsub(/(^|[^-])%d/, '\1_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
20
- end
21
- end
22
-
23
- class Date
24
- include OrdinalizedFormatting
25
- # Converts a Date instance to a Time, where the time is set to the beginning of the day.
26
- # The timezone can be either :local or :utc (default :utc).
27
- #
28
- # ==== Examples:
29
- # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
30
- #
31
- # date.to_time # => Sat Nov 10 00:00:00 0800 2007
32
- # date.to_time(:local) # => Sat Nov 10 00:00:00 0800 2007
33
- #
34
- # date.to_time(:utc) # => Sat Nov 10 00:00:00 UTC 2007
35
- def to_time(form = :utc)
36
- ::Time.send("#{form}_time", year, month, day)
37
- end
38
- def to_date; self; end
39
- end
40
-
41
- class Time
42
- include OrdinalizedFormatting
43
- # Ruby 1.8-cvs and 1.9 define private Time#to_date
44
- %w(to_date to_datetime).each do |method|
45
- public method if private_instance_methods.include?(method)
46
- end
47
- def to_time; self; end
48
- end
49
-
50
1
  module Merb
51
2
  module Helpers
52
3
  # Provides a number of methods for displaying and dealing with dates and times
@@ -78,11 +29,17 @@ module Merb
78
29
  @@time_class
79
30
  end
80
31
 
81
- def time_output
82
- @@time_output
32
+ # ==== Parameters
33
+ # format<Symbol>:: time format to use
34
+ # locale<String, Symbol>:: An optional value which can be used by localization plugins
35
+ #
36
+ # ==== Returns
37
+ # String:: a string used to format time using #strftime
38
+ def self.time_output(format, locale=nil)
39
+ @@time_output[format]
83
40
  end
84
41
 
85
- def date_formats
42
+ def self.date_formats
86
43
  @@date_formats
87
44
  end
88
45
 
@@ -90,27 +47,28 @@ module Merb
90
47
  #
91
48
  # ==== Parameters
92
49
  # time<~to_date>:: The Date or Time to test
50
+ # locale<String, Symbol>:: An optional value which can be used by localization plugins
93
51
  #
94
52
  # ==== Returns
95
- # String:: The sexy relative date
53
+ # String:: Relative date
96
54
  #
97
55
  # ==== Examples
98
56
  # relative_date(Time.now.utc) => "today"
99
57
  # relative_date(5.days.ago) => "March 5th"
100
58
  # relative_date(1.year.ago) => "March 10th, 2007"
101
- def relative_date(time)
59
+ def relative_date(time, locale=nil)
102
60
  date = time.to_date
103
61
  today = DateAndTime.time_class.now.to_date
104
62
  if date == today
105
- DateAndTime.time_output[:today]
63
+ DateAndTime.time_output(:today, locale)
106
64
  elsif date == (today - 1)
107
- DateAndTime.time_output[:yesterday]
65
+ DateAndTime.time_output(:yesterday, locale)
108
66
  elsif date == (today + 1)
109
- DateAndTime.time_output[:tomorrow]
67
+ DateAndTime.time_output(:tomorrow, locale)
110
68
  else
111
- fmt = DateAndTime.time_output[:initial_format].dup
112
- fmt << DateAndTime.time_output[:year_format] unless date.year == today.year
113
- time.strftime_ordinalized(fmt)
69
+ fmt = DateAndTime.time_output(:initial_format, locale).dup
70
+ fmt << DateAndTime.time_output(:year_format, locale) unless date.year == today.year
71
+ time.strftime_ordinalized(fmt, locale)
114
72
  end
115
73
  end
116
74
 
@@ -188,6 +146,7 @@ module Merb
188
146
  # from_time<~to_time>:: The Date or Time to start from
189
147
  # to_time<~to_time>:: The Date or Time to go to, Defaults to Time.now.utc
190
148
  # include_seconds<Boolean>:: Count the seconds initially, Defaults to false
149
+ # locale<String, Symbol>:: An optional value which can be used by localization plugins
191
150
  #
192
151
  # ==== Returns
193
152
  # String:: The time distance
@@ -199,7 +158,7 @@ module Merb
199
158
  # time_lost_in_words(Time.now) # => less than a minute
200
159
  # time_lost_in_words(Time.now, Time.now, true) # => less than 5 seconds
201
160
  #
202
- def time_lost_in_words(from_time, to_time = Time.now.utc, include_seconds = false)
161
+ def time_lost_in_words(from_time, to_time = Time.now.utc, include_seconds = false, locale=nil)
203
162
  from_time = from_time.to_time if from_time.respond_to?(:to_time)
204
163
  to_time = to_time.to_time if to_time.respond_to?(:to_time)
205
164
  distance_in_minutes = (((to_time - from_time).abs)/60).round
@@ -230,13 +189,14 @@ module Merb
230
189
  end
231
190
  alias :time_ago_in_words :time_lost_in_words
232
191
 
233
- def prettier_time(time, ampm=true)
192
+ def prettier_time(time, ampm=true, locale=nil)
234
193
  time.strftime("%I:%M#{" %p" if ampm}").sub(/^0/, '')
235
194
  end
236
195
  end
237
196
  end
238
197
  end
239
198
 
240
- class Merb::Controller #:nodoc:
199
+ class Merb::Controller
241
200
  include Merb::Helpers::DateAndTime
242
201
  end
202
+
@@ -1,6 +1,6 @@
1
1
  require "#{File.dirname(__FILE__)}/tag_helpers"
2
2
 
3
- module Merb #:nodoc:
3
+ module Merb
4
4
 
5
5
  # Merb helpers include several helpers used for simplifying view creation.
6
6
  # The available helpers currently include form tag helpers for both resource based and generic HTML form tag creation
@@ -46,7 +46,7 @@ module Merb #:nodoc:
46
46
  # Provides a HTML formatted display of resource errors in an unordered list with a h2 form submission error
47
47
  # ==== Options
48
48
  # +build_li+:: Block for generating a list item for an error. It receives an instance of the error.
49
- # +html_class+:: Set for custom error div class default is <tt>submittal_failed<tt>
49
+ # +html_class+:: Set for custom error div class default is <tt>submission_failed<tt>
50
50
  #
51
51
  # ==== Examples
52
52
  # <%= error_messages_for :person %>
@@ -71,7 +71,7 @@ module Merb #:nodoc:
71
71
  yield(obj.errors)
72
72
  else
73
73
  error_plurality = (error_count == 1 ? 'problem' : 'problems')
74
- "<h2>Form submittal failed because of #{error_count} #{error_plurality}</h2>"
74
+ "<h2>Form submission failed because of #{error_count} #{error_plurality}</h2>"
75
75
  end
76
76
 
77
77
  markup = %Q{
@@ -88,7 +88,7 @@ module Merb #:nodoc:
88
88
  }
89
89
  end
90
90
 
91
- def obj_from_ivar_or_sym(obj) #:nodoc:
91
+ def obj_from_ivar_or_sym(obj)
92
92
  obj.is_a?(Symbol) ? instance_variable_get("@#{obj}") : obj
93
93
  end
94
94
 
@@ -164,19 +164,19 @@ module Merb #:nodoc:
164
164
  @_obj, @_block, @_object_name = old_obj, old_block, old_object_name
165
165
  end
166
166
 
167
- def control_name(col) #:nodoc:
167
+ def control_name(col)
168
168
  "#{@_object_name}[#{col}]"
169
169
  end
170
170
 
171
- def control_id(col) #:nodoc:
171
+ def control_id(col)
172
172
  "#{@_object_name}_#{col}"
173
173
  end
174
174
 
175
- def control_value(col) #:nodoc:
175
+ def control_value(col)
176
176
  escape_xml(@_obj.send(col))
177
177
  end
178
178
 
179
- def control_name_value(col, attrs) #:nodoc:
179
+ def control_name_value(col, attrs)
180
180
  {:name => control_name(col), :value => control_value(col)}.merge(attrs)
181
181
  end
182
182
 
@@ -212,7 +212,7 @@ module Merb #:nodoc:
212
212
  def password_control(col, attrs = {})
213
213
  attrs.merge!(:name => control_name(col), :id => control_id(col))
214
214
  errorify_field(attrs, col)
215
- password_field(control_name_value(col, attrs))
215
+ password_field({:name => control_name(col)}.merge(attrs))
216
216
  end
217
217
 
218
218
  # Provides a generic HTML password input tag.
@@ -221,7 +221,6 @@ module Merb #:nodoc:
221
221
  # <%= password_field :name => :password, :label => "Password" %>
222
222
  # # => <label for="password">Password</label><input type="password" name="password" id="password"/>
223
223
  def password_field(attrs = {})
224
- attrs.delete(:value)
225
224
  attrs.merge!(:type => 'password')
226
225
  attrs.add_html_class!("password")
227
226
  optional_label(attrs) { self_closing_tag("input", attrs) }
@@ -229,7 +228,7 @@ module Merb #:nodoc:
229
228
 
230
229
  # translate column values from the db to boolean
231
230
  # nil, false, 0 and '0' are false. All others are true
232
- def col_val_to_bool(val) #:nodoc:
231
+ def col_val_to_bool(val)
233
232
  !(val == "0" || val == 0 || !val)
234
233
  end
235
234
  private :col_val_to_bool
@@ -305,6 +304,20 @@ module Merb #:nodoc:
305
304
  self_closing_tag("input", attrs)
306
305
  end
307
306
 
307
+ # Provides a HTML radio input tag based on a resource attribute.
308
+ #
309
+ # ==== Example
310
+ # <% form_for :person, :action => url(:people) do %>
311
+ # <%= radio_control :first_name %>
312
+ # <% end %>
313
+ def radio_control(col, attrs = {})
314
+ errorify_field(attrs, col)
315
+ attrs.merge!(:id => control_id(col))
316
+ val = @_obj.send(col)
317
+ attrs.merge!(:checked => "checked") if val.to_s == attrs[:value]
318
+ optional_label(attrs) { radio_field(control_name_value(col, attrs)) }
319
+ end
320
+
308
321
  # Provides a radio group based on a resource attribute.
309
322
  # This is generally used within a resource block such as +form_for+.
310
323
  #
@@ -334,8 +347,10 @@ module Merb #:nodoc:
334
347
  # ==== Example
335
348
  # <%= radio_field :name => "radio_options", :value => "1", :label => "One" %>
336
349
  # <%= radio_field :name => "radio_options", :value => "2", :label => "Two" %>
350
+ # <%= radio_field :name => "radio_options", :value => "3", :label => "Three", :checked => true %>
337
351
  def radio_field(attrs = {})
338
352
  attrs.merge!(:type => "radio")
353
+ attrs.delete(:checked) unless attrs[:checked]
339
354
  attrs.add_html_class!("radio")
340
355
  optional_label(attrs){self_closing_tag("input", attrs)}
341
356
  end
@@ -559,6 +574,7 @@ module Merb #:nodoc:
559
574
  # Generates a delete button inside of a form.
560
575
  #
561
576
  # <%= delete_button :news_post, @news_post, 'Remove' %>
577
+ # <%= delete_button('/posts/24/comments/10') %>
562
578
  #
563
579
  # The HTML generated for this would be:
564
580
  #
@@ -566,10 +582,17 @@ module Merb #:nodoc:
566
582
  # <input type="hidden" value="delete" name="_method"/>
567
583
  # <button type="submit">Remove</button>
568
584
  # </form>
569
- def delete_button(symbol, obj = instance_variable_get("@#{symbol}"), contents = 'Delete', form_attrs = {}, button_attrs = {})
585
+ #
586
+ # <form method="post" action="/posts/24/comments/10">
587
+ # <input type="hidden" value="delete" name="_method"/>
588
+ # <button type="submit">Remove</button>
589
+ # </form>
590
+ def delete_button(symbol_or_string, obj = nil, contents = 'Delete', form_attrs = {}, button_attrs = {})
591
+ obj ||= instance_variable_get("@#{symbol_or_string}") if symbol_or_string.kind_of?(Symbol)
592
+
570
593
  button_attrs[:type] = :submit
571
594
 
572
- form_attrs.merge! :action => url(symbol, obj), :method => :delete
595
+ form_attrs.merge! :action => symbol_or_string.kind_of?(Symbol) ? url(symbol_or_string, obj) : symbol_or_string, :method => :delete
573
596
 
574
597
  fake_form_method = set_form_method(form_attrs, obj)
575
598
 
@@ -627,6 +650,6 @@ module Merb #:nodoc:
627
650
  end
628
651
  end
629
652
 
630
- class Merb::Controller #:nodoc:
653
+ class Merb::Controller
631
654
  include Merb::Helpers::Form
632
655
  end
@@ -20,4 +20,35 @@ module Ordinalize
20
20
  end
21
21
  end
22
22
  end
23
- Integer.send :include, Ordinalize
23
+
24
+ Integer.send :include, Ordinalize
25
+
26
+ # Time.now.to_ordinalized_s :long
27
+ # => "February 28th, 2006 21:10"
28
+ module OrdinalizedFormatting
29
+
30
+ def self.extended(obj)
31
+ include Merb::Helpers::DateAndTime
32
+ end
33
+
34
+ def to_ordinalized_s(format = :default)
35
+ format = Merb::Helpers::DateAndTime.date_formats[format]
36
+ return self.to_s if format.nil?
37
+ strftime_ordinalized(format)
38
+ end
39
+
40
+ # Gives you a relative date in an attractive format
41
+ #
42
+ # ==== Parameters
43
+ # format<String>:: strftime string used to formatt a time/date object
44
+ # locale<String, Symbol>:: An optional value which can be used by localization plugins
45
+ #
46
+ # ==== Returns
47
+ # String:: Ordinalized time/date object
48
+ #
49
+ # ==== Examples
50
+ # 5.days.ago.strftime_ordinalized('%b %d, %Y') # =>
51
+ def strftime_ordinalized(fmt, format=nil)
52
+ strftime(fmt.gsub(/(^|[^-])%d/, '\1_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
53
+ end
54
+ end
@@ -26,7 +26,7 @@ module Merb
26
26
  # # <div class="class">content</div>
27
27
  #
28
28
  def tag(name, contents = nil, attrs = {}, &block)
29
- attrs = contents if contents.is_a?(Hash)
29
+ attrs, contents = contents, nil if contents.is_a?(Hash)
30
30
  contents = capture(&block) if block_given?
31
31
  open_tag(name, attrs) + contents.to_s + close_tag(name)
32
32
  end
@@ -56,6 +56,6 @@ module Merb
56
56
  end
57
57
  end
58
58
 
59
- class Merb::Controller #:nodoc:
59
+ class Merb::Controller
60
60
  include Merb::Helpers::Tag
61
61
  end
@@ -55,4 +55,5 @@ module TimeDSL
55
55
  end
56
56
  alias :from_now :since
57
57
  end
58
+
58
59
  Numeric.send :include, TimeDSL
data/lib/merb_helpers.rb CHANGED
@@ -1,42 +1,39 @@
1
1
  module Merb
2
2
 
3
3
  module Helpers
4
- HELPERS_DIR = File.dirname(__FILE__) / 'merb_helpers'
5
- HELPERS_FILES = Dir["#{HELPERS_DIR}/*_helpers.rb"].collect {|h| h.match(/\/(\w+)\.rb/)[1]}
6
-
7
- def self.load_helpers(helpers = HELPERS_FILES)
8
- helpers.each {|h| Kernel.load(File.join(HELPERS_DIR, "#{h}.rb") )} # using load here allows specs to work
9
- end
4
+
5
+ @@helpers_dir = File.dirname(__FILE__) / 'merb_helpers'
6
+ @@helpers_files = Dir["#{@@helpers_dir}/*_helpers.rb"].collect {|h| h.match(/\/(\w+)\.rb/)[1]}
10
7
 
11
8
  def self.load
12
- require HELPERS_DIR + '/time_dsl'
13
- require HELPERS_DIR + '/ordinalize'
14
- # TODO remove with and without and only allow 2 options:
15
- # config[:load]
16
- # if defined then load the modules passed along
17
- # otherwise load everything
9
+ require @@helpers_dir + '/time_dsl'
10
+ require @@helpers_dir + '/ordinalize'
11
+ require @@helpers_dir + '/core_ext'
18
12
 
19
13
  if Merb::Plugins.config[:merb_helpers]
20
14
  config = Merb::Plugins.config[:merb_helpers]
21
- raise "With and Without options cannot be used with merb_helpers plugin configuration" if config[:with] && config[:without]
22
- if config[:include]
15
+ raise "With and Without options have been deprecated" if config[:with] || config[:without]
16
+
17
+ if config[:include] && !config[:include].empty?
23
18
  load_helpers(config[:include])
24
- elsif config[:exclude]
25
- load_helpers(HELPERS_FILES.reject {|h| config[:exclude].include? h})
26
19
  else
27
20
  # This is in case someone defines an entry in the config,
28
21
  # but doesn't put in a with or without option
29
22
  load_helpers
30
23
  end
24
+
31
25
  else
32
26
  load_helpers
33
27
  end
34
28
  end
35
29
 
30
+ # Load only specific helpers instead of loading all the helpers
31
+ def self.load_helpers(helpers = @@helpers_files)
32
+ helpers.each {|helper| Kernel.load(File.join(@@helpers_dir, "#{helper}.rb") )} # using load here allows specs to work
33
+ end
34
+
36
35
  end
37
36
 
38
37
  end
39
38
 
40
- Merb::BootLoader.before_app_loads do
41
- Merb::Helpers.load
42
- end
39
+ Merb::Helpers.load
metadata CHANGED
@@ -1,28 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
8
- autorequire: merb_helpers
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-04 00:00:00 -05:00
12
+ date: 2008-08-03 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: merb-core
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
20
21
  - - ">="
21
22
  - !ruby/object:Gem::Version
22
- version: 0.9.3
23
+ version: 0.9.4
23
24
  version:
24
25
  description: Helper support for merb (similar to the Rails form helpers)
25
- email: wycats@gmail.com
26
+ email: ykatz@engineyard.com
26
27
  executables: []
27
28
 
28
29
  extensions: []
@@ -37,6 +38,7 @@ files:
37
38
  - Rakefile
38
39
  - TODO
39
40
  - lib/merb_helpers
41
+ - lib/merb_helpers/core_ext.rb
40
42
  - lib/merb_helpers/date_time_helpers.rb
41
43
  - lib/merb_helpers/form_helpers.rb
42
44
  - lib/merb_helpers/ordinalize.rb
@@ -44,7 +46,7 @@ files:
44
46
  - lib/merb_helpers/time_dsl.rb
45
47
  - lib/merb_helpers.rb
46
48
  has_rdoc: true
47
- homepage: http://merb.rubyforge.org/
49
+ homepage: http://merbivore.com
48
50
  post_install_message:
49
51
  rdoc_options: []
50
52
 
@@ -64,8 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
66
  version:
65
67
  requirements: []
66
68
 
67
- rubyforge_project:
68
- rubygems_version: 1.0.1
69
+ rubyforge_project: merb
70
+ rubygems_version: 1.2.0
69
71
  signing_key:
70
72
  specification_version: 2
71
73
  summary: Helper support for merb (similar to the Rails form helpers)