currency_select 5.0.0 → 5.0.1

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
  SHA256:
3
- metadata.gz: 7d100fa5d8db54cfe83c7b6b22af1b074fda179bbc8372a6be10fe724a284b2d
4
- data.tar.gz: cbcbdd178abaf13fc1ecf6bbee7c9e9486c46139e3bca4ae761685deedbb14f4
3
+ metadata.gz: e66e8307689b3cafe1b952135b87cd0a68813c97523bc4ff381039db912cb6ad
4
+ data.tar.gz: bae46f9d23ba8cfc8f1e99c024187c76d83e133c6937b7fdef526c07e8a3007c
5
5
  SHA512:
6
- metadata.gz: 736a8e8842996e681149fc24c0dae6483ac45cf0bd5ed71a43b99b6a2571783d5ad0a1d0ddf44b8cff3ab10c166f787a04008169a0f7da20daea18fa46596633
7
- data.tar.gz: e7c241ca7915f93e32cec7fb0ce60b9ee9c04e546ded9fd6f5d95b11a640ca7e04a2647971cb317942f886db1c4c4f1f10601f572b37d7608ac0baf2c2f5f505
6
+ metadata.gz: 95ca18df0dcda855119e0631278a4743b3067bea1adf7f43dc7a51153ff6702556bb307be15ec8e8b6f5e2b63c083723d79b05a4a7be8578106a607fd07ccb11
7
+ data.tar.gz: b2c8201dcad0b20634fa6487f4c7c9bc2196b02bbde98da7e9f598f548215a0c31cdca25827c5e7f6d5fd3bd2ca463eeee02c94a51d935d8f2d8cfb720a3963e
data/CHANGELOG.md CHANGED
@@ -13,6 +13,15 @@ This project adheres to [Semantic Versioning](https://semver.org/).
13
13
 
14
14
  ### Removed
15
15
 
16
+ ### Fixed
17
+
18
+ ### Security
19
+
20
+ ## 5.0.1
21
+
22
+ ### Fixed
23
+ - Add missing files to the gemspec file (#137)
24
+
16
25
  ## 5.0.0
17
26
 
18
27
  ### Added
@@ -26,10 +35,6 @@ This project adheres to [Semantic Versioning](https://semver.org/).
26
35
  - Drop support for Rails 5.2 (#112)
27
36
  - Drop support for Ruby 2.6 and 2.7 (#111, #132)
28
37
 
29
- ### Fixed
30
-
31
- ### Security
32
-
33
38
  ## 4.1.0
34
39
 
35
40
  ### Added
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.0
1
+ 5.0.1
@@ -15,8 +15,11 @@ Gem::Specification.new do |s|
15
15
  s.email = 'o.klee@braingourmets.com'
16
16
 
17
17
  s.files = %w[
18
- lib/currency_select.rb rails/init.rb CHANGELOG.md CODE_OF_CONDUCT.md
19
- currency_select.gemspec Gemfile LICENSE Rakefile README.md VERSION
18
+ CHANGELOG.md CODE_OF_CONDUCT.md Gemfile LICENSE README.md Rakefile VERSION
19
+ currency_select.gemspec
20
+ lib/currency_select.rb lib/currency_select_tag.rb lib/form_builder.rb
21
+ lib/form_options_helper.rb lib/to_currency_select_tag.rb
22
+ rails/init.rb
20
23
  ]
21
24
  s.extra_rdoc_files = %w[CHANGELOG.md LICENSE README.md]
22
25
 
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'to_currency_select_tag'
4
+
5
+ # CurrencySelect
6
+ module ActionView
7
+ module Helpers
8
+ ##
9
+ # Tag.
10
+ #
11
+ class CurrencySelectTag < Tags::Base
12
+ include ToCurrencySelectTag
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # CurrencySelect
4
+ module ActionView
5
+ module Helpers
6
+ ##
7
+ # Form builder.
8
+ #
9
+ class FormBuilder
10
+ def currency_select(
11
+ method, priority_currencies = nil, options = {}, html_options = {}
12
+ )
13
+ @template.currency_select(
14
+ @object_name,
15
+ method,
16
+ priority_currencies,
17
+ options.merge(object: @object),
18
+ html_options
19
+ )
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'money'
4
+
5
+ # CurrencySelect
6
+ module ActionView
7
+ module Helpers
8
+ ##
9
+ # Module for the form options.
10
+ #
11
+ module FormOptionsHelper
12
+ # Return select and option tags for the given object and method, using
13
+ # currency_options_for_select to generate the list of option tags.
14
+ def currency_select(
15
+ object, method, priority_currencies = nil, options = {},
16
+ html_options = {}
17
+ )
18
+ tag = CurrencySelectTag.new(object, method, self, options)
19
+ tag.to_currency_select_tag(priority_currencies, options, html_options)
20
+ end
21
+
22
+ # Returns a string of option tags for all available currencies. Supply
23
+ # a currency ISO code as +selected+ to have it marked as the selected
24
+ # option tag. You can also supply an array of currencies as
25
+ # +priority_currencies+, so that they will be listed above the rest of
26
+ # the list.
27
+ def currency_options_for_select(selected = nil, priority_currencies = nil)
28
+ currency_options = ''.html_safe
29
+
30
+ if priority_currencies
31
+ currency_options += options_for_select(
32
+ ::CurrencySelect.priority_currencies_array(priority_currencies),
33
+ selected
34
+ )
35
+ label = '-------------'.html_safe
36
+ option = content_tag(:option, label, value: '', disabled: 'disabled')
37
+ currency_options += option
38
+
39
+ # prevents selected from being included twice in the HTML which causes
40
+ # some browsers to select the second selected option (not priority)
41
+ # which makes it harder to select an alternative priority country
42
+ selected = nil if priority_currencies.include?(selected)
43
+ end
44
+
45
+ # All the countries included in the country_options output.
46
+ currency_options + options_for_select(
47
+ ::CurrencySelect.currencies_array, selected
48
+ )
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # CurrencySelect
4
+ module ActionView
5
+ module Helpers
6
+ ##
7
+ # Tag.
8
+ #
9
+ module ToCurrencySelectTag
10
+ def to_currency_select_tag(priority_currencies, options, html_options)
11
+ html_options = html_options.stringify_keys
12
+ add_default_name_and_id(html_options)
13
+ value = if method(:value).arity.zero?
14
+ options.fetch(:selected) { value() }
15
+ else
16
+ options.fetch(:selected) { value(object) }
17
+ end
18
+ content_tag(
19
+ 'select',
20
+ add_options(
21
+ currency_options_for_select(value, priority_currencies),
22
+ options,
23
+ value
24
+ ),
25
+ html_options
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: currency_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trond Arve Nordheim
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-07-28 00:00:00.000000000 Z
12
+ date: 2023-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionview
@@ -133,6 +133,10 @@ files:
133
133
  - VERSION
134
134
  - currency_select.gemspec
135
135
  - lib/currency_select.rb
136
+ - lib/currency_select_tag.rb
137
+ - lib/form_builder.rb
138
+ - lib/form_options_helper.rb
139
+ - lib/to_currency_select_tag.rb
136
140
  - rails/init.rb
137
141
  homepage: https://github.com/braingourmets/currency_select
138
142
  licenses: