sitemap_generator 2.1.7 → 2.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -5
- data/Gemfile.lock +2 -13
- data/README.md +104 -39
- data/VERSION +1 -1
- data/lib/sitemap_generator/builder/sitemap_url.rb +57 -13
- metadata +4 -4
data/Gemfile
CHANGED
@@ -11,14 +11,18 @@ gem 'rspec-rails', '~>1.3.2', :require => 'spec/rails'
|
|
11
11
|
# Simplify these dependencies
|
12
12
|
gem 'git', '1.2.5'
|
13
13
|
gem 'jeweler', '=1.4.0'
|
14
|
-
gem 'github', '0.4.5'
|
14
|
+
gem 'github', '0.4.5' # comment out to test on 1.9; removed in framework_agnostic
|
15
15
|
gem 'gemcutter', '0.6.1'
|
16
16
|
|
17
17
|
# These seem to be dependencies of jeweler or one of the other gems
|
18
18
|
gem 'nokogiri', '1.4.4'
|
19
19
|
gem 'sqlite3-ruby', '1.3.1', :require => 'sqlite3'
|
20
20
|
|
21
|
-
group :test do
|
22
|
-
gem 'ruby-debug', '~>0.10'
|
23
|
-
gem 'ruby-debug-base', '~>0.10'
|
24
|
-
end
|
21
|
+
#group :test do
|
22
|
+
# gem 'ruby-debug', '~>0.10'
|
23
|
+
# gem 'ruby-debug-base', '~>0.10'
|
24
|
+
#end
|
25
|
+
# group :test do
|
26
|
+
# gem 'ruby-debug-base19', '0.11.26'
|
27
|
+
# gem 'ruby-debug19'
|
28
|
+
# end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ./
|
3
3
|
specs:
|
4
|
-
sitemap_generator (2.1.
|
4
|
+
sitemap_generator (2.1.8)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -16,7 +16,6 @@ GEM
|
|
16
16
|
activeresource (2.3.8)
|
17
17
|
activesupport (= 2.3.8)
|
18
18
|
activesupport (2.3.8)
|
19
|
-
columnize (0.3.4)
|
20
19
|
gemcutter (0.6.1)
|
21
20
|
git (1.2.5)
|
22
21
|
github (0.4.5)
|
@@ -28,11 +27,9 @@ GEM
|
|
28
27
|
gemcutter (>= 0.1.0)
|
29
28
|
git (>= 1.2.5)
|
30
29
|
rubyforge (>= 2.0.0)
|
31
|
-
json (1.
|
30
|
+
json (1.6.2)
|
32
31
|
json_pure (1.5.4)
|
33
32
|
spruz (~> 0.2.8)
|
34
|
-
linecache (0.46)
|
35
|
-
rbx-require-relative (> 0.0.4)
|
36
33
|
mocha (0.9.10)
|
37
34
|
rake
|
38
35
|
nokogiri (1.4.4)
|
@@ -45,16 +42,10 @@ GEM
|
|
45
42
|
activesupport (= 2.3.8)
|
46
43
|
rake (>= 0.8.3)
|
47
44
|
rake (0.9.2.2)
|
48
|
-
rbx-require-relative (0.0.5)
|
49
45
|
rspec (1.3.1)
|
50
46
|
rspec-rails (1.3.4)
|
51
47
|
rack (>= 1.0.0)
|
52
48
|
rspec (~> 1.3.1)
|
53
|
-
ruby-debug (0.10.3)
|
54
|
-
columnize (>= 0.1)
|
55
|
-
ruby-debug-base (~> 0.10.3.0)
|
56
|
-
ruby-debug-base (0.10.3)
|
57
|
-
linecache (>= 0.3)
|
58
49
|
rubyforge (2.0.4)
|
59
50
|
json_pure (>= 1.1.7)
|
60
51
|
spruz (0.2.13)
|
@@ -77,7 +68,5 @@ DEPENDENCIES
|
|
77
68
|
rake (>= 0.8.7)
|
78
69
|
rspec (= 1.3.1)
|
79
70
|
rspec-rails (~> 1.3.2)
|
80
|
-
ruby-debug (~> 0.10)
|
81
|
-
ruby-debug-base (~> 0.10)
|
82
71
|
sitemap_generator!
|
83
72
|
sqlite3-ruby (= 1.3.1)
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Features
|
|
12
12
|
- Adheres to the [Sitemap 0.9 protocol][sitemap_protocol]
|
13
13
|
- Handles millions of links
|
14
14
|
- Automatically compresses your sitemaps
|
15
|
-
- Notifies search engines (Google,
|
15
|
+
- Notifies search engines (Google, Bing, Ask, SitemapWriter) of new sitemaps
|
16
16
|
- Ensures your old sitemaps stay in place if the new sitemap fails to generate
|
17
17
|
- Gives you complete control over your sitemaps and their content
|
18
18
|
|
@@ -26,6 +26,7 @@ Does your website use SitemapGenerator to generate Sitemaps? Where would you be
|
|
26
26
|
Changelog
|
27
27
|
-------
|
28
28
|
|
29
|
+
- v2.1.8: Extend and improve Video Sitemap support. Include sitemap docs in the README, support all element attributes, properly format values.
|
29
30
|
- v2.1.7: Improve format of float priorities; Remove Yahoo from ping - the Yahoo
|
30
31
|
service has been shut down.
|
31
32
|
- v2.1.6: Fix the lastmod value on sitemap file links
|
@@ -109,9 +110,7 @@ Run `rake sitemap:refresh` as needed to create or rebuild your sitemap files. S
|
|
109
110
|
Search Engine Notification
|
110
111
|
-----
|
111
112
|
|
112
|
-
Using `rake sitemap:refresh` will notify major search engines to let them know that a new sitemap is available (Google,
|
113
|
-
|
114
|
-
To ping Yahoo you will need to set your Yahoo AppID in `config/sitemap.rb`. For example: `SitemapGenerator::Sitemap.yahoo_app_id = "my_app_id"`
|
113
|
+
Using `rake sitemap:refresh` will notify major search engines to let them know that a new sitemap is available (Google, Bing, Ask, SitemapWriter). To generate new sitemaps without notifying search engines (for example when running in a local environment) use `rake sitemap:refresh:no_ping`.
|
115
114
|
|
116
115
|
Crontab
|
117
116
|
-----
|
@@ -213,7 +212,7 @@ overwrite each other. You can use the `filename`, `sitemaps_namer` and `sitemap
|
|
213
212
|
|
214
213
|
In the following example we generate three sitemaps each in its own subdirectory:
|
215
214
|
|
216
|
-
%w(google
|
215
|
+
%w(google bing apple).each do |subdomain|
|
217
216
|
SitemapGenerator::Sitemap.default_host = "https://#{subdomain}.mysite.com"
|
218
217
|
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/#{subdomain}"
|
219
218
|
SitemapGenerator::Sitemap.create do
|
@@ -226,8 +225,8 @@ Outputs:
|
|
226
225
|
+ sitemaps/google/sitemap1.xml.gz 2 links / 822 Bytes / 328 Bytes gzipped
|
227
226
|
+ sitemaps/google/sitemap_index.xml.gz 1 sitemaps / 389 Bytes / 217 Bytes gzipped
|
228
227
|
Sitemap stats: 2 links / 1 sitemaps / 0m00s
|
229
|
-
+ sitemaps/
|
230
|
-
+ sitemaps/
|
228
|
+
+ sitemaps/bing/sitemap1.xml.gz 2 links / 820 Bytes / 330 Bytes gzipped
|
229
|
+
+ sitemaps/bing/sitemap_index.xml.gz 1 sitemaps / 388 Bytes / 217 Bytes gzipped
|
231
230
|
Sitemap stats: 2 links / 1 sitemaps / 0m00s
|
232
231
|
+ sitemaps/apple/sitemap1.xml.gz 2 links / 820 Bytes / 330 Bytes gzipped
|
233
232
|
+ sitemaps/apple/sitemap_index.xml.gz 1 sitemaps / 388 Bytes / 214 Bytes gzipped
|
@@ -249,9 +248,9 @@ If you don't want to have to generate all the sitemaps at once, or you want to r
|
|
249
248
|
add '/home'
|
250
249
|
end
|
251
250
|
|
252
|
-
# config/
|
253
|
-
SitemapGenerator::Sitemap.default_host = "https://
|
254
|
-
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/
|
251
|
+
# config/bing_sitemap.rb
|
252
|
+
SitemapGenerator::Sitemap.default_host = "https://bing.mysite.com"
|
253
|
+
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/bing"
|
255
254
|
SitemapGenerator::Sitemap.create do
|
256
255
|
add '/home'
|
257
256
|
end
|
@@ -260,7 +259,7 @@ To generate each one specify the configuration file to run by passing the `CONFI
|
|
260
259
|
|
261
260
|
rake sitemap:refresh CONFIG_FILE="config/google_sitemap.rb"
|
262
261
|
rake sitemap:refresh CONFIG_FILE="config/apple_sitemap.rb"
|
263
|
-
rake sitemap:refresh CONFIG_FILE="config/
|
262
|
+
rake sitemap:refresh CONFIG_FILE="config/bing_sitemap.rb"
|
264
263
|
|
265
264
|
Sitemap Configuration
|
266
265
|
======
|
@@ -523,7 +522,9 @@ Sitemap Extensions
|
|
523
522
|
News Sitemaps
|
524
523
|
-----------
|
525
524
|
|
526
|
-
A news item can be added to a sitemap URL by passing a `:news` hash to `add`. The hash must contain tags defined by the [News Sitemap][news_tags] specification.
|
525
|
+
A news item can be added to a sitemap URL by passing a `:news` hash to `add`. The hash must contain tags defined by the [News Sitemap][news_tags] specification.
|
526
|
+
|
527
|
+
### Example
|
527
528
|
|
528
529
|
SitemapGenerator::Sitemap.create do
|
529
530
|
add('/index.html', :news => {
|
@@ -538,7 +539,7 @@ A news item can be added to a sitemap URL by passing a `:news` hash to `add`. T
|
|
538
539
|
})
|
539
540
|
end
|
540
541
|
|
541
|
-
Supported
|
542
|
+
### Supported options
|
542
543
|
|
543
544
|
* `publication_name`
|
544
545
|
* `publication_language`
|
@@ -549,10 +550,13 @@ Supported news options include:
|
|
549
550
|
* `keywords`
|
550
551
|
* `stock_tickers`
|
551
552
|
|
553
|
+
* * *
|
552
554
|
Image Sitemaps
|
553
555
|
-----------
|
554
556
|
|
555
|
-
Images can be added to a sitemap URL by passing an `:images` array to `add`. Each item in the array must be a Hash containing tags defined by the [Image Sitemap][image_tags] specification.
|
557
|
+
Images can be added to a sitemap URL by passing an `:images` array to `add`. Each item in the array must be a Hash containing tags defined by the [Image Sitemap][image_tags] specification.
|
558
|
+
|
559
|
+
### Example
|
556
560
|
|
557
561
|
SitemapGenerator::Sitemap.create do
|
558
562
|
add('/index.html', :images => [{
|
@@ -560,7 +564,7 @@ Images can be added to a sitemap URL by passing an `:images` array to `add`. Ea
|
|
560
564
|
:title => 'Image' }])
|
561
565
|
end
|
562
566
|
|
563
|
-
Supported
|
567
|
+
### Supported options
|
564
568
|
|
565
569
|
* `loc` Required, location of the image
|
566
570
|
* `caption`
|
@@ -568,16 +572,15 @@ Supported image options include:
|
|
568
572
|
* `title`
|
569
573
|
* `license`
|
570
574
|
|
575
|
+
* * *
|
571
576
|
Video Sitemaps
|
572
577
|
-----------
|
573
578
|
|
574
|
-
A video can be added to a sitemap URL by passing a `:video` Hash to `add`. The Hash can contain tags defined by the [Video Sitemap specification][video_tags].
|
579
|
+
A video can be added to a sitemap URL by passing a `:video` Hash to `add()`. The Hash can contain tags defined by the [Video Sitemap specification][video_tags].
|
575
580
|
|
576
581
|
To add more than one video to a url, pass an array of video hashes using the `:videos` option.
|
577
582
|
|
578
|
-
|
579
|
-
|
580
|
-
Example:
|
583
|
+
### Example
|
581
584
|
|
582
585
|
add('/index.html', :video => {
|
583
586
|
:thumbnail_loc => 'http://www.example.com/video1_thumbnail.png',
|
@@ -588,35 +591,97 @@ Example:
|
|
588
591
|
:category => 'Category'
|
589
592
|
})
|
590
593
|
|
591
|
-
Supported
|
592
|
-
|
593
|
-
*
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
* `
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
* `
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
* `
|
606
|
-
|
607
|
-
|
608
|
-
|
594
|
+
### Supported options
|
595
|
+
|
596
|
+
* `:thumbnail_loc` - Required, string.
|
597
|
+
|
598
|
+
A URL pointing to the URL for the video thumbnail image file. We can accept most image sizes/types but recommend your thumbs are at least at least 640x480 pixels in .jpg, .png, or. gif formats. The max size is 1920 x 1080 pixels.
|
599
|
+
|
600
|
+
* `:title` - Required, string.
|
601
|
+
|
602
|
+
The title of the video. Limited to 100 characters.
|
603
|
+
|
604
|
+
* `:description` - Required, string.
|
605
|
+
|
606
|
+
The description of the video. Descriptions longer than 2048 characters will be truncated.
|
607
|
+
|
608
|
+
* `:content_loc` - String. **At least one of `player_loc` or `content_loc` is required.**
|
609
|
+
|
610
|
+
The URL should point to a .mpg, .mpeg, .mp4, .m4v, .mov, .wmv, .asf, .avi, .ra, .ram, .rm, .flv, or other video file format, and can be omitted if `:player_loc` is specified. However, because Google needs to be able to check that the Flash object is actually a player for video (as opposed to some other use of Flash, e.g. games and animations), it's helpful to provide both.
|
611
|
+
|
612
|
+
* `:player_loc` - String. **At least one of `player_loc` or `content_loc` is required.**
|
613
|
+
|
614
|
+
A URL pointing to a Flash player for a specific video. In general, this is the information in the src element of an <embed> tag and should not be the same as the content of the <loc> tag. Since each video is uniquely identified by its content URL (the location of the actual video file) or, if a content URL is not present, a player URL (a URL pointing to a player for the video), you must include either the `:player_loc` or `:content_loc` options. If these options are omitted and we can't find this information, we'll be unable to index your video.
|
615
|
+
|
616
|
+
Attributes:
|
617
|
+
* `:allow_embed` - Optional. Values: boolean, or string 'yes' or 'no'. Default: 'yes'.
|
618
|
+
|
619
|
+
Specifies whether Google can embed the video in search results.
|
620
|
+
* `:autoplay` - String, user defined.
|
621
|
+
|
622
|
+
A user-defined string that Google may append (if appropriate) to the flashvars parameter to enable autoplay of the video. For example: <embed src="http://www.example.com/videoplayer.swf?video=123" autoplay="ap=1"/>
|
623
|
+
|
624
|
+
* `:expiration_date` - Recommended. Values: Date, DateTime, Time, ActiveSupport::TimeWithZone or String.
|
625
|
+
|
626
|
+
The date after which the video will no longer be available. Don't supply this information if your video does not expire. Ruby date and time objects will be formatted for you in the appropriate W3C format. However, if you are passing a string, follow these guidelines: acceptable values are complete date (YYYY-MM-DD) and complete date plus hours, minutes and seconds, and timezone (YYYY-MM-DDThh:mm:ss+TZD). For example, 2007-07-16T19:20:30+08:00.
|
627
|
+
|
628
|
+
* `:duration` - Recommended. Integer.
|
609
629
|
|
630
|
+
The duration of the clip in seconds.
|
610
631
|
|
632
|
+
* `:rating` - Optional. The value must be a float or integer between 0.0 and 5.0.
|
611
633
|
|
634
|
+
The rating of the video.
|
635
|
+
|
636
|
+
* `:view_count` - Optional, integer.
|
637
|
+
|
638
|
+
The number of times the video has been viewed.
|
639
|
+
|
640
|
+
* `:publication_date` - Optional. Values: Date, DateTime, Time, ActiveSupport::TimeWithZone or String.
|
641
|
+
|
642
|
+
The date the video was first published. Ruby date and time objects will be formatted for you in the appropriate W3C format. However, if you are passing a string, follow these guidelines: acceptable values are complete date (YYYY-MM-DD) and complete date plus hours, minutes and seconds, and timezone (YYYY-MM-DDThh:mm:ss+TZD). For example, 2007-07-16T19:20:30+08:00.
|
643
|
+
|
644
|
+
* `:family_friendly` - Optional. Values: boolean, or string 'yes' or 'no'.
|
645
|
+
|
646
|
+
Whether the video is suitable for viewing by children. If `No` the video is only available to users with SafeSearch turned off.
|
647
|
+
|
648
|
+
* `:tags` - Optional. A list of one or more string tags. A maximum of 32 tags is permitted.
|
649
|
+
|
650
|
+
* `:tag` - Optional. String. A single tag. If the video has more than one tag, use `:tags`.
|
651
|
+
|
652
|
+
A tag associated with the video. Tags are generally very short descriptions of key concepts associated with a video or piece of content. A single video could have several tags, although it might belong to only one category. For example, a video about grilling food may belong in the Grilling category, but could be tagged "steak", "meat", "summer", and "outdoor".
|
653
|
+
|
654
|
+
* `:category` - Optional, string.
|
655
|
+
|
656
|
+
The video's category. For example, cooking. The value should be a string no longer than 256 characters. In general, categories are broad groupings of content by subject. Usually a video will belong to a single category. For example, a site about cooking could have categories for Broiling, Baking, and Grilling.
|
657
|
+
|
658
|
+
* `:gallery_loc` - Optional, string.
|
659
|
+
|
660
|
+
A link to the gallery (collection of videos) in which this video appears. Only one <video:gallery_loc> tag can be listed for each video.
|
661
|
+
|
662
|
+
Attributes:
|
663
|
+
* `:gallery_title` - Optional, string. The title of the gallery. Sets the `title` attribute of the <video:gallery_loc> tag.
|
664
|
+
|
665
|
+
* `:uploader` - Optional, string.
|
666
|
+
|
667
|
+
A name or handle of the video’s uploader. Only one <video:uploader> is allowed per video.
|
668
|
+
|
669
|
+
Attributes:
|
670
|
+
* `:uploader_info` - Optional, string. Specifies the URL of a webpage with additional information about this uploader. This URL must be on the same domain as the <loc> tag. Sets the `info` attribute of the <video:uploader_info> tag.
|
671
|
+
|
672
|
+
* * *
|
612
673
|
Geo Sitemaps
|
613
674
|
-----------
|
614
675
|
|
615
676
|
Pages with geo data can be added by passing a `:geo` Hash to `add`. The Hash only supports one tag of `:format`. Google provides an [example of a geo sitemap link here][geo_tags]. Note that the sitemap does not actually contain your KML or GeoRSS. It merely links to a page that has this content.
|
616
677
|
|
617
|
-
|
678
|
+
### Example:
|
679
|
+
|
680
|
+
SitemapGenerator::Sitemap.create do
|
681
|
+
add('/stores/1234.xml', :geo => { :format => 'kml' })
|
682
|
+
end
|
618
683
|
|
619
|
-
Supported
|
684
|
+
### Supported options
|
620
685
|
|
621
686
|
* `format` Required, either 'kml' or 'georss'
|
622
687
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.8
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'builder'
|
2
2
|
require 'uri'
|
3
|
+
require 'time'
|
4
|
+
require 'date'
|
3
5
|
|
4
6
|
module SitemapGenerator
|
5
7
|
module Builder
|
@@ -59,9 +61,9 @@ module SitemapGenerator
|
|
59
61
|
builder = ::Builder::XmlMarkup.new if builder.nil?
|
60
62
|
builder.url do
|
61
63
|
builder.loc self[:loc]
|
62
|
-
builder.lastmod w3c_date(self[:lastmod])
|
63
|
-
builder.changefreq self[:changefreq]
|
64
|
-
builder.priority
|
64
|
+
builder.lastmod w3c_date(self[:lastmod]) if self[:lastmod]
|
65
|
+
builder.changefreq self[:changefreq] if self[:changefreq]
|
66
|
+
builder.priority format_float(self[:priority]) if self[:priority]
|
65
67
|
|
66
68
|
unless self[:news].blank?
|
67
69
|
news_data = self[:news]
|
@@ -97,20 +99,18 @@ module SitemapGenerator
|
|
97
99
|
builder.video :description, video[:description]
|
98
100
|
builder.video :content_loc, video[:content_loc] if video[:content_loc]
|
99
101
|
if video[:player_loc]
|
100
|
-
builder.video :player_loc, video[:player_loc], :allow_embed => (video[:allow_embed]
|
102
|
+
builder.video :player_loc, video[:player_loc], :allow_embed => yes_or_no_with_default(video[:allow_embed], true), :autoplay => video[:autoplay]
|
101
103
|
end
|
102
|
-
|
103
|
-
builder.video :rating, video[:rating] if video[:rating]
|
104
|
-
builder.video :view_count, video[:view_count] if video[:view_count]
|
105
|
-
builder.video :publication_date, video[:publication_date] if video[:publication_date]
|
106
|
-
builder.video :expiration_date, video[:expiration_date] if video[:expiration_date]
|
107
|
-
builder.video :family_friendly, (video[:family_friendly] ? 'yes' : 'no') if video[:family_friendly]
|
108
104
|
builder.video :duration, video[:duration] if video[:duration]
|
105
|
+
builder.video :expiration_date, w3c_date(video[:expiration_date]) if video[:expiration_date]
|
106
|
+
builder.video :rating, format_float(video[:rating]) if video[:rating]
|
107
|
+
builder.video :view_count, video[:view_count] if video[:view_count]
|
108
|
+
builder.video :publication_date, w3c_date(video[:publication_date]) if video[:publication_date]
|
109
109
|
video[:tags].each {|tag| builder.video :tag, tag } if video[:tags]
|
110
110
|
builder.video :tag, video[:tag] if video[:tag]
|
111
111
|
builder.video :category, video[:category] if video[:category]
|
112
|
-
builder.video :
|
113
|
-
|
112
|
+
builder.video :family_friendly, yes_or_no_with_default(video[:family_friendly], true) if video.has_key?(:family_friendly)
|
113
|
+
builder.video :gallery_loc, video[:gallery_loc], :title => video[:gallery_title] if video[:gallery_loc]
|
114
114
|
if video[:uploader]
|
115
115
|
builder.video :uploader, video[:uploader], video[:uploader_info] ? { :info => video[:uploader_info] } : {}
|
116
116
|
end
|
@@ -149,7 +149,51 @@ module SitemapGenerator
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def w3c_date(date)
|
152
|
-
|
152
|
+
if date.is_a?(String)
|
153
|
+
date
|
154
|
+
elsif date.respond_to?(:iso8601)
|
155
|
+
date.iso8601.sub(/Z$/i, '+00:00')
|
156
|
+
elsif date.is_a?(Date) && !date.is_a?(DateTime)
|
157
|
+
date.strftime("%Y-%m-%d")
|
158
|
+
else
|
159
|
+
zulutime = if date.is_a?(DateTime)
|
160
|
+
date.new_offset(0)
|
161
|
+
elsif date.respond_to?(:utc)
|
162
|
+
date.utc
|
163
|
+
else
|
164
|
+
nil
|
165
|
+
end
|
166
|
+
|
167
|
+
if zulutime
|
168
|
+
zulutime.strftime("%Y-%m-%dT%H:%M:%S+00:00")
|
169
|
+
else
|
170
|
+
zone = date.strftime('%z').insert(-3, ':')
|
171
|
+
date.strftime("%Y-%m-%dT%H:%M:%S") + zone
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Accept a string or boolean and return 'yes' or 'no'. If a string, the
|
177
|
+
# value must be 'yes' or 'no'. Pass the default value as a boolean using `default`.
|
178
|
+
def yes_or_no(value)
|
179
|
+
if value.is_a?(String)
|
180
|
+
raise ArgumentError.new("Unrecognized value for yes/no field: #{value.inspect}") unless value =~ /^(yes|no)$/i
|
181
|
+
value.downcase
|
182
|
+
else
|
183
|
+
value ? 'yes' : 'no'
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# If the value is nil, return `default` converted to either 'yes' or 'no'.
|
188
|
+
# If the value is set, return its value converted to 'yes' or 'no'.
|
189
|
+
def yes_or_no_with_default(value, default)
|
190
|
+
yes_or_no(value.nil? ? default : value)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Format a float to to one decimal precision.
|
194
|
+
# TODO: Use rounding with precision once merged with framework_agnostic.
|
195
|
+
def format_float(value)
|
196
|
+
value.is_a?(String) ? value : ('%0.1f' % value)
|
153
197
|
end
|
154
198
|
end
|
155
199
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitemap_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 2.1.
|
9
|
+
- 8
|
10
|
+
version: 2.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Karl Varga
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-12-16 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|