holidays_img 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5777df762392df78ec386a0c915ec1c90ee5abdd
4
- data.tar.gz: 5f84598221af1370e21ffba12f54c8a60f87941c
3
+ metadata.gz: c0be67fcb81c827f829c0f1a7022e333477f958d
4
+ data.tar.gz: c3284d9944346ccbb5e348417fe82b887f7468b8
5
5
  SHA512:
6
- metadata.gz: c25d8dfd62b0619121f82d14c1f08050bed852f1ca4c12999eee9fd350792f3a4f61c0caf8901497af8f334de57a7037be672849b060ac273098e82db480b3ac
7
- data.tar.gz: 7f5d9b25098165e71220408bf6f802df7e4785c27c252a6c39b5b4605c82bed4ed9d70bb0d9410c4a6674111855871857171cb6f07ab7b03e43bc4fc7f60abd4
6
+ metadata.gz: d1769d5c8d1cf8f7ed95c95926b1c9a687ab3a3d280dbe5a71788bcf52eeebc73160499ecdfc25c26b1fad11df2dd31a41a4bb4728d35497bcd92183bb2b3e74
7
+ data.tar.gz: d85ea2729c79419e991d17dda9fddc2d29758ade4ff50b4f1d5058bb028a19c31733b361d0239f00530d934dee14579d89bbe16a712a74421359af14994c8a35
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # holidays_img
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/holidays_img.svg)](https://badge.fury.io/rb/holidays_img)
4
+
3
5
  This gem is a simple wrapper for Rails's `image_tag` helper. Leveraging the `holidays` gem, it allows you to easily load images based on the holiday occurring on any given date.
4
6
 
5
7
  ## Installation
6
8
 
7
- Add this line to your application's Gemfile:
9
+ Add the gem to your application's Gemfile:
8
10
 
9
11
  ```ruby
10
12
  gem 'holidays_img'
@@ -18,13 +20,19 @@ $ bundle
18
20
 
19
21
  ## Usage
20
22
 
21
- Simply use the `holidays_image_tag` helper as you would a standard Rails `image_tag`. To ensure proper loading of images, adhere to the following naming convention:
23
+ Simply use the `holidays_image_tag` helper as you would a standard Rails `image_tag`:
24
+
25
+ ```
26
+ <%= holidays_image_tag 'image.jpg' %>
27
+ ```
28
+
29
+ To ensure proper loading of images, adhere to the following naming convention:
22
30
 
23
31
  - Have a default image, used for when a day does not fall on a holiday (also acts as a fallback for when a holiday image cannot be found)
24
- - Name your holiday images in the following format: `original_name_holiday_name`
32
+ - Name your holiday images in the following format: `original_name_holiday_name.ext`
25
33
  - Ensure all holiday images are in the same directory
26
34
 
27
- Naming Examples:
35
+ Naming Example:
28
36
 
29
37
  ```
30
38
  image.jpg
@@ -34,24 +42,27 @@ image_independence_day.jpg
34
42
  ...
35
43
  ```
36
44
 
37
- See the holiday gem's [definition files](https://github.com/holidays/definitions) for a list of holidays for any available region.
45
+ See the Holidays gem's [definition files](https://github.com/holidays/definitions) for a list of holidays for any available region.
38
46
 
39
47
  ## Configuration
40
48
 
41
49
  You can configure options using an initializer:
42
50
 
43
51
  ```ruby
44
- # app/initializers/holidays_img.rb
52
+ # config/initializers/holidays_img.rb
45
53
 
46
54
  HolidaysImg.configure do |config|
47
55
  # Load holidays based on region, defaults to :us
48
56
  config.region = :ca
49
- # Only load images for holidays you specify,
50
- # defaults to all holidays observed for specified region
51
- config.whitelist = ['Christmas Day']
57
+ # Only load images for holidays you specify
58
+ config.whitelist = ['Christmas Day', 'Mother\'s Day']
59
+ # Load custom holidays from file, can also pass array of file paths
60
+ config.custom_holidays = '/path/to/custom_holidays.yml'
52
61
  end
53
62
  ```
54
63
 
64
+ For info on how to format custom holiday definitions, see the Holidays gem's [definition syntax documentation](https://github.com/holidays/definitions/blob/master/SYNTAX.md).
65
+
55
66
  ## License
56
67
 
57
68
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -7,5 +7,6 @@ module HolidaysImg
7
7
  extend Configuration
8
8
 
9
9
  define_setting :region, :us
10
- define_setting :whitelist, []
10
+ define_setting :whitelist
11
+ define_setting :custom_holidays
11
12
  end
@@ -1,6 +1,8 @@
1
1
  module HolidaysImg
2
2
  module ImageTagWrapper
3
3
  def holidays_image_tag(source, options={})
4
+ Holidays.load_custom(HolidaysImg.custom_holidays) if HolidaysImg.custom_holidays
5
+
4
6
  date = options[:date] || Date.today
5
7
  holiday = Holidays.on(date, HolidaysImg.region).first
6
8
 
@@ -8,7 +10,7 @@ module HolidaysImg
8
10
  original_source = source.dup
9
11
  substring_index = source.rindex('.')
10
12
 
11
- if HolidaysImg.whitelist.empty? || HolidaysImg.whitelist.include?(holiday[:name])
13
+ if HolidaysImg.whitelist.blank? || HolidaysImg.whitelist.include?(holiday[:name])
12
14
  source.insert(substring_index, "_#{holiday[:name].parameterize(separator: '_')}")
13
15
 
14
16
  unless File.exists?("#{Rails.root}/app/assets/images/#{source}")
@@ -1,3 +1,3 @@
1
1
  module HolidaysImg
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holidays_img
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoran Pesic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-20 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: holidays