typesafe_enum 0.2.2 → 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: bb07ad036d64d6c64c976b86db50a4f94a33c85fb18410077551282ad2d32f51
4
- data.tar.gz: 0c9a2342fa1163a2475fe0c7bb7656c333e678a66ae5be47b6beed9934cebd17
3
+ metadata.gz: e86150c4dbad18dc3b34bc33f36af102c1f6a971de91e1fdd77eda854f00ff88
4
+ data.tar.gz: 5e05fae89f1428427afff174ceaf42336e2031851d1428a58b9cf98adef42ba1
5
5
  SHA512:
6
- metadata.gz: 8a39483acf17f3a706dd61caa5cebd6c269789a23baf8b36ce0c7f3e4a870d3e0dc15b47753e268505417e00d769dea6d1e1719a9e5570fba5af9f8329da37ea
7
- data.tar.gz: b02640de3559f49920ae311c6cd2b68411a78bd38763289cb87726c3c4989d0ed49c98a1f2d0450d9a8ef79b0782cca1f62968d61ea83ce61deff1978b24e267
6
+ metadata.gz: 866a544ab2935cd10e40fc44ee9f965ee08f21fcfed13a0412eaccbe09157b93a5a3df067a1c25b2c75d676c7d2dcbcccfe25141de708c77f32230d73cfca93d
7
+ data.tar.gz: ba826a728d1e2bed282df2f9d550ea7edd780f45f07c1bcdf6967710de52edd8898ec512281f48d36ba8dfb6d781655e8de7bd5e2adb16473dccf98f8c87416f
data/.gitignore CHANGED
@@ -1,50 +1,227 @@
1
- # IDEA
1
+ ############################################################
2
+ # Custom ignores
2
3
 
3
- .idea
4
- /out/
4
+ # apps need Gemfile.lock in source control, gems don't
5
+ /Gemfile.lock
5
6
 
6
- # Ruby defaults
7
+ # https://youtrack.jetbrains.com/issue/IDEA-233049
8
+ .idea/$CACHE_FILE$
7
9
 
8
- /.bundle/
9
- /.yardoc
10
- /Gemfile.lock
11
- /_yardoc/
10
+ ############################################################
11
+ # Generated ignores
12
+
13
+ #### joe made this: http://goel.io/joe
14
+
15
+ #### ruby ####
16
+ *.gem
17
+ *.rbc
18
+ /.config
12
19
  /coverage/
13
- /doc/
20
+ /InstalledFiles
14
21
  /pkg/
15
22
  /spec/reports/
23
+ /spec/examples.txt
24
+ /test/tmp/
25
+ /test/version_tmp/
16
26
  /tmp/
17
- *.bundle
18
- *.so
19
- *.o
20
- *.a
21
- mkmf.log
22
27
 
23
- # Build output
24
- *.gem
28
+ # Used by dotenv library to load environment variables.
29
+ # .env
30
+
31
+ # Ignore Byebug command history file.
32
+ .byebug_history
25
33
 
26
- # Database
34
+ ## Specific to RubyMotion:
35
+ .dat*
36
+ .repl_history
37
+ build/
38
+ *.bridgesupport
39
+ build-iPhoneOS/
40
+ build-iPhoneSimulator/
27
41
 
28
- db/*.sqlite3
42
+ ## Specific to RubyMotion (use of CocoaPods):
43
+ #
44
+ # We recommend against adding the Pods directory to your .gitignore. However
45
+ # you should judge for yourself, the pros and cons are mentioned at:
46
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
47
+ #
48
+ # vendor/Pods/
29
49
 
30
- # Logs
50
+ ## Documentation cache and generated files:
51
+ /.yardoc/
52
+ /_yardoc/
53
+ /doc/
54
+ /rdoc/
31
55
 
32
- /log/
56
+ ## Environment normalization:
57
+ /.bundle/
58
+ /vendor/bundle
59
+ /lib/bundler/man/
33
60
 
34
- # IntellJ
61
+ # for a library or gem, you might want to ignore these files since the code is
62
+ # intended to run in multiple environments; otherwise, check them in:
63
+ # Gemfile.lock
64
+ # .ruby-version
65
+ # .ruby-gemset
35
66
 
36
- *.iml
37
- *.ipr
67
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
68
+ .rvmrc
69
+
70
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
71
+ # .rubocop-https?--*
72
+
73
+
74
+ #### jetbrains ####
75
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
76
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
77
+
78
+ # User-specific stuff
79
+ .idea/**/workspace.xml
80
+ .idea/**/tasks.xml
81
+ .idea/**/usage.statistics.xml
82
+ .idea/**/dictionaries
83
+ .idea/**/shelf
84
+
85
+ # Generated files
86
+ .idea/**/contentModel.xml
87
+
88
+ # Sensitive or high-churn files
89
+ .idea/**/dataSources/
90
+ .idea/**/dataSources.ids
91
+ .idea/**/dataSources.local.xml
92
+ .idea/**/sqlDataSources.xml
93
+ .idea/**/dynamic.xml
94
+ .idea/**/uiDesigner.xml
95
+ .idea/**/dbnavigator.xml
96
+
97
+ # Gradle
98
+ .idea/**/gradle.xml
99
+ .idea/**/libraries
100
+
101
+ # Gradle and Maven with auto-import
102
+ # When using Gradle or Maven with auto-import, you should exclude module files,
103
+ # since they will be recreated, and may cause churn. Uncomment if using
104
+ # auto-import.
105
+ # .idea/artifacts
106
+ # .idea/compiler.xml
107
+ # .idea/jarRepositories.xml
108
+ # .idea/modules.xml
109
+ # .idea/*.iml
110
+ # .idea/modules
111
+ # *.iml
112
+ # *.ipr
113
+
114
+ # CMake
115
+ cmake-build-*/
116
+
117
+ # Mongo Explorer plugin
118
+ .idea/**/mongoSettings.xml
119
+
120
+ # File-based project format
38
121
  *.iws
39
- *.ids
40
- .rakeTasks
41
122
 
42
- # Emacs
123
+ # IntelliJ
124
+ out/
125
+
126
+ # mpeltonen/sbt-idea plugin
127
+ .idea_modules/
43
128
 
129
+ # JIRA plugin
130
+ atlassian-ide-plugin.xml
131
+
132
+ # Cursive Clojure plugin
133
+ .idea/replstate.xml
134
+
135
+ # Crashlytics plugin (for Android Studio and IntelliJ)
136
+ com_crashlytics_export_strings.xml
137
+ crashlytics.properties
138
+ crashlytics-build.properties
139
+ fabric.properties
140
+
141
+ # Editor-based Rest Client
142
+ .idea/httpRequests
143
+
144
+ # Android studio 3.1+ serialized cache file
145
+ .idea/caches/build_file_checksums.ser
146
+
147
+
148
+ #### emacs ####
149
+ # -*- mode: gitignore; -*-
44
150
  *~
45
- \#*
46
- .#*
151
+ \#*\#
152
+ /.emacs.desktop
153
+ /.emacs.desktop.lock
154
+ *.elc
155
+ auto-save-list
156
+ tramp
157
+ .\#*
158
+
159
+ # Org-mode
160
+ .org-id-locations
161
+ *_archive
162
+
163
+ # flymake-mode
164
+ *_flymake.*
165
+
166
+ # eshell files
167
+ /eshell/history
168
+ /eshell/lastdir
169
+
170
+ # elpa packages
171
+ /elpa/
172
+
173
+ # reftex files
174
+ *.rel
175
+
176
+ # AUCTeX auto folder
177
+ /auto/
47
178
 
48
- # Mac OS
179
+ # cask packages
180
+ .cask/
181
+ dist/
49
182
 
183
+ # Flycheck
184
+ flycheck_*.el
185
+
186
+ # server auth directory
187
+ /server/
188
+
189
+ # projectiles files
190
+ .projectile
191
+
192
+ # directory configuration
193
+ .dir-locals.el
194
+
195
+ # network security
196
+ /network-security.data
197
+
198
+
199
+
200
+ #### macos ####
201
+ # General
50
202
  .DS_Store
203
+ .AppleDouble
204
+ .LSOverride
205
+
206
+ # Icon must end with two \r
207
+ Icon
208
+
209
+
210
+ # Thumbnails
211
+ ._*
212
+
213
+ # Files that might appear in the root of a volume
214
+ .DocumentRevisions-V100
215
+ .fseventsd
216
+ .Spotlight-V100
217
+ .TemporaryItems
218
+ .Trashes
219
+ .VolumeIcon.icns
220
+ .com.apple.timemachine.donotpresent
221
+
222
+ # Directories potentially created on remote AFP share
223
+ .AppleDB
224
+ .AppleDesktop
225
+ Network Trash Folder
226
+ Temporary Items
227
+ .apdisk
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Run all unit tests with coverage" fullCmd="coverage" taksId="coverage" /><RakeTask description="Run unit tests, check test coverage, run acceptance tests, check code style" fullCmd="default" taksId="default" /><RakeTask description="Run RuboCop" fullCmd="rubocop" taksId="rubocop" /><RakeGroup description="" fullCmd="" taksId="rubocop"><RakeTask description="Auto-correct RuboCop offenses" fullCmd="rubocop:auto_correct" taksId="auto_correct" /></RakeGroup><RakeTask description="Run all tests" fullCmd="spec" taksId="spec" /><RakeGroup description="" fullCmd="" taksId="spec"><RakeTask description="Run all unit tests" fullCmd="spec:unit" taksId="unit" /><RakeTask description="" fullCmd="spec:all" taksId="all" /></RakeGroup><RakeTask description="List TODOs (from spec/todo.rb)" fullCmd="todo" taksId="todo" /></RakeGroup></Settings>
@@ -0,0 +1,45 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <Properties>
4
+ <option name="KEEP_BLANK_LINES" value="true" />
5
+ </Properties>
6
+ <Python>
7
+ <option name="DICT_NEW_LINE_AFTER_LEFT_BRACE" value="true" />
8
+ <option name="DICT_NEW_LINE_BEFORE_RIGHT_BRACE" value="true" />
9
+ </Python>
10
+ <Shell_Script>
11
+ <option name="REDIRECT_FOLLOWED_BY_SPACE" value="true" />
12
+ </Shell_Script>
13
+ <codeStyleSettings language="Groovy">
14
+ <indentOptions>
15
+ <option name="INDENT_SIZE" value="2" />
16
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
17
+ <option name="TAB_SIZE" value="2" />
18
+ </indentOptions>
19
+ </codeStyleSettings>
20
+ <codeStyleSettings language="HTML">
21
+ <option name="RIGHT_MARGIN" value="200" />
22
+ <indentOptions>
23
+ <option name="INDENT_SIZE" value="2" />
24
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
25
+ <option name="TAB_SIZE" value="2" />
26
+ </indentOptions>
27
+ </codeStyleSettings>
28
+ <codeStyleSettings language="JAVA">
29
+ <option name="IF_BRACE_FORCE" value="3" />
30
+ <option name="DOWHILE_BRACE_FORCE" value="3" />
31
+ <option name="WHILE_BRACE_FORCE" value="3" />
32
+ <option name="FOR_BRACE_FORCE" value="3" />
33
+ <indentOptions>
34
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
35
+ </indentOptions>
36
+ </codeStyleSettings>
37
+ <codeStyleSettings language="ruby">
38
+ <option name="SPACE_WITHIN_BRACES" value="true" />
39
+ <indentOptions>
40
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
41
+ <option name="USE_RELATIVE_INDENTS" value="false" />
42
+ </indentOptions>
43
+ </codeStyleSettings>
44
+ </code_scheme>
45
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GoImports">
4
+ <option name="optimizeImportsOnTheFly" value="false" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,17 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="GoNameStartsWithPackageName" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
5
+ <inspection_tool class="GoSnakeCaseUsage" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
6
+ <inspection_tool class="GoUnusedGlobalVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
7
+ <inspection_tool class="GoUnusedVariable" enabled="true" level="WARNING" enabled_by_default="true" />
8
+ <inspection_tool class="GrazieInspection" enabled="false" level="TYPO" enabled_by_default="false" />
9
+ <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
10
+ <inspection_tool class="RubyStringKeysInHashInspection" enabled="true" level="INFORMATION" enabled_by_default="true" />
11
+ <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
12
+ <option name="processCode" value="true" />
13
+ <option name="processLiterals" value="true" />
14
+ <option name="processComments" value="true" />
15
+ </inspection_tool>
16
+ </profile>
17
+ </component>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="13" project-jdk-type="JavaSDK">
7
+ <output url="file://$PROJECT_DIR$/out" />
8
+ </component>
9
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/typesafe_enum.iml" filepath="$PROJECT_DIR$/.idea/typesafe_enum.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="jdk" jdkName="RVM: ruby-2.6.6" jdkType="RUBY_SDK" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ <orderEntry type="library" scope="PROVIDED" name="ansi (v1.5.0, RVM: ruby-2.6.6) [gem]" level="application" />
9
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.1, RVM: ruby-2.6.6) [gem]" level="application" />
10
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.6.6) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.6) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="docile (v1.3.2, RVM: ruby-2.6.6) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.2, RVM: ruby-2.6.6) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="parser (v2.7.2.0, RVM: ruby-2.6.6) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.6.6) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="rake (v12.3.3, RVM: ruby-2.6.6) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v1.8.2, RVM: ruby-2.6.6) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.6.6) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.6.6) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.1, RVM: ruby-2.6.6) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.1, RVM: ruby-2.6.6) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.6.6) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.2, RVM: ruby-2.6.6) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v0.91.0, RVM: ruby-2.6.6) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v0.8.0, RVM: ruby-2.6.6) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.6.6) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="simplecov (v0.18.5, RVM: ruby-2.6.6) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-console (v0.7.2, RVM: ruby-2.6.6) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.2, RVM: ruby-2.6.6) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="terminal-table (v1.8.0, RVM: ruby-2.6.6) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.7.0, RVM: ruby-2.6.6) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="yard (v0.9.24, RVM: ruby-2.6.6) [gem]" level="application" />
33
+ </component>
34
+ <component name="RModuleSettingsStorage">
35
+ <LOAD_PATH number="2" string0="$MODULE_DIR$/lib" string1="$MODULE_DIR$/spec" />
36
+ <I18N_FOLDERS number="0" />
37
+ </component>
38
+ </module>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -1,8 +1,3 @@
1
- # Disable compact style check for example.rb
2
- Style/ClassAndModuleChildren:
3
- Exclude:
4
- - 'example.rb'
5
-
6
1
  # Allow one line around block body (Layout/EmptyLines will still disallow two or more)
7
2
  Layout/EmptyLinesAroundBlockBody:
8
3
  Enabled: false
@@ -27,11 +22,6 @@ Layout/MultilineMethodCallIndentation:
27
22
  Layout/MultilineOperationIndentation:
28
23
  Enabled: false
29
24
 
30
- # Just because something looks like an accessor doesn't mean it is one
31
- Naming/PredicateName:
32
- Exclude:
33
- - 'app/controllers/application_controller.rb'
34
-
35
25
  # Confusing and weird
36
26
  Naming/VariableNumber:
37
27
  Enabled: False
@@ -60,18 +50,6 @@ Style/CommentedKeyword:
60
50
  Style/Documentation:
61
51
  Enabled: false
62
52
 
63
- # Added in RuboCop 0.80
64
- Style/HashEachMethods:
65
- Enabled: true
66
-
67
- # Added in RuboCop 0.80
68
- Style/HashTransformKeys:
69
- Enabled: true
70
-
71
- # Added in RuboCop 0.80
72
- Style/HashTransformValues:
73
- Enabled: true
74
-
75
53
  # Adding more line noise to format strings will not improve them
76
54
  Style/FormatStringToken:
77
55
  Enabled: false
@@ -95,3 +73,187 @@ Style/Lambda:
95
73
  # Unclear why it's a good idea to give parameters semantically meaningless names
96
74
  Style/SingleLineBlockParams:
97
75
  Enabled: false
76
+
77
+ ############################################################
78
+ # Added in RuboCop 0.80
79
+
80
+ Style/HashEachMethods:
81
+ Enabled: true
82
+
83
+ Style/HashTransformKeys:
84
+ Enabled: true
85
+
86
+ Style/HashTransformValues:
87
+ Enabled: true
88
+
89
+ ############################################################
90
+ # Added in RuboCop 0.81
91
+
92
+ Lint/StructNewOverride:
93
+ Enabled: true
94
+
95
+ Lint/RaiseException:
96
+ Enabled: true
97
+
98
+ ############################################################
99
+ # Added in RuboCop 0.82
100
+
101
+ Layout/SpaceAroundMethodCallOperator:
102
+ Enabled: true
103
+
104
+ Style/ExponentialNotation:
105
+ Enabled: false
106
+
107
+ ############################################################
108
+ # Added in RuboCop 0.83
109
+
110
+ Layout/EmptyLinesAroundAttributeAccessor:
111
+ Enabled: true
112
+
113
+ Style/SlicingWithRange:
114
+ Enabled: true
115
+
116
+ ############################################################
117
+ # Added in RuboCop 0.84
118
+
119
+ Lint/DeprecatedOpenSSLConstant:
120
+ Enabled: true
121
+
122
+ ############################################################
123
+ # Added in RuboCop 0.85
124
+
125
+ Lint/MixedRegexpCaptureTypes:
126
+ Enabled: true
127
+
128
+ Style/RedundantRegexpEscape:
129
+ Enabled: true
130
+
131
+ Style/RedundantRegexpCharacterClass:
132
+ Enabled: true
133
+
134
+ ############################################################
135
+ # Added in Rubocop 0.86
136
+
137
+ Style/RedundantFetchBlock:
138
+ Enabled: true
139
+
140
+ ############################################################
141
+ # Added in Rubocop 0.87
142
+
143
+ # Sometimes we separate things for a reason
144
+ Style/AccessorGrouping:
145
+ Enabled: false
146
+
147
+ Style/BisectedAttrAccessor:
148
+ Enabled: true
149
+
150
+ Style/RedundantAssignment:
151
+ Enabled: true
152
+
153
+ ############################################################
154
+ # Added in Rubocop 0.88
155
+
156
+ Lint/DuplicateElsifCondition:
157
+ Enabled: true
158
+
159
+ Style/ArrayCoercion:
160
+ Enabled: true
161
+
162
+ Style/CaseLikeIf:
163
+ Enabled: true
164
+
165
+ Style/HashAsLastArrayItem:
166
+ Enabled: true
167
+
168
+ Style/HashLikeCase:
169
+ Enabled: true
170
+
171
+ Style/RedundantFileExtensionInRequire:
172
+ Enabled: true
173
+
174
+ ############################################################
175
+ # Added in Rubocop 0.89
176
+
177
+ Lint/BinaryOperatorWithIdenticalOperands:
178
+ Enabled: true
179
+
180
+ Lint/DuplicateRescueException:
181
+ Enabled: true
182
+
183
+ Lint/EmptyConditionalBody:
184
+ Enabled: true
185
+
186
+ Lint/FloatComparison:
187
+ Enabled: true
188
+
189
+ Lint/MissingSuper:
190
+ Enabled: true
191
+
192
+ Lint/OutOfRangeRegexpRef:
193
+ Enabled: true
194
+
195
+ Lint/SelfAssignment:
196
+ Enabled: true
197
+
198
+ Lint/TopLevelReturnWithArgument:
199
+ Enabled: true
200
+
201
+ Lint/UnreachableLoop:
202
+ Enabled: true
203
+
204
+ Style/ExplicitBlockArgument:
205
+ Enabled: true
206
+
207
+ Style/GlobalStdStream:
208
+ Enabled: true
209
+
210
+ Style/OptionalBooleanParameter:
211
+ Enabled: true
212
+
213
+ Style/SingleArgumentDig:
214
+ Enabled: true
215
+
216
+ Style/SoleNestedConditional:
217
+ Enabled: true
218
+
219
+ Style/StringConcatenation:
220
+ Enabled: true
221
+
222
+ ############################################################
223
+ # Added in Rubocop 0.90
224
+
225
+ Lint/DuplicateRequire:
226
+ Enabled: true
227
+
228
+ Lint/EmptyFile:
229
+ Enabled: true
230
+
231
+ Lint/TrailingCommaInAttributeDeclaration:
232
+ Enabled: true
233
+
234
+ Lint/UselessMethodDefinition:
235
+ Enabled: true
236
+
237
+ Style/CombinableLoops:
238
+ Enabled: true
239
+
240
+ Style/KeywordParametersOrder:
241
+ Enabled: true
242
+
243
+ Style/RedundantSelfAssignment:
244
+ Enabled: true
245
+
246
+ ############################################################
247
+ # Added in Rubocop 0.91
248
+
249
+ Layout/BeginEndAlignment:
250
+ Enabled: true
251
+
252
+ Lint/ConstantDefinitionInBlock:
253
+ Enabled: true
254
+
255
+ Lint/IdentityComparison:
256
+ Enabled: true
257
+
258
+ Lint/UselessTimes:
259
+ Enabled: true
@@ -1 +1 @@
1
- 2.6.5
1
+ 2.6.6
@@ -1,2 +1,9 @@
1
1
  language: ruby
2
2
 
3
+ os:
4
+ - linux
5
+ - osx
6
+
7
+ rvm:
8
+ - 2.6
9
+ - 2.7
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.3.0
2
+
3
+ - Support explicit nil values
4
+ - Update author email in gemspec
5
+ - Update RuboCop to version 0.91 and pin version
6
+ - Set minimum required_ruby_version to 2.6.0
7
+ - Bump .ruby-version to 2.6.6
8
+
1
9
  ## 0.2.2 (23 April 2020)
2
10
 
3
11
  - Implement [`Enumerable`](https://ruby-doc.org/core-2.6.5/Enumerable.html)
data/README.md CHANGED
@@ -93,6 +93,20 @@ Scale::KILO.value
93
93
  # => 1000
94
94
  ```
95
95
 
96
+ Even `nil` is a valid value (if set explicitly):
97
+
98
+ ```ruby
99
+ class Scheme < TypesafeEnum::Base
100
+ new :HTTP, 'http'
101
+ new :HTTPS, 'https'
102
+ new :EXAMPLE, 'example'
103
+ new :UNKNOWN, nil
104
+ end
105
+
106
+ Scheme::UNKNOWN.value
107
+ # => nil
108
+ ```
109
+
96
110
  Declaring two instances with the same key will produce an error:
97
111
 
98
112
  ```ruby
@@ -79,23 +79,37 @@ module TypesafeEnum
79
79
  end
80
80
 
81
81
  def valid_key_and_value(instance)
82
+ return unless (key = valid_key(instance))
83
+
84
+ [key, valid_value(instance)]
85
+ end
86
+
87
+ def valid_key(instance)
82
88
  key = instance.key
89
+ return key unless (found = find_by_key(key))
90
+
91
+ value = instance.value
92
+ raise NameError, "#{name}::#{key} already exists with value #{found.value.inspect}" unless value == found.value
93
+
94
+ warn("ignoring redeclaration of #{name}::#{key} with value #{value.inspect} (source: #{caller(6..6).first})")
95
+ end
96
+
97
+ def valid_value(instance)
83
98
  value = instance.value
84
- if (found = find_by_key(key))
85
- raise NameError, "#{name}::#{key} already exists" unless value == found.value
99
+ return value unless (found = find_by_value(value))
86
100
 
87
- warn("ignoring redeclaration of #{name}::#{key} with value #{value} (source: #{caller(5..5).first})")
88
- nil
89
- else
90
- raise NameError, "A #{name} instance with value '#{value}' already exists" if find_by_value(value)
101
+ key = instance.key
102
+ raise NameError, "A #{name} instance with value #{value.inspect} already exists: #{found.key}" unless key == found.key
91
103
 
92
- [key, value]
93
- end
104
+ # valid_key() should already have warned us, and valid_key_and_value() should have exited early, but just in case
105
+ # :nocov:
106
+ warn("ignoring redeclaration of #{name}::#{key} with value #{value.inspect} (source: #{caller(6..6).first})")
107
+ # :nocov:
94
108
  end
95
109
 
96
110
  def register(instance)
97
111
  key, value = valid_key_and_value(instance)
98
- return unless key && value
112
+ return unless key
99
113
 
100
114
  const_set(key.to_s, instance)
101
115
  by_key[key] = instance
@@ -138,16 +152,19 @@ module TypesafeEnum
138
152
  end
139
153
 
140
154
  def to_s
141
- "#{self.class}::#{key} [#{ord}] -> #{value}"
155
+ "#{self.class}::#{key} [#{ord}] -> #{value.inspect}"
142
156
  end
143
157
 
144
158
  private
145
159
 
146
- def initialize(key, value = nil, &block)
160
+ IMPLICIT = Class.new.new
161
+ private_constant :IMPLICIT
162
+
163
+ def initialize(key, value = IMPLICIT, &block)
147
164
  raise TypeError, "#{key} is not a symbol" unless key.is_a?(Symbol)
148
165
 
149
166
  @key = key
150
- @value = value || key.to_s.downcase
167
+ @value = value == IMPLICIT ? key.to_s.downcase : value
151
168
  @ord = self.class.size
152
169
  self.class.class_exec(self) do |instance|
153
170
  register(instance)
@@ -5,7 +5,7 @@ module TypesafeEnum
5
5
  NAME = 'typesafe_enum'
6
6
 
7
7
  # The version of this gem
8
- VERSION = '0.2.2'
8
+ VERSION = '0.3.0'
9
9
 
10
10
  # The copyright notice for this gem
11
11
  COPYRIGHT = 'Copyright (c) 2020 The Regents of the University of California'
@@ -1,5 +1,8 @@
1
1
  inherit_from: ../.rubocop.yml
2
2
 
3
+ Lint/ConstantDefinitionInBlock:
4
+ Enabled: false
5
+
3
6
  Style/ClassAndModuleChildren:
4
7
  Enabled: false
5
8
 
@@ -29,6 +29,13 @@ class Scale < TypesafeEnum::Base
29
29
  new :MEGA, 1_000_000
30
30
  end
31
31
 
32
+ class Scheme < TypesafeEnum::Base
33
+ new :HTTP, 'http'
34
+ new :HTTPS, 'https'
35
+ new :EXAMPLE, 'example'
36
+ new :UNKNOWN, nil
37
+ end
38
+
32
39
  module TypesafeEnum
33
40
  describe Base do
34
41
 
@@ -38,6 +45,15 @@ module TypesafeEnum
38
45
  expect(enum).to be_a(Suit)
39
46
  end
40
47
 
48
+ it 'allows nil values' do
49
+ expect do
50
+ class ::NilValues < Base
51
+ new :NONE, nil
52
+ end
53
+ end.not_to raise_error
54
+ expect(::NilValues.to_a).not_to be_empty
55
+ end
56
+
41
57
  it 'insists symbols be symbols' do
42
58
  expect do
43
59
  class ::StringKeys < Base
@@ -80,6 +96,18 @@ module TypesafeEnum
80
96
  expect(::DuplicateValues.find_by_key(:ALSO_SPADES)).to be_nil
81
97
  end
82
98
 
99
+ it 'disallows duplicate nil values' do
100
+ expect do
101
+ class ::DuplicateNilValues < Base
102
+ new :NONE, nil
103
+ new :NULL, nil
104
+ end.to raise_error(NameError)
105
+ expect(::DuplicateNilValues.to_a).to eq([::DuplicateNilValues::NONE])
106
+ expect(::DuplicateNilValues::NONE.value).to be_nil
107
+ expect(::DuplicateNilValues.find_by_key(:NULL)).to be_nil
108
+ end
109
+ end
110
+
83
111
  it 'disallows nil keys' do
84
112
  expect do
85
113
  class ::NilKeys < Base
@@ -93,8 +121,8 @@ module TypesafeEnum
93
121
  class ::IdenticalInstances < Base
94
122
  new :SPADES, 'spades'
95
123
  end
96
- expected_msg = /ignoring redeclaration of IdenticalInstances::SPADES with value spades/
97
- expect(::IdenticalInstances).to receive(:warn).with(a_string_matching(expected_msg))
124
+ expected_msg = /ignoring redeclaration of IdenticalInstances::SPADES with value "spades" \(source: .*base_spec.rb:[0-9]+:in `new'\)/
125
+ expect(::IdenticalInstances).to receive(:warn).once.with(expected_msg)
98
126
  class ::IdenticalInstances < Base
99
127
  new :SPADES, 'spades'
100
128
  end
@@ -302,6 +330,20 @@ module TypesafeEnum
302
330
  expect(s.value).to eq(expected[index])
303
331
  end
304
332
  end
333
+
334
+ it 'returns an explicit value' do
335
+ expected = [10, 100, 1000, 1_000_000]
336
+ Scale.each_with_index do |s, index|
337
+ expect(s.value).to eq(expected[index])
338
+ end
339
+ end
340
+
341
+ it 'supports nil values' do
342
+ expected = ['http', 'https', 'example', nil]
343
+ Scheme.each_with_index do |s, index|
344
+ expect(s.value).to eq(expected[index])
345
+ end
346
+ end
305
347
  end
306
348
 
307
349
  describe :key do
@@ -324,10 +366,10 @@ module TypesafeEnum
324
366
  describe :to_s do
325
367
  it 'provides an informative string' do
326
368
  aggregate_failures 'informative string' do
327
- [Suit, Tarot, RGBColor, Scale].each do |ec|
369
+ [Suit, Tarot, RGBColor, Scale, Scheme].each do |ec|
328
370
  ec.each do |ev|
329
371
  result = ev.to_s
330
- [ec.to_s, ev.key, ev.ord, ev.value].each do |info|
372
+ [ec.to_s, ev.key, ev.ord, ev.value.inspect].each do |info|
331
373
  expect(result).to include(info.to_s)
332
374
  end
333
375
  end
@@ -374,6 +416,12 @@ module TypesafeEnum
374
416
  expect(Scale.find_by_value(s.value)).to be(s)
375
417
  end
376
418
  end
419
+
420
+ it 'supports enums with explicit nil values' do
421
+ Scheme.each do |s|
422
+ expect(Scheme.find_by_value(s.value)).to be(s)
423
+ end
424
+ end
377
425
  end
378
426
 
379
427
  describe :find_by_value_str do
@@ -400,6 +448,12 @@ module TypesafeEnum
400
448
  expect(Scale.find_by_value_str(s.value.to_s)).to be(s)
401
449
  end
402
450
  end
451
+
452
+ it 'supports enums with explicit nil values' do
453
+ Scheme.each do |s|
454
+ expect(Scheme.find_by_value(s.value)).to be(s)
455
+ end
456
+ end
403
457
  end
404
458
 
405
459
  describe :find_by_ord do
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.name = TypesafeEnum::NAME
11
11
  spec.version = TypesafeEnum::VERSION
12
12
  spec.authors = ['David Moles']
13
- spec.email = ['david.moles@ucop.edu']
13
+ spec.email = ['dmoles@berkeley.edu']
14
14
  spec.summary = 'Typesafe enum pattern for Ruby'
15
15
  spec.description = 'A gem that implements the typesafe enum pattern in Ruby'
16
16
  spec.license = 'MIT'
@@ -23,9 +23,11 @@ Gem::Specification.new do |spec|
23
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
24
  spec.require_paths = ['lib']
25
25
 
26
+ spec.required_ruby_version = '>= 2.6.0'
27
+
26
28
  spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
27
29
  spec.add_development_dependency 'rspec', '~> 3.9'
28
- spec.add_development_dependency 'rubocop', '~> 0.80'
30
+ spec.add_development_dependency 'rubocop', '0.91'
29
31
  spec.add_development_dependency 'simplecov', '~> 0.18'
30
32
  spec.add_development_dependency 'simplecov-console', '~> 0.7'
31
33
  spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.12'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typesafe_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-24 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -48,16 +48,16 @@ dependencies:
48
48
  name: rubocop
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: '0.80'
53
+ version: '0.91'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - '='
59
59
  - !ruby/object:Gem::Version
60
- version: '0.80'
60
+ version: '0.91'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: simplecov
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -108,12 +108,21 @@ dependencies:
108
108
  version: 0.9.12
109
109
  description: A gem that implements the typesafe enum pattern in Ruby
110
110
  email:
111
- - david.moles@ucop.edu
111
+ - dmoles@berkeley.edu
112
112
  executables: []
113
113
  extensions: []
114
114
  extra_rdoc_files: []
115
115
  files:
116
116
  - ".gitignore"
117
+ - ".idea/.rakeTasks"
118
+ - ".idea/codeStyles/Project.xml"
119
+ - ".idea/codeStyles/codeStyleConfig.xml"
120
+ - ".idea/go.imports.xml"
121
+ - ".idea/inspectionProfiles/Project_Default.xml"
122
+ - ".idea/misc.xml"
123
+ - ".idea/modules.xml"
124
+ - ".idea/typesafe_enum.iml"
125
+ - ".idea/vcs.xml"
117
126
  - ".rubocop.yml"
118
127
  - ".ruby-version"
119
128
  - ".travis.yml"
@@ -134,7 +143,7 @@ homepage: https://github.com/dmolesUC/typesafe_enum
134
143
  licenses:
135
144
  - MIT
136
145
  metadata: {}
137
- post_install_message:
146
+ post_install_message:
138
147
  rdoc_options: []
139
148
  require_paths:
140
149
  - lib
@@ -142,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
151
  requirements:
143
152
  - - ">="
144
153
  - !ruby/object:Gem::Version
145
- version: '0'
154
+ version: 2.6.0
146
155
  required_rubygems_version: !ruby/object:Gem::Requirement
147
156
  requirements:
148
157
  - - ">="
@@ -150,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
159
  version: '0'
151
160
  requirements: []
152
161
  rubygems_version: 3.0.8
153
- signing_key:
162
+ signing_key:
154
163
  specification_version: 4
155
164
  summary: Typesafe enum pattern for Ruby
156
165
  test_files: