seq_as_enum 0.2.0 → 0.3.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: 6ed043cc3fc1e665375938158a59ea4f383fdd950c92c9ed1dd83eee62955efd
4
- data.tar.gz: 99db0b6e544984f67a1fb47fcad0a08bcb15f0461b07200b65f6bfd5093b3c79
3
+ metadata.gz: c45de2e91439203353c8e6362ccf4becd6859946609ecc814b09a08045589a43
4
+ data.tar.gz: c034f84fc7e80ad7e0666ebcc82f4ad789a8b7c8f4d9b885412aaa587ca731ff
5
5
  SHA512:
6
- metadata.gz: acc00518b38c8be7670fdc9b1d6ed6ab9e066099a04dd04e1723649ded370269752d8499e7138e81201a310b5d6f9668a691048e1303c7c9f07d48b06a5c8594
7
- data.tar.gz: 1ab81b07529fcd49895fed3a21d57f4d74b118aadfc5a8d008043047278ccbf015c4b9278917f651179a49da4f5736855c896d4887a9374afb576c1246f6b272
6
+ metadata.gz: b2e4836703c9878874a748414fd93d2d393b73644564edee548a0b4c23e7c25987a4b042880f326ad382be88a8107b84bd98a94fe1d46598b29ce3d4d4d39a8d
7
+ data.tar.gz: 76ecfebf9feb146995e34d9fbb1c03eb75214541137af348d4fa2899ad487fbb348657c132a857a2d477c29951d62f83fad2e29b4aa81322b1ccf6c24eeb1aa6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2023-06-06
4
+
5
+ - Allow override constant
6
+
7
+ ## [0.2.0] - 2023-06-06
8
+
3
9
  - Use Struct instead of Data for Ruby 3.1.x and 3.0.x environments.
4
10
 
5
11
  ## [0.1.0] - 2023-06-06
data/CODE_OF_CONDUCT.md CHANGED
@@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when
39
39
 
40
40
  ## Enforcement
41
41
 
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jit@sonicgarden.jp. All complaints will be reviewed and investigated promptly and fairly.
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at JunichiIto. All complaints will be reviewed and investigated promptly and fairly.
43
43
 
44
44
  All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
45
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seq_as_enum (0.1.0)
4
+ seq_as_enum (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -97,7 +97,7 @@ seq_as_enum :Name, :Address, :Phone, prefix: :Col, sep: false
97
97
 
98
98
  ### data_as option
99
99
 
100
- You can get sequence values as Data object instead of constants:
100
+ With `data_as` option, you can get sequence values as Data object instead of constants:
101
101
 
102
102
  ```ruby
103
103
  class AwesomeCsv
@@ -123,7 +123,7 @@ class AwesomeCsv
123
123
  end
124
124
  ```
125
125
 
126
- NOTE: If you use Ruby 3.1.x or 3.0.x, data_as will use Struct instead of Data.
126
+ NOTE: If you're using Ruby 3.1.x or 3.0.x, data_as will use Struct instead of Data.
127
127
 
128
128
  ## Development
129
129
 
@@ -133,7 +133,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
133
133
 
134
134
  ## Contributing
135
135
 
136
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/seq_as_enum. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/seq_as_enum/blob/main/CODE_OF_CONDUCT.md).
136
+ Bug reports and pull requests are welcome on GitHub at https://github.com/JunichiIto/seq_as_enum. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/JunichiIto/seq_as_enum/blob/main/CODE_OF_CONDUCT.md).
137
137
 
138
138
  ## License
139
139
 
@@ -141,4 +141,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
141
141
 
142
142
  ## Code of Conduct
143
143
 
144
- Everyone interacting in the SeqAsEnum project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/seq_as_enum/blob/main/CODE_OF_CONDUCT.md).
144
+ Everyone interacting in the SeqAsEnum project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/JunichiIto/seq_as_enum/blob/main/CODE_OF_CONDUCT.md).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SeqAsEnum
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/seq_as_enum.rb CHANGED
@@ -5,6 +5,8 @@ require_relative "seq_as_enum/version"
5
5
  module SeqAsEnum
6
6
  DEFAULT_SEP = '_'.freeze
7
7
 
8
+ private
9
+
8
10
  def seq_as_enum(*names, init: 0, data_as: nil, prefix: nil, sep: DEFAULT_SEP)
9
11
  raise ArgumentError, 'Cannot use prefix option with data_as option' if prefix && data_as
10
12
  raise ArgumentError, 'Cannot use sep option without prefix option' if sep != DEFAULT_SEP && !prefix
@@ -15,22 +17,15 @@ module SeqAsEnum
15
17
  if data_as
16
18
  class_name = "#{data_as}Data"
17
19
  data_class = const_defined?(:Data) ? Data.define(*names) : Struct.new(*names, keyword_init: true)
18
- const_set!(class_name, data_class)
20
+ const_set(class_name, data_class)
19
21
  data = data_class.new(**key_values)
20
- const_set!(data_as, data)
22
+ const_set(data_as, data)
21
23
  else
22
24
  key_values.each do |name, value|
23
25
  sep = '' unless sep
24
26
  name = "#{prefix}#{sep}#{name}".to_sym if prefix
25
- const_set!(name, value)
27
+ const_set(name, value)
26
28
  end
27
29
  end
28
30
  end
29
-
30
- private
31
-
32
- def const_set!(sym, obj)
33
- raise "already initialized constant: #{self.name}::#{sym}" if const_defined?(sym)
34
- const_set(sym, obj)
35
- end
36
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seq_as_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Junichi Ito