currency_select 0.2.0 → 4.0.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
  SHA256:
3
- metadata.gz: e2471dfa3ccebc2db85ee1a7a2a00056b316b5d7241f405db0b47e6f3fa83913
4
- data.tar.gz: b3808c9060bfeb3fd083abfebdd76ab0e6d9d4c5257b8310459bad7bf0785eb6
3
+ metadata.gz: 6bdd9085a02527f2e1d0bbf0cb877d174f3a3526dff45abf477244f77c4cb834
4
+ data.tar.gz: be45a25e79d6e587393558d5a68a86e4e48eb767f96cf42f5c14d390c2207422
5
5
  SHA512:
6
- metadata.gz: b30f41b0297a3f473827b3c6e0ba80a7cfc9b990225cf2dfe011f2ab5d2a4d377ddfb06fd9f12cc5a5d6cec661dd9160a120192dbeee168f430da1fb3402d3ed
7
- data.tar.gz: f10c333fc00853130c1ac70545f2213898a478eb843c174a0d2edee51568ec31ea79bf27099e462394df94fab7fc73da5869d2a426650c58107b3f00756d03b9
6
+ metadata.gz: 96126a0e82c23fc6c0a9bfbe269ad7f1469bb557464d22d9dbaf8bafe8c210aa6acb3772e638e73cf453a6c34d5820e87491015a63e8f7660412d5b7e15091c5
7
+ data.tar.gz: ebd800afe6b498c9aa9190a7fc31202bda022dcc3fb2f4498c0a40057d8de8bb7a6122b0c444f8a2955abe84efb2a4c186d4511008fa0139bf2528df84ee2091
data/CHANGELOG.md CHANGED
@@ -1,29 +1,97 @@
1
1
  # currency_select change log
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
- This project adheres to [Semantic Versioning](http://semver.org/).
5
-
4
+ This project adheres to [Semantic Versioning](https://semver.org/).
6
5
 
7
6
  ## x.y.z (unreleased)
8
7
 
9
8
  ### Added
10
9
 
11
-
12
10
  ### Changed
13
11
 
14
-
15
12
  ### Deprecated
16
13
 
14
+ ### Removed
15
+
16
+ ### Fixed
17
+
18
+ ### Security
19
+
20
+ ## 4.0.0
21
+
22
+ ### Added
23
+ - Add support for Rails 7.0 (#96)
24
+
25
+ ### Removed
26
+ - Drop support for Ruby 2.5 (#90)
27
+
28
+ ## 3.0.0
29
+
30
+ ### Added
31
+ - Add automatic gem release (#86, #88)
32
+ - Support Ruby 3 (#81)
33
+ - Add support for Rails 6.1 (#78, #79, #83)
34
+ - Check the code with RuboCop (#72)
35
+ - Add support for Ruby 2.7 (#66)
36
+
37
+ ### Changed
38
+ - Switch the CI from Travis to GitHub Actions (#80, #85)
39
+ - Upgrade RSpec and RSpec-Rails (#71)
40
+ - Update the Ruby versions on Travis CI (#68)
17
41
 
18
42
  ### Removed
43
+ - Drop support for Ruby 2.4 (#70)
44
+ - Drop support for Rails < 5.2 (#65)
45
+
46
+ ### Fixed
47
+ - Fix some RuboCop warnings (#73)
48
+ - Fix warnings in the `.travis.yml` (#67, #69)
19
49
 
50
+ ## 2.0.0
51
+
52
+ ### Added
53
+ - Add support for Rails 6.0
54
+ ([#60](https://github.com/braingourmets/currency_select/pull/60))
55
+ - Officially support Rails 5.2
56
+ ([#51](https://github.com/braingourmets/currency_select/pull/51))
57
+ - Add Ruby 2.5.1 to the Travis build matrix
58
+ ([#49](https://github.com/braingourmets/currency_select/pull/49))
59
+
60
+ ### Removed
61
+ - Drop support for Rails < 5.1
62
+ ([#62](https://github.com/braingourmets/currency_select/pull/62))
63
+ - Drop support for Ruby < 2.4
64
+ ([#61](https://github.com/braingourmets/currency_select/pull/61))
65
+ - Drop support for Ruby < 2.3
66
+ ([#48](https://github.com/braingourmets/currency_select/pull/48))
20
67
 
21
68
  ### Fixed
69
+ - Add version to the requirements in the gemspec file
70
+ ([#53](https://github.com/braingourmets/currency_select/pull/53))
71
+ - Fix file names references from the gemspec file
72
+ ([#52](https://github.com/braingourmets/currency_select/pull/52))
73
+ - Fix value call on Rails 5.2
74
+ ([#47](https://github.com/braingourmets/currency_select/pull/47))
22
75
 
76
+ ## 1.0.0
23
77
 
24
- ### Security
78
+ ### Added
79
+ - Officially support Rails 5.2
80
+ ([#51](https://github.com/braingourmets/currency_select/pull/51))
81
+ - Add Ruby 2.5.1 to the Travis build matrix
82
+ ([#49](https://github.com/braingourmets/currency_select/pull/49))
25
83
 
84
+ ### Removed
85
+ - Drop support for Ruby < 2.3
86
+ ([#48](https://github.com/braingourmets/currency_select/pull/48))
26
87
 
88
+ ### Fixed
89
+ - Add version to the requirements in the gemspec file
90
+ ([#53](https://github.com/braingourmets/currency_select/pull/53))
91
+ - Fix file names references from the gemspec file
92
+ ([#52](https://github.com/braingourmets/currency_select/pull/52))
93
+ - Fix value call on Rails 5.2
94
+ ([#47](https://github.com/braingourmets/currency_select/pull/47))
27
95
 
28
96
  ## 0.2.0
29
97
 
@@ -33,18 +101,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
33
101
  - Add a code of conduct
34
102
  ([#25](https://github.com/braingourmets/currency_select/pull/25))
35
103
 
36
-
37
104
  ### Changed
38
105
  - Mark all Ruby files as frozen_string_literal: true
39
106
  ([#31](https://github.com/braingourmets/currency_select/pull/31))
40
107
 
41
-
42
108
  ### Deprecated
43
109
  - Support for Rails < 5.0.0 will be removed in version 2.0.0.
44
110
  - Support for Rails < 4.2.0 will be removed in version 1.0.0.
45
- - Support for Ruby < 2.2.2 will be removed in version 2.0.0.
46
- - Support for Ruby < 2.0.0 will be removed in version 1.0.0.
47
-
111
+ - Support for Ruby < 2.3.0 will be removed in version 1.0.0.
48
112
 
49
113
  ### Removed
50
114
  - Remove pre-Rails-4.0-specific code
@@ -52,7 +116,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
52
116
  - Drop Jeweler
53
117
  ([#28](https://github.com/braingourmets/currency_select/pull/28))
54
118
 
55
-
56
119
  ### Fixed
57
120
  - Add ActionView as explicit dependency
58
121
  ([#34](https://github.com/braingourmets/currency_select/pull/34))
@@ -60,7 +123,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
60
123
  ([#27](https://github.com/braingourmets/currency_select/pull/27))
61
124
  - Use ISO codes as select values, not the IDs
62
125
  ([#24](https://github.com/braingourmets/currency_select/pull/24))
63
- - Fix the the Gemfile
126
+ - Fix the Gemfile
64
127
  ([#19](https://github.com/braingourmets/currency_select/pull/19))
65
128
  - Fix the order of name attribute and ID in the specs
66
129
  ([#18](https://github.com/braingourmets/currency_select/pull/18))
data/README.md CHANGED
@@ -1,26 +1,32 @@
1
1
  # CurrencySelect
2
2
 
3
- [![Build Status](https://travis-ci.org/braingourmets/currency_select.svg?branch=master)](https://travis-ci.org/braingourmets/currency_select)
3
+ [![GitHub CI Status](https://github.com/braingourmets/currency_select/workflows/CI/badge.svg?branch=main)](https://github.com/braingourmets/currency_select/actions)
4
4
  [![Gem Version](https://badge.fury.io/rb/currency_select.svg)](http://badge.fury.io/rb/currency_select)
5
5
 
6
6
  Adds a currency_select helper to Ruby on Rails projects, allowing you to get
7
7
  a HTML select list of available currencies.
8
8
 
9
- The list of currencies are provided by the [Money](http://money.rubyforge.org/)
10
- gem.
11
-
9
+ The list of currencies are provided by the
10
+ [Money gem](https://rubygems.org/gems/money).
12
11
 
13
12
  ## Installation
14
13
 
15
14
  Add the following to your Gemfile:
16
15
 
17
- gem 'currency_select'
18
-
16
+ ```ruby
17
+ gem 'currency_select'
18
+ ```
19
19
 
20
20
  ## Example
21
21
 
22
- currency_select("user", "currency")
22
+ ```ruby
23
+ currency_select('user', 'currency')
24
+ ```
23
25
 
26
+ ### form_for example
27
+ ```
28
+ <%= f.currency_select(:currency, ["USD", "EUR", "CAD"], {}, {class: "form-control"}) -%>
29
+ ```
24
30
 
25
31
  ## Contributing to this project
26
32
 
@@ -30,7 +36,6 @@ This project adheres to a [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
30
36
  By participating in this project and its community, you are expected to uphold
31
37
  this code.
32
38
 
33
-
34
39
  ## Maintainers
35
40
 
36
41
  * [Oliver Klee](https://github.com/oliverklee)
data/Rakefile CHANGED
@@ -12,3 +12,8 @@ Rake::RDocTask.new do |rdoc|
12
12
  rdoc.rdoc_files.include('README.md')
13
13
  rdoc.rdoc_files.include('lib/**/*.rb')
14
14
  end
15
+
16
+ desc 'Runs RuboCop for checking the Ruby files.'
17
+ task :rubocop do
18
+ sh 'rubocop lib/ rails/ spec/ currency_select.gemspec Gemfile Rakefile'
19
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 4.0.0
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- version = File.read(File.expand_path('../VERSION', __FILE__)).strip
3
+ version = File.read(File.expand_path('VERSION', __dir__)).strip
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'currency_select'
@@ -8,14 +8,23 @@ Gem::Specification.new do |s|
8
8
  s.version = version
9
9
  s.license = 'MIT'
10
10
 
11
+ s.required_ruby_version = '>= 2.6.0'
12
+
11
13
  s.homepage = 'https://github.com/braingourmets/currency_select'
12
14
  s.authors = ['Trond Arve Nordheim', 'Oliver Klee']
13
15
  s.email = 'o.klee@braingourmets.com'
14
16
 
15
- s.files = %w(lib/currency_select.rb rails/init.rb CHANGELOG.md CODE_OF_CONDUCT.md currency_select.gemspec Gemfile LICENSE Rakefile README.md VERSION)
16
- s.extra_rdoc_files = %w(CHANGELOG.md LICENSE README.md)
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
20
+ ]
21
+ s.extra_rdoc_files = %w[CHANGELOG.md LICENSE README.md]
22
+
23
+ s.add_runtime_dependency 'actionview', '>= 5.2.0', '< 7.1'
24
+ s.add_runtime_dependency 'money', '~> 6.0'
17
25
 
18
- s.add_runtime_dependency 'actionview'
19
- s.add_runtime_dependency 'money'
20
- s.add_development_dependency 'rspec-rails'
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'
21
30
  end
@@ -2,6 +2,9 @@
2
2
 
3
3
  require 'money'
4
4
 
5
+ ##
6
+ # Module for creating currency drop-downs.
7
+ #
5
8
  module CurrencySelect
6
9
  class << self
7
10
  ##
@@ -10,7 +13,7 @@ module CurrencySelect
10
13
  # priority: 2,
11
14
  # iso_code: "EUR",
12
15
  # name: "Euro",
13
- # symbol: "",
16
+ # symbol: "$",
14
17
  # alternate_symbols: [],
15
18
  # subunit: "Cent",
16
19
  # subunit_to_unit: 100,
@@ -50,12 +53,17 @@ module CurrencySelect
50
53
  # passed as an argument
51
54
  # == Example
52
55
  # priority_currencies_array([ "USD", "NOK" ])
53
- # # => [ ['United States Dollar - USD', 'USD' ], ['Norwegian Kroner - NOK', 'NOK'] ]
56
+ # # => [
57
+ # # ['United States Dollar - USD', 'USD' ],
58
+ # # ['Norwegian Kroner - NOK', 'NOK']
59
+ # # ]
54
60
  #
55
61
  # @return [Array]
56
62
  #
57
63
  def priority_currencies_array(currency_codes = [])
58
- 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
59
67
  end
60
68
  end
61
69
  end
@@ -63,10 +71,16 @@ end
63
71
  # CurrencySelect
64
72
  module ActionView
65
73
  module Helpers
74
+ ##
75
+ # Module for the form options.
76
+ #
66
77
  module FormOptionsHelper
67
78
  # Return select and option tags for the given object and method, using
68
79
  # currency_options_for_select to generate the list of option tags.
69
- def currency_select(object, method, priority_currencies = nil, options = {}, html_options = {})
80
+ def currency_select(
81
+ object, method, priority_currencies = nil, options = {},
82
+ html_options = {}
83
+ )
70
84
  tag = CurrencySelectTag.new(object, method, self, options)
71
85
  tag.to_currency_select_tag(priority_currencies, options, html_options)
72
86
  end
@@ -80,8 +94,12 @@ module ActionView
80
94
  currency_options = ''.html_safe
81
95
 
82
96
  if priority_currencies
83
- currency_options += options_for_select(::CurrencySelect::priority_currencies_array(priority_currencies), selected)
84
- 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"
85
103
 
86
104
  # prevents selected from being included twice in the HTML which causes
87
105
  # some browsers to select the second selected option (not priority)
@@ -90,27 +108,58 @@ module ActionView
90
108
  end
91
109
 
92
110
  # All the countries included in the country_options output.
93
- return currency_options + options_for_select(::CurrencySelect::currencies_array, selected)
111
+ currency_options + options_for_select(
112
+ ::CurrencySelect.currencies_array, selected
113
+ )
94
114
  end
95
115
  end
96
116
 
117
+ ##
118
+ # Tag.
119
+ #
97
120
  module ToCurrencySelectTag
98
121
  def to_currency_select_tag(priority_currencies, options, html_options)
99
122
  html_options = html_options.stringify_keys
100
123
  add_default_name_and_id(html_options)
101
- value = value(object)
102
- 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
+ )
103
138
  end
104
139
  end
105
140
 
141
+ ##
142
+ # Tag.
143
+ #
106
144
  class CurrencySelectTag < Tags::Base
107
145
  include ToCurrencySelectTag
108
146
  end
109
147
 
148
+ ##
149
+ # Form builder.
150
+ #
110
151
  class FormBuilder
111
- def currency_select(method, priority_currencies = nil, options = {}, html_options = {})
112
- @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
+ )
113
162
  end
114
163
  end
115
164
  end
116
- end
165
+ 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: 0.2.0
4
+ version: 4.0.0
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: 2018-09-15 00:00:00.000000000 Z
12
+ date: 2021-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionview
@@ -17,42 +17,90 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: 5.2.0
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '7.1'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
27
- version: '0'
30
+ version: 5.2.0
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '7.1'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: money
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
- - - ">="
38
+ - - "~>"
33
39
  - !ruby/object:Gem::Version
34
- version: '0'
40
+ version: '6.0'
35
41
  type: :runtime
36
42
  prerelease: false
37
43
  version_requirements: !ruby/object:Gem::Requirement
38
44
  requirements:
39
- - - ">="
45
+ - - "~>"
40
46
  - !ruby/object:Gem::Version
41
- version: '0'
47
+ version: '6.0'
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: rspec-rails
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
- - - ">="
52
+ - - "~>"
47
53
  - !ruby/object:Gem::Version
48
- version: '0'
54
+ version: 4.0.0
49
55
  type: :development
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
52
58
  requirements:
53
- - - ">="
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
+ - - "~>"
54
81
  - !ruby/object:Gem::Version
55
- version: '0'
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
+ - - "~>"
95
+ - !ruby/object:Gem::Version
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
56
104
  description:
57
105
  email: o.klee@braingourmets.com
58
106
  executables: []
@@ -84,15 +132,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
132
  requirements:
85
133
  - - ">="
86
134
  - !ruby/object:Gem::Version
87
- version: '0'
135
+ version: 2.6.0
88
136
  required_rubygems_version: !ruby/object:Gem::Requirement
89
137
  requirements:
90
138
  - - ">="
91
139
  - !ruby/object:Gem::Version
92
140
  version: '0'
93
141
  requirements: []
94
- rubyforge_project:
95
- rubygems_version: 2.7.7
142
+ rubygems_version: 3.2.32
96
143
  signing_key:
97
144
  specification_version: 4
98
145
  summary: Currency select plugin for Rails