currency_select 0.1.4 → 3.0.0

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
+ SHA256:
3
+ metadata.gz: 604aa2ae65152c8cee328a9057730d2c0b13a837821011c4243abe5472e5ddfd
4
+ data.tar.gz: 875ac451d6891e673b4c5de1be1d3da37332d86d8144a00cc6f4685cdf16c44d
5
+ SHA512:
6
+ metadata.gz: ddd165f48539bcfbaf4beab11d8e1863de607466de249a7e098e005e53ec3e14dba8aeb0fa9a6040ab8fd92986020d603642145712cfe87523edd7488944a6f0
7
+ data.tar.gz: 7a940a412651e7a8dd0fd147b118780e2c891fdc97e451c5757c43447f2d63ef6343489989dd7e4ae2943482118d76bef4eab143530bb8ac54f700e7ff2ae900
@@ -0,0 +1,121 @@
1
+ # currency_select change log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project adheres to [Semantic Versioning](https://semver.org/).
5
+
6
+ ## x.y.z (unreleased)
7
+
8
+ ### Added
9
+
10
+ ### Changed
11
+
12
+ ### Deprecated
13
+
14
+ ### Removed
15
+
16
+ ### Fixed
17
+
18
+ ### Security
19
+
20
+ ## 3.0.0
21
+
22
+ ### Added
23
+ - Add automatic gem release (#86, #88)
24
+ - Support Ruby 3 (#81)
25
+ - Add support for Rails 6.1 (#78, #79, #83)
26
+ - Check the code with RuboCop (#72)
27
+ - Add support for Ruby 2.7 (#66)
28
+
29
+ ### Changed
30
+ - Switch the CI from Travis to GitHub Actions (#80, #85)
31
+ - Upgrade RSpec and RSpec-Rails (#71)
32
+ - Update the Ruby versions on Travis CI (#68)
33
+
34
+ ### Removed
35
+ - Drop support for Ruby 2.4 (#70)
36
+ - Drop support for Rails < 5.2 (#65)
37
+
38
+ ### Fixed
39
+ - Fix some RuboCop warnings (#73)
40
+ - Fix warnings in the `.travis.yml` (#67, #69)
41
+
42
+ ## 2.0.0
43
+
44
+ ### Added
45
+ - Add support for Rails 6.0
46
+ ([#60](https://github.com/braingourmets/currency_select/pull/60))
47
+ - Officially support Rails 5.2
48
+ ([#51](https://github.com/braingourmets/currency_select/pull/51))
49
+ - Add Ruby 2.5.1 to the Travis build matrix
50
+ ([#49](https://github.com/braingourmets/currency_select/pull/49))
51
+
52
+ ### Removed
53
+ - Drop support for Rails < 5.1
54
+ ([#62](https://github.com/braingourmets/currency_select/pull/62))
55
+ - Drop support for Ruby < 2.4
56
+ ([#61](https://github.com/braingourmets/currency_select/pull/61))
57
+ - Drop support for Ruby < 2.3
58
+ ([#48](https://github.com/braingourmets/currency_select/pull/48))
59
+
60
+ ### Fixed
61
+ - Add version to the requirements in the gemspec file
62
+ ([#53](https://github.com/braingourmets/currency_select/pull/53))
63
+ - Fix file names references from the gemspec file
64
+ ([#52](https://github.com/braingourmets/currency_select/pull/52))
65
+ - Fix value call on Rails 5.2
66
+ ([#47](https://github.com/braingourmets/currency_select/pull/47))
67
+
68
+ ## 1.0.0
69
+
70
+ ### Added
71
+ - Officially support Rails 5.2
72
+ ([#51](https://github.com/braingourmets/currency_select/pull/51))
73
+ - Add Ruby 2.5.1 to the Travis build matrix
74
+ ([#49](https://github.com/braingourmets/currency_select/pull/49))
75
+
76
+ ### Removed
77
+ - Drop support for Ruby < 2.3
78
+ ([#48](https://github.com/braingourmets/currency_select/pull/48))
79
+
80
+ ### Fixed
81
+ - Add version to the requirements in the gemspec file
82
+ ([#53](https://github.com/braingourmets/currency_select/pull/53))
83
+ - Fix file names references from the gemspec file
84
+ ([#52](https://github.com/braingourmets/currency_select/pull/52))
85
+ - Fix value call on Rails 5.2
86
+ ([#47](https://github.com/braingourmets/currency_select/pull/47))
87
+
88
+ ## 0.2.0
89
+
90
+ ### Added
91
+ - Automatically use the version number from the VERSION file in the gemspec
92
+ ([#32](https://github.com/braingourmets/currency_select/pull/32))
93
+ - Add a code of conduct
94
+ ([#25](https://github.com/braingourmets/currency_select/pull/25))
95
+
96
+ ### Changed
97
+ - Mark all Ruby files as frozen_string_literal: true
98
+ ([#31](https://github.com/braingourmets/currency_select/pull/31))
99
+
100
+ ### Deprecated
101
+ - Support for Rails < 5.0.0 will be removed in version 2.0.0.
102
+ - Support for Rails < 4.2.0 will be removed in version 1.0.0.
103
+ - Support for Ruby < 2.3.0 will be removed in version 1.0.0.
104
+
105
+ ### Removed
106
+ - Remove pre-Rails-4.0-specific code
107
+ ([#38](https://github.com/braingourmets/currency_select/pull/38))
108
+ - Drop Jeweler
109
+ ([#28](https://github.com/braingourmets/currency_select/pull/28))
110
+
111
+ ### Fixed
112
+ - Add ActionView as explicit dependency
113
+ ([#34](https://github.com/braingourmets/currency_select/pull/34))
114
+ - Fix the check for only one active selection in the specs
115
+ ([#27](https://github.com/braingourmets/currency_select/pull/27))
116
+ - Use ISO codes as select values, not the IDs
117
+ ([#24](https://github.com/braingourmets/currency_select/pull/24))
118
+ - Fix the Gemfile
119
+ ([#19](https://github.com/braingourmets/currency_select/pull/19))
120
+ - Fix the order of name attribute and ID in the specs
121
+ ([#18](https://github.com/braingourmets/currency_select/pull/18))
@@ -0,0 +1,77 @@
1
+ # Contributor Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age,
8
+ body size, disability, ethnicity, gender identity and expression, level of
9
+ experience, nationality, personal appearance, race, religion, or sexual
10
+ identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+
35
+ ## Our Responsibilities
36
+
37
+ Project maintainers are responsible for clarifying the standards of acceptable
38
+ behavior and are expected to take appropriate and fair corrective action in
39
+ response to any instances of unacceptable behavior.
40
+
41
+ Project maintainers have the right and responsibility to remove, edit, or
42
+ reject comments, commits, code, wiki edits, issues, and other contributions
43
+ that are not aligned to this Code of Conduct, or to ban temporarily or
44
+ permanently any contributor for other behaviors that they deem inappropriate,
45
+ threatening, offensive, or harmful.
46
+
47
+ ## Scope
48
+
49
+ This Code of Conduct applies both within project spaces and in public spaces
50
+ when an individual is representing the project or its community. Examples of
51
+ representing a project or community include using an official project e-mail
52
+ address, posting via an official social media account, or acting as an
53
+ appointed representative at an online or offline event. Representation of a
54
+ project may be further defined and clarified by project maintainers.
55
+
56
+ ## Enforcement
57
+
58
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
59
+ reported by contacting the project team at (info at braingourmets dot com).
60
+ All complaints will be reviewed and investigated and will result in a response
61
+ that is deemed necessary and appropriate to the circumstances. The project team
62
+ is obligated to maintain confidentiality with regard to the reporter of an
63
+ incident. Further details of specific enforcement policies may be posted
64
+ separately.
65
+
66
+ Project maintainers who do not follow or enforce the Code of Conduct in good
67
+ faith may face temporary or permanent repercussions as determined by other
68
+ members of the project's leadership.
69
+
70
+ ## Attribution
71
+
72
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
73
+ version 1.4, available at
74
+ [http://contributor-covenant.org/version/1/4/][version].
75
+
76
+ [homepage]: http://contributor-covenant.org
77
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
- gem 'money', '~> 5.1.1'
5
+ gemspec
data/LICENSE CHANGED
@@ -1,20 +1,23 @@
1
+ Licensed under the MIT license:
2
+
3
+ https://opensource.org/licenses/mit-license.php
4
+
1
5
  Copyright (c) 2009 Trond Arve Nordheim
2
6
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
10
13
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
13
16
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # CurrencySelect
2
+
3
+ [![GitHub CI Status](https://github.com/braingourmets/currency_select/workflows/CI/badge.svg?branch=main)](https://github.com/braingourmets/currency_select/actions)
4
+ [![Gem Version](https://badge.fury.io/rb/currency_select.svg)](http://badge.fury.io/rb/currency_select)
5
+
6
+ Adds a currency_select helper to Ruby on Rails projects, allowing you to get
7
+ a HTML select list of available currencies.
8
+
9
+ The list of currencies are provided by the
10
+ [Money gem](https://rubygems.org/gems/money).
11
+
12
+ ## Installation
13
+
14
+ Add the following to your Gemfile:
15
+
16
+ ```ruby
17
+ gem 'currency_select'
18
+ ```
19
+
20
+ ## Example
21
+
22
+ ```ruby
23
+ currency_select('user', 'currency')
24
+ ```
25
+
26
+ ### form_for example
27
+ ```
28
+ <%= f.currency_select(:currency, ["USD", "EUR", "CAD"], {}, {class: "form-control"}) -%>
29
+ ```
30
+
31
+ ## Contributing to this project
32
+
33
+ ### Code of Conduct
34
+
35
+ This project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
36
+ By participating in this project and its community, you are expected to uphold
37
+ this code.
38
+
39
+ ## Maintainers
40
+
41
+ * [Oliver Klee](https://github.com/oliverklee)
data/Rakefile CHANGED
@@ -1,76 +1,19 @@
1
- require "rake"
2
- require "bundler"
3
- require "rake/testtask"
4
- require "rdoc/task"
1
+ # frozen_string_literal: true
5
2
 
6
- # Gemcutter/Jeweler configuration
7
- # -----------------------------------------------------------------------------
8
- begin
9
-
10
- require "jeweler"
11
-
12
- Jeweler::Tasks.new do |gem|
13
-
14
- gem.name = "currency_select"
15
- gem.summary = "Currency Select plugin for Rails"
16
- gem.description = "Adds a currency_select helper to Ruby on Rails projects"
17
- gem.email = "tanordheim@gmail.com"
18
- gem.homepage = "http://github.com/tanordheim/currency_select"
19
- gem.authors = [ "Trond Arve Nordheim" ]
20
- gem.version = File.read('VERSION').chomp
21
-
22
- end
23
-
24
- Jeweler::GemcutterTasks.new
25
-
26
- rescue LoadError
27
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
28
- end
29
-
30
-
31
- # Test setup
32
- # -----------------------------------------------------------------------------
33
- Rake::TestTask.new(:test) do |t|
34
- t.libs << "lib" << "test"
35
- t.ruby_opts << "-rubygems"
36
- t.pattern = "test/**/*_test.rb"
37
- t.verbose = true
38
- end
3
+ require 'rdoc/task'
39
4
 
40
5
  # RDoc setup
41
6
  # ----------------------------------------------------------------------------
42
7
  Rake::RDocTask.new do |rdoc|
43
-
44
- version = File.exists?("VERSION") ? File.read("VERSION") : ""
8
+ version = File.read('VERSION')
45
9
 
46
- rdoc.rdoc_dir = "rdoc"
10
+ rdoc.rdoc_dir = 'rdoc'
47
11
  rdoc.title = "currency_select #{version}"
48
- rdoc.rdoc_files.include("README.rdoc")
49
- rdoc.rdoc_files.include("lib/**/*.rb")
50
-
12
+ rdoc.rdoc_files.include('README.md')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
14
  end
52
15
 
53
- # Rcov setup
54
- # ----------------------------------------------------------------------------
55
- begin
56
-
57
- require "rcov/rcovtask"
58
-
59
- Rcov::RcovTask.new do |test|
60
-
61
- test.libs << "test"
62
- test.pattern = "test/**/*_test.rb"
63
- test.verbose = "true"
64
-
65
- end
66
-
67
- rescue LoadError
68
- task :rcov do
69
- abort "Rcov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
70
- end
16
+ desc 'Runs RuboCop for checking the Ruby files.'
17
+ task :rubocop do
18
+ sh 'rubocop lib/ rails/ spec/ currency_select.gemspec Gemfile Rakefile'
71
19
  end
72
-
73
- # Task setups
74
- # -----------------------------------------------------------------------------
75
- task :test => :check_dependencies
76
- task :default => :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 3.0.0
@@ -1,50 +1,30 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
3
+ version = File.read(File.expand_path('VERSION', __dir__)).strip
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = "currency_select"
8
- s.version = "0.1.4"
6
+ s.name = 'currency_select'
7
+ s.summary = 'Currency select plugin for Rails'
8
+ s.version = version
9
+ s.license = 'MIT'
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Trond Arve Nordheim"]
12
- s.date = "2013-08-05"
13
- s.description = "Adds a currency_select helper to Ruby on Rails projects"
14
- s.email = "tanordheim@gmail.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "currency_select.gemspec",
28
- "lib/currency_select.rb",
29
- "rails/init.rb",
30
- "test/helper.rb",
31
- "test/test_currency_select.rb"
11
+ s.required_ruby_version = '>= 2.5.0'
12
+
13
+ s.homepage = 'https://github.com/braingourmets/currency_select'
14
+ s.authors = ['Trond Arve Nordheim', 'Oliver Klee']
15
+ s.email = 'o.klee@braingourmets.com'
16
+
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
32
20
  ]
33
- s.homepage = "http://github.com/tanordheim/currency_select"
34
- s.require_paths = ["lib"]
35
- s.rubygems_version = "1.8.23"
36
- s.summary = "Currency Select plugin for Rails"
21
+ s.extra_rdoc_files = %w[CHANGELOG.md LICENSE README.md]
37
22
 
38
- if s.respond_to? :specification_version then
39
- s.specification_version = 3
23
+ s.add_runtime_dependency 'actionview', '>= 5.2.0', '< 6.2'
24
+ s.add_runtime_dependency 'money', '~> 6.0'
40
25
 
41
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
- s.add_runtime_dependency(%q<money>, ["~> 5.1.1"])
43
- else
44
- s.add_dependency(%q<money>, ["~> 5.1.1"])
45
- end
46
- else
47
- s.add_dependency(%q<money>, ["~> 5.1.1"])
48
- end
26
+ s.add_development_dependency 'rspec-rails', '~> 4.0.0'
27
+ s.add_development_dependency 'rubocop', '~> 0.82.0'
28
+ s.add_development_dependency 'rubocop-rails', '~> 2.5.2'
29
+ s.add_development_dependency 'rubocop-rspec', '~> 1.38.1'
49
30
  end
50
-
@@ -1,46 +1,87 @@
1
- require "money"
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'money'
4
+
5
+ ##
6
+ # Module for creating currency drop-downs.
7
+ #
3
8
  module CurrencySelect
4
9
  class << self
10
+ ##
11
+ # Money::Currency::table is a hash of this format for each entry:
12
+ # id (lowercase) => {
13
+ # priority: 2,
14
+ # iso_code: "EUR",
15
+ # name: "Euro",
16
+ # symbol: "$",
17
+ # alternate_symbols: [],
18
+ # subunit: "Cent",
19
+ # subunit_to_unit: 100,
20
+ # symbol_first: true,
21
+ # html_entity: "&#x20AC;"
22
+ # decimal_mark: ",",
23
+ # thousands_separator: ".",
24
+ # iso_numeric: "978"
25
+ # smallest_denomination: 1
26
+ # }
27
+ unless const_defined?('CURRENCIES')
28
+ CURRENCIES = Money::Currency.table.inject([]) do |array, (_, currency)|
29
+ array << [
30
+ "#{currency[:name]} - #{currency[:iso_code]}", currency[:iso_code]
31
+ ]
32
+ end
33
+ # sort by the label (not by the ISO code)
34
+ CURRENCIES.sort_by(&:first)
35
+ end
5
36
 
6
- CURRENCIES = Money::Currency::table.inject([]) do |array, (id, currency)|
7
- array << [ "#{currency[:name]} - #{currency[:iso_code]}", id ]
8
- end.sort_by { |currency| currency.first.parameterize } unless const_defined?("CURRENCIES")
9
-
10
- # Returns an array with ISO codes and currency names for <tt>option</tt>
11
- # tags.
37
+ ##
38
+ # Returns a two-dimensional array with ISO codes and currency names for
39
+ # <tt>option</tt> tags.
40
+ #
41
+ # In the outer array, there will be one element for each currency. Each
42
+ # element looks like this, containing a label and the ISO code:
43
+ # ["Afghan Afghani - AFN", "AFN"]
44
+ #
45
+ # @return [Array]
46
+ #
12
47
  def currencies_array
13
48
  CURRENCIES
14
49
  end
15
50
 
16
- # Return an array with ISO codes and currency names for currency ISO codes
51
+ ##
52
+ # Returns an array with ISO codes and currency names for currency ISO codes
17
53
  # passed as an argument
18
54
  # == Example
19
55
  # priority_currencies_array([ "USD", "NOK" ])
20
- # # => [ ['United States Dollar - USD', 'USD' ], ['Norwegian Kroner - NOK', 'NOK'] ]
56
+ # # => [
57
+ # # ['United States Dollar - USD', 'USD' ],
58
+ # # ['Norwegian Kroner - NOK', 'NOK']
59
+ # # ]
60
+ #
61
+ # @return [Array]
62
+ #
21
63
  def priority_currencies_array(currency_codes = [])
22
- currency_codes.flat_map { |code| currencies_array.select { |currency| currency.last.to_s == code }}
64
+ currency_codes.flat_map do |code|
65
+ currencies_array.select { |currency| currency.last.to_s == code }
66
+ end
23
67
  end
24
-
25
68
  end
26
69
  end
27
70
 
28
71
  # CurrencySelect
29
72
  module ActionView
30
73
  module Helpers
74
+ ##
75
+ # Module for the form options.
76
+ #
31
77
  module FormOptionsHelper
32
-
33
78
  # Return select and option tags for the given object and method, using
34
79
  # currency_options_for_select to generate the list of option tags.
35
- def currency_select(object, method, priority_currencies = nil, options = {}, html_options = {})
36
- tag = if defined?(ActionView::Helpers::InstanceTag) &&
37
- ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
38
-
39
- InstanceTag.new(object, method, self, options.delete(:object))
40
- else
41
- CurrencySelectTag.new(object, method, self, options)
42
- end
43
-
80
+ def currency_select(
81
+ object, method, priority_currencies = nil, options = {},
82
+ html_options = {}
83
+ )
84
+ tag = CurrencySelectTag.new(object, method, self, options)
44
85
  tag.to_currency_select_tag(priority_currencies, options, html_options)
45
86
  end
46
87
 
@@ -50,11 +91,15 @@ module ActionView
50
91
  # +priority_currencies+, so that they will be listed above the rest of
51
92
  # the list.
52
93
  def currency_options_for_select(selected = nil, priority_currencies = nil)
53
- currency_options = "".html_safe
94
+ currency_options = ''.html_safe
54
95
 
55
96
  if priority_currencies
56
- currency_options += options_for_select(::CurrencySelect::priority_currencies_array(priority_currencies), selected)
57
- currency_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n".html_safe
97
+ currency_options += options_for_select(
98
+ ::CurrencySelect.priority_currencies_array(priority_currencies),
99
+ selected
100
+ )
101
+ raw = '<option value="" disabled="disabled">-------------</option>'
102
+ currency_options += raw.html_safe + "\n"
58
103
 
59
104
  # prevents selected from being included twice in the HTML which causes
60
105
  # some browsers to select the second selected option (not priority)
@@ -63,35 +108,58 @@ module ActionView
63
108
  end
64
109
 
65
110
  # All the countries included in the country_options output.
66
- return currency_options + options_for_select(::CurrencySelect::currencies_array, selected)
111
+ currency_options + options_for_select(
112
+ ::CurrencySelect.currencies_array, selected
113
+ )
67
114
  end
68
115
  end
69
116
 
117
+ ##
118
+ # Tag.
119
+ #
70
120
  module ToCurrencySelectTag
71
121
  def to_currency_select_tag(priority_currencies, options, html_options)
72
122
  html_options = html_options.stringify_keys
73
123
  add_default_name_and_id(html_options)
74
- value = value(object)
75
- content_tag('select', add_options(currency_options_for_select(value, priority_currencies), options, value), html_options)
124
+ value = if method(:value).arity.zero?
125
+ value()
126
+ else
127
+ value(object)
128
+ end
129
+ content_tag(
130
+ 'select',
131
+ add_options(
132
+ currency_options_for_select(value, priority_currencies),
133
+ options,
134
+ value
135
+ ),
136
+ html_options
137
+ )
76
138
  end
77
139
  end
78
140
 
79
- if defined?(ActionView::Helpers::InstanceTag) &&
80
- ActionView::Helpers::InstanceTag.instance_method(:initialize).arity != 0
81
- class InstanceTag
82
- include ToCurrencySelectTag
83
- end
84
- else
85
- class CurrencySelectTag < Tags::Base
86
- include ToCurrencySelectTag
87
- end
141
+ ##
142
+ # Tag.
143
+ #
144
+ class CurrencySelectTag < Tags::Base
145
+ include ToCurrencySelectTag
88
146
  end
89
147
 
148
+ ##
149
+ # Form builder.
150
+ #
90
151
  class FormBuilder
91
- def currency_select(method, priority_currencies = nil, options = {}, html_options = {})
92
- @template.currency_select(@object_name, method, priority_currencies, options.merge(:object => @object), html_options)
152
+ def currency_select(
153
+ method, priority_currencies = nil, options = {}, html_options = {}
154
+ )
155
+ @template.currency_select(
156
+ @object_name,
157
+ method,
158
+ priority_currencies,
159
+ options.merge(object: @object),
160
+ html_options
161
+ )
93
162
  end
94
163
  end
95
-
96
164
  end
97
165
  end
@@ -1 +1,3 @@
1
- require "currency_select"
1
+ # frozen_string_literal: true
2
+
3
+ require 'currency_select'
metadata CHANGED
@@ -1,74 +1,146 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: currency_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 3.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Trond Arve Nordheim
8
+ - Oliver Klee
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-05 00:00:00.000000000 Z
12
+ date: 2021-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: actionview
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 5.2.0
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '6.2'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: 5.2.0
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.2'
14
34
  - !ruby/object:Gem::Dependency
15
35
  name: money
16
36
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
37
  requirements:
19
- - - ~>
38
+ - - "~>"
20
39
  - !ruby/object:Gem::Version
21
- version: 5.1.1
40
+ version: '6.0'
22
41
  type: :runtime
23
42
  prerelease: false
24
43
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
44
  requirements:
27
- - - ~>
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '6.0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec-rails
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: rubocop
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.82.0
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.82.0
76
+ - !ruby/object:Gem::Dependency
77
+ name: rubocop-rails
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.5.2
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.5.2
90
+ - !ruby/object:Gem::Dependency
91
+ name: rubocop-rspec
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
28
95
  - !ruby/object:Gem::Version
29
- version: 5.1.1
30
- description: Adds a currency_select helper to Ruby on Rails projects
31
- email: tanordheim@gmail.com
96
+ version: 1.38.1
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.38.1
104
+ description:
105
+ email: o.klee@braingourmets.com
32
106
  executables: []
33
107
  extensions: []
34
108
  extra_rdoc_files:
109
+ - CHANGELOG.md
35
110
  - LICENSE
36
- - README.rdoc
111
+ - README.md
37
112
  files:
38
- - .document
113
+ - CHANGELOG.md
114
+ - CODE_OF_CONDUCT.md
39
115
  - Gemfile
40
- - Gemfile.lock
41
116
  - LICENSE
42
- - README.rdoc
117
+ - README.md
43
118
  - Rakefile
44
119
  - VERSION
45
120
  - currency_select.gemspec
46
121
  - lib/currency_select.rb
47
122
  - rails/init.rb
48
- - test/helper.rb
49
- - test/test_currency_select.rb
50
- homepage: http://github.com/tanordheim/currency_select
51
- licenses: []
123
+ homepage: https://github.com/braingourmets/currency_select
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
52
127
  post_install_message:
53
128
  rdoc_options: []
54
129
  require_paths:
55
130
  - lib
56
131
  required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
132
  requirements:
59
- - - ! '>='
133
+ - - ">="
60
134
  - !ruby/object:Gem::Version
61
- version: '0'
135
+ version: 2.5.0
62
136
  required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
137
  requirements:
65
- - - ! '>='
138
+ - - ">="
66
139
  - !ruby/object:Gem::Version
67
140
  version: '0'
68
141
  requirements: []
69
- rubyforge_project:
70
- rubygems_version: 1.8.23
142
+ rubygems_version: 3.2.3
71
143
  signing_key:
72
- specification_version: 3
73
- summary: Currency Select plugin for Rails
144
+ specification_version: 4
145
+ summary: Currency select plugin for Rails
74
146
  test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
@@ -1,12 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- i18n (0.6.4)
5
- money (5.1.1)
6
- i18n (~> 0.6.0)
7
-
8
- PLATFORMS
9
- ruby
10
-
11
- DEPENDENCIES
12
- money (~> 5.1.1)
@@ -1,14 +0,0 @@
1
- = CurrencySelect
2
-
3
- Adds a currency_select helper to Ruby on Rails projects, allowing you to get
4
- a HTML select list of available currencies.
5
-
6
- The list of currencies are provided by the {Money}[http://money.rubyforge.org/] gem.
7
-
8
- = Example
9
-
10
- currency_select("user", "currency")
11
-
12
- == Copyright
13
-
14
- Copyright (c) 2010 Trond Arve Nordheim. See LICENSE for details.
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'currency_select'
8
-
9
- class Test::Unit::TestCase
10
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestCurrencySelect < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end