attribute_enum 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: 5075ad8cbbf43b276833d5e1b369a415a046bdac
4
- data.tar.gz: 17cc221ce2dac88bcac9beb371fd6c03eaff1077
3
+ metadata.gz: 20da3634743f48cfb2e3fb714b10894e74227dab
4
+ data.tar.gz: c20543c1b23c5b00af5341b8d49eba4c01f631bb
5
5
  SHA512:
6
- metadata.gz: 6eb30fbeb983574b458553d3c8107e6f77de76575a53de38038bb0e8a03d2f7b14d494e276592e60b011a38d16699b935de4ca578ff0d4a8d13f27495366a91d
7
- data.tar.gz: bf5260f15d6fad7a7eadd0c545342be9120c42eb9c0a6cd333bffdb467ab4b2da1265fb6681eff6db835acf651e3f7905482dd5dc620548a7efcfa04829ab594
6
+ metadata.gz: 0034b0878fca092aab66ed5980f564959403a75463957a924cc6949b3deb609b2c0e34e16dd5acd67f2dc7ca35e5a7b59b9bc3de607bef7539a0af198db6be89
7
+ data.tar.gz: a4e2d824b95db0a39001c3e6ad7d9679a411844f1664261eeb10db0cce424d701b25d04e8a5d1109001724b7cb5ee3590cbeff774229936033650faab6ade4c7
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ /.idea
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
data/README.md CHANGED
@@ -24,7 +24,7 @@ Class must have read'n'write attribute named `[what's being enumerated]`.
24
24
 
25
25
  ```ruby
26
26
  class Payment
27
- include Enum
27
+ include AttributeEnum
28
28
  attr_accessor :status
29
29
 
30
30
  def initialize(status = 0)
@@ -49,7 +49,7 @@ Payment.statuses # => [:active, :inactive]
49
49
  Payment.get_statuses # => [:active, :inactive]
50
50
  Payment.get_status(1) # => :inactive
51
51
  Payment.get_status(:active) # => 0
52
- Payment.get_status('invalid') # => ArgumentError('valid argument is either Fixnum or Symbol')
52
+ Payment.get_status('invalid') # => ArgumentError('valid argument is either Integer or Symbol')
53
53
 
54
54
  ```
55
55
 
Binary file
@@ -43,12 +43,12 @@ module AttributeEnum
43
43
  # Payment.get_statuses # => [:active, :inactive]
44
44
  # Payment.get_status(1) # => :inactive
45
45
  # Payment.get_status(:active) # => 0
46
- # Payment.get_status('invalid') # => ArgumentError('valid argument is either Fixnum or Symbol')
46
+ # Payment.get_status('invalid') # => ArgumentError('valid argument is either Integer or Symbol')
47
47
  #
48
48
  def enum(enumerated, values)
49
49
  if values.is_a? Hash
50
50
  values.each do |key,val|
51
- raise ArgumentError, "index should be numeric, #{key} provided wich it's a #{key.class}" unless key.is_a? Fixnum
51
+ raise ArgumentError, "index should be numeric, #{key} provided wich it's a #{key.class}" unless key.is_a? Integer
52
52
  raise ArgumentError "value should be a symbol, #{val} provided wich it's a #{val.class}" unless val.is_a? Symbol
53
53
  end
54
54
  elsif values.is_a? Array
@@ -130,13 +130,13 @@ module AttributeEnum
130
130
  # Obj.get_status(:active) # => 0
131
131
  #
132
132
  define_singleton_method "get_#{enumerated}" do |arg|
133
- if arg.is_a? Fixnum
133
+ if arg.is_a? Integer
134
134
  self.enums[enumerated].fetch(arg, nil)
135
135
  elsif arg.is_a? Symbol
136
136
  key = self.enums[enumerated].rassoc(arg)
137
137
  key ? key[0] : nil
138
138
  else
139
- raise ArgumentError.new('valid argument is either Fixnum or Symbol')
139
+ raise ArgumentError.new('valid argument is either Integer or Symbol')
140
140
  end
141
141
  end
142
142
 
@@ -1,3 +1,3 @@
1
1
  module AttributeEnum
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribute_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlad Faust
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-22 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -60,15 +60,12 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
- - ".idea/attribute_enum.iml"
64
- - ".idea/misc.xml"
65
- - ".idea/modules.xml"
66
- - ".idea/workspace.xml"
67
63
  - CODE_OF_CONDUCT.md
68
64
  - Gemfile
69
65
  - LICENSE.txt
70
66
  - README.md
71
67
  - Rakefile
68
+ - attribute_enum-0.1.0.gem
72
69
  - attribute_enum.gemspec
73
70
  - bin/console
74
71
  - bin/setup
@@ -94,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
91
  version: '0'
95
92
  requirements: []
96
93
  rubyforge_project:
97
- rubygems_version: 2.5.1
94
+ rubygems_version: 2.6.8
98
95
  signing_key:
99
96
  specification_version: 4
100
97
  summary: Turns a dot-accessible class attribute to an enum (a.k.a bytefield).
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="FacetManager">
4
- <facet type="gem" name="New Gem">
5
- <configuration>
6
- <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
- <option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
8
- <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
- </configuration>
10
- </facet>
11
- </component>
12
- <component name="NewModuleRootManager">
13
- <content url="file://$MODULE_DIR$">
14
- <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
15
- <excludeFolder url="file://$MODULE_DIR$/.bundle" />
16
- <excludeFolder url="file://$MODULE_DIR$/vendor/bundle" />
17
- </content>
18
- <orderEntry type="inheritedJdk" />
19
- <orderEntry type="sourceFolder" forTests="false" />
20
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.11.2, rbenv: 2.3.0) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, rbenv: 2.3.0) [gem]" level="application" />
22
- </component>
23
- </module>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectLevelVcsManager" settingsEditedManually="false">
4
- <OptionsSetting value="true" id="Add" />
5
- <OptionsSetting value="true" id="Remove" />
6
- <OptionsSetting value="true" id="Checkout" />
7
- <OptionsSetting value="true" id="Update" />
8
- <OptionsSetting value="true" id="Status" />
9
- <OptionsSetting value="true" id="Edit" />
10
- <ConfirmationsSetting value="0" id="Add" />
11
- <ConfirmationsSetting value="0" id="Remove" />
12
- </component>
13
- <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 2.3.0" project-jdk-type="RUBY_SDK" />
14
- </project>
@@ -1,8 +0,0 @@
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/attribute_enum.iml" filepath="$PROJECT_DIR$/.idea/attribute_enum.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,214 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ChangeListManager">
4
- <list default="true" id="9a54a5f6-efef-449e-80de-a116ffb81be8" name="Default" comment="" />
5
- <ignored path="attribute_enum.iws" />
6
- <ignored path=".idea/workspace.xml" />
7
- <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
8
- <option name="TRACKING_ENABLED" value="true" />
9
- <option name="SHOW_DIALOG" value="false" />
10
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
11
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
12
- <option name="LAST_RESOLUTION" value="IGNORE" />
13
- </component>
14
- <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
15
- <component name="CreatePatchCommitExecutor">
16
- <option name="PATCH_PATH" value="" />
17
- </component>
18
- <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
19
- <component name="FavoritesManager">
20
- <favorites_list name="attribute_enum" />
21
- </component>
22
- <component name="FileEditorManager">
23
- <leaf>
24
- <file leaf-file-name="attribute_enum.rb" pinned="false" current-in-tab="false">
25
- <entry file="file://$PROJECT_DIR$/lib/attribute_enum.rb">
26
- <provider selected="true" editor-type-id="text-editor">
27
- <state relative-caret-position="18">
28
- <caret line="1" column="9" selection-start-line="1" selection-start-column="9" selection-end-line="1" selection-end-column="23" />
29
- <folding />
30
- </state>
31
- </provider>
32
- </entry>
33
- </file>
34
- <file leaf-file-name="Rakefile" pinned="false" current-in-tab="false">
35
- <entry file="file://$PROJECT_DIR$/Rakefile">
36
- <provider selected="true" editor-type-id="text-editor">
37
- <state relative-caret-position="0">
38
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
39
- <folding />
40
- </state>
41
- </provider>
42
- </entry>
43
- </file>
44
- <file leaf-file-name="attribute_enum.gemspec" pinned="false" current-in-tab="true">
45
- <entry file="file://$PROJECT_DIR$/attribute_enum.gemspec">
46
- <provider selected="true" editor-type-id="text-editor">
47
- <state relative-caret-position="205">
48
- <caret line="29" column="37" selection-start-line="29" selection-start-column="37" selection-end-line="29" selection-end-column="37" />
49
- <folding />
50
- </state>
51
- </provider>
52
- </entry>
53
- </file>
54
- </leaf>
55
- </component>
56
- <component name="IdeDocumentHistory">
57
- <option name="CHANGED_PATHS">
58
- <list>
59
- <option value="$PROJECT_DIR$/lib/attribute_enum.rb" />
60
- <option value="$PROJECT_DIR$/attribute_enum.gemspec" />
61
- </list>
62
- </option>
63
- </component>
64
- <component name="JsBuildToolGruntFileManager" detection-done="true" />
65
- <component name="JsBuildToolPackageJson" detection-done="true" />
66
- <component name="JsGulpfileManager">
67
- <detection-done>true</detection-done>
68
- </component>
69
- <component name="ProjectFrameBounds">
70
- <option name="x" value="65" />
71
- <option name="y" value="24" />
72
- <option name="width" value="1301" />
73
- <option name="height" value="744" />
74
- </component>
75
- <component name="ProjectLevelVcsManager" settingsEditedManually="false">
76
- <OptionsSetting value="true" id="Add" />
77
- <OptionsSetting value="true" id="Remove" />
78
- <OptionsSetting value="true" id="Checkout" />
79
- <OptionsSetting value="true" id="Update" />
80
- <OptionsSetting value="true" id="Status" />
81
- <OptionsSetting value="true" id="Edit" />
82
- <ConfirmationsSetting value="0" id="Add" />
83
- <ConfirmationsSetting value="0" id="Remove" />
84
- </component>
85
- <component name="ProjectView">
86
- <navigator currentView="ProjectPane" proportions="" version="1">
87
- <flattenPackages />
88
- <showMembers />
89
- <showModules />
90
- <showLibraryContents />
91
- <hideEmptyPackages />
92
- <abbreviatePackageNames />
93
- <autoscrollToSource />
94
- <autoscrollFromSource />
95
- <sortByType />
96
- <manualOrder />
97
- <foldersAlwaysOnTop value="true" />
98
- </navigator>
99
- <panes>
100
- <pane id="Scope" />
101
- <pane id="ProjectPane">
102
- <subPane>
103
- <PATH>
104
- <PATH_ELEMENT>
105
- <option name="myItemId" value="attribute_enum" />
106
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
107
- </PATH_ELEMENT>
108
- </PATH>
109
- <PATH>
110
- <PATH_ELEMENT>
111
- <option name="myItemId" value="attribute_enum" />
112
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
113
- </PATH_ELEMENT>
114
- <PATH_ELEMENT>
115
- <option name="myItemId" value="attribute_enum" />
116
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
117
- </PATH_ELEMENT>
118
- </PATH>
119
- <PATH>
120
- <PATH_ELEMENT>
121
- <option name="myItemId" value="attribute_enum" />
122
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
123
- </PATH_ELEMENT>
124
- <PATH_ELEMENT>
125
- <option name="myItemId" value="attribute_enum" />
126
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
127
- </PATH_ELEMENT>
128
- <PATH_ELEMENT>
129
- <option name="myItemId" value="lib" />
130
- <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
131
- </PATH_ELEMENT>
132
- </PATH>
133
- </subPane>
134
- </pane>
135
- <pane id="Scratches" />
136
- </panes>
137
- </component>
138
- <component name="PropertiesComponent">
139
- <property name="WebServerToolWindowFactoryState" value="false" />
140
- </component>
141
- <component name="ShelveChangesManager" show_recycled="false">
142
- <option name="remove_strategy" value="false" />
143
- </component>
144
- <component name="TaskManager">
145
- <task active="true" id="Default" summary="Default task">
146
- <changelist id="9a54a5f6-efef-449e-80de-a116ffb81be8" name="Default" comment="" />
147
- <created>1461329391280</created>
148
- <option name="number" value="Default" />
149
- <option name="presentableId" value="Default" />
150
- <updated>1461329391280</updated>
151
- <workItem from="1461329392694" duration="90000" />
152
- </task>
153
- <servers />
154
- </component>
155
- <component name="TimeTrackingManager">
156
- <option name="totallyTimeSpent" value="90000" />
157
- </component>
158
- <component name="ToolWindowManager">
159
- <frame x="65" y="24" width="1301" height="744" extended-state="6" />
160
- <editor active="true" />
161
- <layout>
162
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25418326" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
163
- <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
164
- <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
165
- <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
166
- <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
167
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32868218" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
168
- <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
169
- <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
170
- <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
171
- <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
172
- <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
173
- <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
174
- <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
175
- <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
176
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
177
- <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
178
- <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
179
- </layout>
180
- </component>
181
- <component name="VcsContentAnnotationSettings">
182
- <option name="myLimit" value="2678400000" />
183
- </component>
184
- <component name="XDebuggerManager">
185
- <breakpoint-manager />
186
- <watches-manager />
187
- </component>
188
- <component name="editorHistoryManager">
189
- <entry file="file://$PROJECT_DIR$/Rakefile">
190
- <provider selected="true" editor-type-id="text-editor">
191
- <state relative-caret-position="0">
192
- <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
193
- <folding />
194
- </state>
195
- </provider>
196
- </entry>
197
- <entry file="file://$PROJECT_DIR$/lib/attribute_enum.rb">
198
- <provider selected="true" editor-type-id="text-editor">
199
- <state relative-caret-position="18">
200
- <caret line="1" column="9" selection-start-line="1" selection-start-column="9" selection-end-line="1" selection-end-column="23" />
201
- <folding />
202
- </state>
203
- </provider>
204
- </entry>
205
- <entry file="file://$PROJECT_DIR$/attribute_enum.gemspec">
206
- <provider selected="true" editor-type-id="text-editor">
207
- <state relative-caret-position="205">
208
- <caret line="29" column="37" selection-start-line="29" selection-start-column="37" selection-end-line="29" selection-end-column="37" />
209
- <folding />
210
- </state>
211
- </provider>
212
- </entry>
213
- </component>
214
- </project>