carmen-rails 1.0.0 → 1.0.1

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60e0203dc4406464bdc96cb694b3105a01550a0c
4
+ data.tar.gz: 95ab17dade0f5108f8af0ca057680fa94a32e9a2
5
+ SHA512:
6
+ metadata.gz: bbab683e09c64fae6072bc309ab380c347d8da0d1af11255d222b91db3306fdb202bfa44ab8d788dd828af4f83f242716b2d8ab4a3f15e923827d99836d9206d
7
+ data.tar.gz: 9e3e3669fbfd86d85c0c51f6e87852971523c883a865107fa5633c723335299367d98f7d5320e0218d5c205afaeb93b21351a576b5f32068849f34c25e41a81a
data/README.md CHANGED
@@ -4,25 +4,41 @@ carmen-rails is a Rails 3 plugin that supplies two new form helper methods:
4
4
  `country_select` and `subregion_select`. It uses
5
5
  [carmen](http://github.com/jim/carmen) as its source of geographic data.
6
6
 
7
+ ## Requirements
8
+
9
+ carmen-rails requires Ruby 1.9.2 or greater.
10
+
7
11
  ## Installation
8
12
 
9
13
  Just add carmen-rails to your Gemfile:
10
14
 
11
15
  ```ruby
12
- gem 'carmen-rails', '~> 1.0.0.beta3'
16
+ gem 'carmen-rails', '~> 1.0.0'
13
17
  ```
14
-
15
18
  ## Usage
16
19
 
17
20
  ```erb
18
21
  <%= form_for(@order) do |f| %>
19
22
  <div class="field">
20
23
  <%= f.label :country_code %><br />
21
- <%= f.country_select :country_code, {priority: %w(US CA)}, prompt: 'Please select a country' %>
24
+ <%= f.country_select :country_code, {priority: %w(US CA), prompt: 'Please select a country'} %>
22
25
  </div>
23
26
  <% end %>
24
27
  ```
25
28
 
29
+ #### SimpleForm
30
+ Pass the object to the country_select helper. This ensures the persisted country is selected when the form is rendered.
31
+
32
+ ```erb
33
+ <%= simple_form_for @user do |f| %>
34
+ <%= f.input :country_code do %>
35
+ <%= f.country_select :country_code, {object: f.object, prompt: 'Country'} %>
36
+ <% end %>
37
+ <% end %>
38
+ ```
39
+
40
+ Passing the object is necessary when using nested form fields with Formtastic.
41
+
26
42
  ## How do I only display a subset of countries/regions?
27
43
 
28
44
  Carmen had a concept of excluded countries in the old days, where you could
@@ -59,4 +75,4 @@ should be done inside `config/application.rb`:
59
75
 
60
76
  ``` ruby
61
77
  config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
62
- ```
78
+ ```
data/Rakefile CHANGED
@@ -1,19 +1,18 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
-
8
- Bundler::GemHelper.install_tasks
1
+ require "rubygems"
2
+ require 'bundler/setup'
9
3
 
4
+ require 'rake'
10
5
  require 'rake/testtask'
6
+ require 'rdoc/task'
7
+
8
+ Bundler::GemHelper.install_tasks
11
9
 
12
- Rake::TestTask.new(:spec) do |t|
10
+ Rake::TestTask.new(:test) do |t|
13
11
  t.libs << 'lib'
14
- t.libs << 'spec'
15
- t.pattern = 'spec/**/*_spec.rb'
16
- t.verbose = false
12
+ t.libs << 'test'
13
+ t.pattern = 'test/**/*_test.rb'
14
+ t.verbose = true
17
15
  end
18
16
 
19
- task :default => :spec
17
+ desc 'Default: run unit tests.'
18
+ task :default => :test
@@ -15,7 +15,7 @@ module ActionView
15
15
  # html_options - Options to use when generating the select tag- class,
16
16
  # id, etc.
17
17
  #
18
- # Uses region_options_or_select to generate the list of option tags.
18
+ # Uses region_options_for_select to generate the list of option tags.
19
19
  #
20
20
  # Example:
21
21
  #
@@ -24,7 +24,7 @@ module ActionView
24
24
  # Returns an `html_safe` string containing the HTML for a select element.
25
25
  def subregion_select(object, method, parent_region_or_code, options={}, html_options={})
26
26
  parent_region = determine_parent(parent_region_or_code)
27
- tag = InstanceTag.new(object, method, self, options.delete(:object))
27
+ tag = instance_tag(object, method, self, options)
28
28
  tag.to_region_select_tag(parent_region, options, html_options)
29
29
  end
30
30
 
@@ -51,18 +51,16 @@ module ActionView
51
51
  # country_select(@object, :region, ['US', 'CA'], class: region)
52
52
  #
53
53
  # Returns an `html_safe` string containing the HTML for a select element.
54
- def country_select(object, method, *args)
55
-
56
- # These contortions are to provide API-compatibility
57
- priority_countries = args.shift if args.first.is_a?(Array)
58
- options, html_options = args
59
-
60
- options ||= {}
61
- options[:priority] = priority_countries if priority_countries
62
-
63
- html_options ||= {}
54
+ def country_select(object, method, priorities_or_options = {}, options_or_html_options = {}, html_options = {})
55
+ if priorities_or_options.is_a? Array
56
+ options = options_or_html_options
57
+ options[:priority] = priorities_or_options
58
+ else
59
+ options = priorities_or_options
60
+ html_options = options_or_html_options
61
+ end
64
62
 
65
- tag = InstanceTag.new(object, method, self)
63
+ tag = instance_tag(object, method, self, options)
66
64
  tag.to_region_select_tag(Carmen::World.instance, options, html_options)
67
65
  end
68
66
 
@@ -96,6 +94,11 @@ module ActionView
96
94
  unless priority_regions.empty?
97
95
  region_options += options_for_select(priority_regions, selected)
98
96
  region_options += "<option disabled>-------------</option>"
97
+
98
+ # If a priority region is selected, don't select it again in the main list.
99
+ # This prevents some browsers from selecting the second occurance of this region,
100
+ # which makes it difficult to select an alternative priority region.
101
+ selected = nil if priority_region_codes.include?(selected)
99
102
  end
100
103
  end
101
104
 
@@ -158,6 +161,15 @@ module ActionView
158
161
 
159
162
  private
160
163
 
164
+ def instance_tag(object_name, method_name, template_object, options = {})
165
+ if Rails::VERSION::MAJOR == 3
166
+ InstanceTag.new(object_name, method_name, template_object, options.delete(:object))
167
+ else
168
+ ActionView::Helpers::Tags::Base.new(object_name, method_name, template_object, options || {})
169
+ end
170
+ end
171
+
172
+
161
173
  def determine_parent(parent_region_or_code)
162
174
  case parent_region_or_code
163
175
  when String
@@ -172,14 +184,41 @@ module ActionView
172
184
  end
173
185
  end
174
186
 
175
- class InstanceTag
176
- def to_region_select_tag(parent_region, options = {}, html_options = {})
177
- html_options = html_options.stringify_keys
178
- add_default_name_and_id(html_options)
179
- priority_regions = options[:priority] || []
180
- value = value(object)
181
- opts = add_options(region_options_for_select(parent_region.subregions, value, :priority => priority_regions), options, value)
182
- content_tag("select", opts, html_options)
187
+ if Rails::VERSION::MAJOR == 3
188
+ class InstanceTag
189
+ def to_region_select_tag(parent_region, options = {}, html_options = {})
190
+ html_options = html_options.stringify_keys
191
+ add_default_name_and_id(html_options)
192
+ priority_regions = options[:priority] || []
193
+ value = options[:selected] ? options[:selected] : value(object)
194
+ opts = add_options(region_options_for_select(parent_region.subregions, value, :priority => priority_regions), options, value)
195
+ content_tag("select", opts, html_options)
196
+ end
197
+ end
198
+ end
199
+
200
+ if Rails::VERSION::MAJOR == 4
201
+ module Tags
202
+ class Base
203
+ def to_region_select_tag(parent_region, options = {}, html_options = {})
204
+ html_options = html_options.stringify_keys
205
+ add_default_name_and_id(html_options)
206
+ options[:include_blank] ||= true unless options[:prompt] || select_not_required?(html_options)
207
+
208
+ value = options[:selected] ? options[:selected] : value(object)
209
+ priority_regions = options[:priority] || []
210
+ opts = add_options(region_options_for_select(parent_region.subregions, value,
211
+ :priority => priority_regions),
212
+ options, value)
213
+ select = content_tag("select", opts, html_options)
214
+ if html_options["multiple"] && options.fetch(:include_hidden, true)
215
+ tag("input", :disabled => html_options["disabled"], :name => html_options["name"],
216
+ :type => "hidden", :value => "") + select
217
+ else
218
+ select
219
+ end
220
+ end
221
+ end
183
222
  end
184
223
  end
185
224
 
@@ -189,8 +228,16 @@ module ActionView
189
228
  # web form.
190
229
  #
191
230
  # See `FormOptionsHelper::country_select` for more information.
192
- def country_select(method, *args)
193
- @template.country_select(@object_name, method, *args)
231
+ def country_select(method, priorities_or_options = {}, options_or_html_options = {}, html_options = {})
232
+ if priorities_or_options.is_a? Array
233
+ options = options_or_html_options
234
+ options[:priority] = priorities_or_options
235
+ else
236
+ options = priorities_or_options
237
+ html_options = options_or_html_options
238
+ end
239
+
240
+ @template.country_select(@object_name, method, objectify_options(options), @default_options.merge(html_options))
194
241
  end
195
242
 
196
243
  # Generate select and subregion option tags with the provided name. A
@@ -198,8 +245,8 @@ module ActionView
198
245
  # a given country.
199
246
  #
200
247
  # See `FormOptionsHelper::subregion_select` for more information.
201
- def subregion_select(method, parent_region_or_code, *args)
202
- @template.subregion_select(@object_name, method, parent_region_or_code, *args)
248
+ def subregion_select(method, parent_region_or_code, options = {}, html_options = {})
249
+ @template.subregion_select(@object_name, method, parent_region_or_code, objectify_options(options), @default_options.merge(html_options))
203
250
  end
204
251
  end
205
252
 
@@ -1,5 +1,5 @@
1
1
  module Carmen
2
2
  module Rails
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,49 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carmen-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jim Benton
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-20 00:00:00.000000000Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
- requirement: &2160706040 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2160706040
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: carmen
27
- requirement: &2160704840 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: 1.0.0.beta2
33
+ version: 1.0.0
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *2160704840
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: minitest
38
- requirement: &2160677320 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - ">="
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *2160677320
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  description: Provides country_select and subregion_select form helpers.
48
56
  email:
49
57
  - jim@autonomousmachine.com
@@ -51,39 +59,34 @@ executables: []
51
59
  extensions: []
52
60
  extra_rdoc_files: []
53
61
  files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - lib/carmen-rails.rb
54
66
  - lib/carmen/rails/action_view/form_helper.rb
55
67
  - lib/carmen/rails/version.rb
56
- - lib/carmen-rails.rb
57
68
  - lib/tasks/carmen-rails_tasks.rake
58
- - MIT-LICENSE
59
- - Rakefile
60
- - README.md
61
- - spec/carmen/action_view/helpers/form_helper_spec.rb
62
- - spec/spec_helper.rb
63
69
  homepage: http://github.com/jim/carmen-rails
64
70
  licenses: []
71
+ metadata: {}
65
72
  post_install_message:
66
73
  rdoc_options: []
67
74
  require_paths:
68
75
  - lib
69
76
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
77
  requirements:
72
- - - ! '>='
78
+ - - ">="
73
79
  - !ruby/object:Gem::Version
74
80
  version: '0'
75
81
  required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
82
  requirements:
78
- - - ! '>='
83
+ - - ">="
79
84
  - !ruby/object:Gem::Version
80
85
  version: '0'
81
86
  requirements: []
82
87
  rubyforge_project:
83
- rubygems_version: 1.8.15
88
+ rubygems_version: 2.2.0
84
89
  signing_key:
85
- specification_version: 3
90
+ specification_version: 4
86
91
  summary: Rails adapter for Carmen
87
- test_files:
88
- - spec/carmen/action_view/helpers/form_helper_spec.rb
89
- - spec/spec_helper.rb
92
+ test_files: []
@@ -1,241 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class CarmenViewHelperTest < MiniTest::Unit::TestCase
4
- include ActionView::Helpers::FormOptionsHelper
5
- include ActionView::Helpers::FormTagHelper
6
- include ActionDispatch::Assertions::SelectorAssertions
7
-
8
- def setup
9
- @object = OpenStruct.new
10
- def @object.to_s; 'object'; end
11
- end
12
-
13
- def response_from_page
14
- HTML::Document.new(@html).root
15
- end
16
-
17
- def test_basic_country_select
18
- html = country_select(@object, :country_code)
19
- expected = <<-HTML
20
- <select id="object_country_code" name="object[country_code]">
21
- <option value="ES">Eastasia</option>
22
- <option value="EU">Eurasia</option>
23
- <option value="OC">Oceania</option>
24
- </select>
25
- HTML
26
-
27
- assert_equal_markup(expected, html)
28
- end
29
-
30
- def test_country_selected_value
31
- @object.country_code = 'OC'
32
- @html = country_select(@object, :country_code)
33
- assert_select('option[selected="selected"][value="OC"]')
34
- end
35
-
36
- def test_basic_country_select_tag
37
- html = country_select_tag('attribute_name', nil)
38
- expected = <<-HTML
39
- <select id="attribute_name" name="attribute_name">
40
- <option value="ES">Eastasia</option>
41
- <option value="EU">Eurasia</option>
42
- <option value="OC">Oceania</option>
43
- </select>
44
- HTML
45
-
46
- assert_equal_markup(expected, html)
47
- end
48
-
49
- def test_country_select_tag_with_prompt
50
- html = country_select_tag('attribute_name', nil, :prompt => 'Please Select')
51
- expected = <<-HTML
52
- <select id="attribute_name" name="attribute_name">
53
- <option value="">Please Select</option>
54
- <option value="ES">Eastasia</option>
55
- <option value="EU">Eurasia</option>
56
- <option value="OC">Oceania</option>
57
- </select>
58
- HTML
59
-
60
- assert_equal_markup(expected, html)
61
- end
62
- def test_country_tag_selected_value
63
- @html = country_select_tag(:country_code, 'OC')
64
- assert_select('option[selected="selected"][value="OC"]')
65
- end
66
-
67
- def test_priority_country_select
68
- html = country_select(@object, :country_code, :priority => ['ES'])
69
- expected = <<-HTML
70
- <select id="object_country_code" name="object[country_code]">
71
- <option value="ES">Eastasia</option>
72
- <option disabled>-------------</option>
73
- <option value="ES">Eastasia</option>
74
- <option value="EU">Eurasia</option>
75
- <option value="OC">Oceania</option>
76
- </select>
77
- HTML
78
-
79
- assert_equal_markup(expected, html)
80
- end
81
-
82
- def test_priority_country_select_deprecated_api
83
- html = country_select(@object, :country_code, ['ES'], {})
84
- expected = <<-HTML
85
- <select id="object_country_code" name="object[country_code]">
86
- <option value="ES">Eastasia</option>
87
- <option disabled>-------------</option>
88
- <option value="ES">Eastasia</option>
89
- <option value="EU">Eurasia</option>
90
- <option value="OC">Oceania</option>
91
- </select>
92
- HTML
93
-
94
- assert_equal_markup(expected, html)
95
- end
96
-
97
- def test_basic_subregion_select
98
- oceania = Carmen::Country.coded('OC')
99
- expected = <<-HTML
100
- <select id="object_subregion_code" name="object[subregion_code]">
101
- <option value="AO">Airstrip One</option>
102
- </select>
103
- HTML
104
-
105
- html = subregion_select(@object, :subregion_code, oceania)
106
-
107
- assert_equal_markup(expected, html)
108
- end
109
-
110
- def test_subregion_select_using_parent_code
111
- expected = <<-HTML
112
- <select id="object_subregion_code" name="object[subregion_code]">
113
- <option value="AO">Airstrip One</option>
114
- </select>
115
- HTML
116
-
117
- html = subregion_select(@object, :subregion_code, 'OC')
118
-
119
- assert_equal_markup(expected, html)
120
- end
121
-
122
- def test_subregion_select_using_parent_code_array
123
- expected = <<-HTML
124
- <select id="object_subregion_code" name="object[subregion_code]">
125
- <option value="LO">London</option>
126
- </select>
127
- HTML
128
-
129
- html = subregion_select(@object, :subregion_code, ['OC', 'AO'])
130
-
131
- assert_equal_markup(expected, html)
132
- end
133
-
134
- def test_subregion_selected_value
135
- @object.subregion_code = 'AO'
136
- oceania = Carmen::Country.coded('OC')
137
-
138
- @html = subregion_select(@object, :subregion_code, oceania)
139
-
140
- assert_select('option[selected="selected"][value="AO"]')
141
- end
142
-
143
- def test_basic_subregion_select_tag
144
- oceania = Carmen::Country.coded('OC')
145
- expected = <<-HTML
146
- <select id="subregion_code" name="subregion_code">
147
- <option value="AO">Airstrip One</option>
148
- </select>
149
- HTML
150
-
151
- html = subregion_select_tag(:subregion_code, nil, oceania)
152
-
153
- assert_equal_markup(expected, html)
154
- end
155
-
156
- def test_subregion_select_tag_with_priority
157
- oceania = Carmen::Country.coded('OC')
158
- expected = <<-HTML
159
- <select id="subregion_code" name="subregion_code">
160
- <option value="AO">Airstrip One</option>
161
- <option disabled>-------------</option>
162
- <option value="AO">Airstrip One</option>
163
- </select>
164
- HTML
165
-
166
- html = subregion_select_tag(:subregion_code, nil, oceania, :priority => ['AO'])
167
-
168
- assert_equal_markup(expected, html)
169
- end
170
-
171
- def test_subregion_select_tag_with_prompt
172
- oceania = Carmen::Country.coded('OC')
173
- expected = <<-HTML
174
- <select id="subregion_code" name="subregion_code">
175
- <option value="">Please select</option>
176
- <option value="AO">Airstrip One</option>
177
- </select>
178
- HTML
179
-
180
- html = subregion_select_tag(:subregion_code, nil, oceania, :prompt => 'Please select')
181
-
182
- assert_equal_markup(expected, html)
183
- end
184
-
185
- def test_region_options_for_select
186
- regions = Carmen::Country.all
187
- expected = <<-HTML
188
- <option value="ES">Eastasia</option>
189
- <option value="EU">Eurasia</option>
190
- <option value="OC" selected="selected">Oceania</option>
191
- HTML
192
- html = region_options_for_select(regions, 'OC')
193
-
194
- assert_equal_markup(expected, html)
195
- end
196
-
197
- def test_region_options_for_select_with_array_of_regions_and_priority
198
- regions = [Carmen::Country.coded('ES'), Carmen::Country.coded('EU')]
199
- expected = <<-HTML
200
- <option value="ES">Eastasia</option>
201
- <option disabled>-------------</option>
202
- <option value="ES">Eastasia</option>
203
- <option value="EU">Eurasia</option>
204
- HTML
205
- html = region_options_for_select(regions, nil, :priority => ['ES'])
206
-
207
- assert_equal_markup(expected, html)
208
- end
209
-
210
- def test_form_builder_country_select
211
- form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {}, lambda{})
212
-
213
- html = form.country_select('attribute_name')
214
- expected = <<-HTML
215
- <select id="object_attribute_name" name="object[attribute_name]">
216
- <option value="ES">Eastasia</option>
217
- <option value="EU">Eurasia</option>
218
- <option value="OC">Oceania</option>
219
- </select>
220
- HTML
221
-
222
- assert_equal_markup(expected, html)
223
- end
224
-
225
- def test_form_builder_country_select_deprecated_api
226
- form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {}, lambda{})
227
-
228
- html = form.country_select('attribute_name', ['ES'])
229
- expected = <<-HTML
230
- <select id="object_attribute_name" name="object[attribute_name]">
231
- <option value="ES">Eastasia</option>
232
- <option disabled>-------------</option>
233
- <option value="ES">Eastasia</option>
234
- <option value="EU">Eurasia</option>
235
- <option value="OC">Oceania</option>
236
- </select>
237
- HTML
238
-
239
- assert_equal_markup(expected, html)
240
- end
241
- end
@@ -1,36 +0,0 @@
1
- lib_path = File.expand_path('../../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib_path)
3
-
4
- require 'minitest/spec'
5
- require 'minitest/autorun'
6
-
7
- require 'action_view/test_case'
8
-
9
- require 'rails'
10
- require 'carmen-rails'
11
- require 'ostruct'
12
-
13
- MiniTest::Spec.register_spec_type(/.*/, ActionView::TestCase)
14
-
15
- Carmen.clear_data_paths
16
- Carmen.append_data_path(Carmen.root_path + 'spec_data/data')
17
-
18
- locale_path = Carmen.root_path + 'spec_data/locale'
19
- Carmen.i18n_backend = Carmen::I18n::Simple.new(locale_path)
20
-
21
- class MiniTest::Unit::TestCase
22
- def assert_equal_markup(expected, actual, message=nil)
23
- assert_equal(clean_markup(expected), clean_markup(actual), message)
24
- end
25
-
26
- private
27
-
28
- def clean_markup(markup)
29
- markup.
30
- gsub(/\s+/, ' '). # cleanup whitespace
31
- gsub(/>\s/, '>'). # kill space after tags
32
- gsub(/\s</, '<'). # space before tags
33
- gsub(/\s\/>/, '/>'). # space inside self-closing tags
34
- strip
35
- end
36
- end