jiffy_enums 1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +22 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +101 -0
- data/MIT-LICENSE +20 -0
- data/README.md +61 -0
- data/Rakefile +31 -0
- data/app/assets/images/jiffy_enums/.gitkeep +0 -0
- data/app/assets/javascripts/jiffy_enum.js.coffee +2 -0
- data/app/assets/javascripts/jiffy_enums/.gitkeep +0 -0
- data/app/assets/javascripts/jiffy_enums.js.coffee +36 -0
- data/app/assets/stylesheets/jiffy_enums/.gitkeep +0 -0
- data/app/controllers/.gitkeep +0 -0
- data/app/helpers/.gitkeep +0 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/views/.gitkeep +0 -0
- data/config/routes.rb +2 -0
- data/jiffy_enums.gemspec +20 -0
- data/lib/jiffy_enum.rb +13 -0
- data/lib/jiffy_enums/engine.rb +4 -0
- data/lib/jiffy_enums/version.rb +3 -0
- data/lib/jiffy_enums.rb +69 -0
- data/lib/tasks/jiffy_enums_tasks.rake +4 -0
- data/script/rails +8 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/log/development.log +2 -0
- data/spec/dummy/log/test.log +7 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/jiffy_enums_spec.rb +89 -0
- data/spec/spec_helper.rb +9 -0
- metadata +168 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
# The priority is based upon order of creation:
|
3
|
+
# first created -> highest priority.
|
4
|
+
|
5
|
+
# Sample of regular route:
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
8
|
+
|
9
|
+
# Sample of named route:
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
12
|
+
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
14
|
+
# resources :products
|
15
|
+
|
16
|
+
# Sample resource route with options:
|
17
|
+
# resources :products do
|
18
|
+
# member do
|
19
|
+
# get 'short'
|
20
|
+
# post 'toggle'
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# collection do
|
24
|
+
# get 'sold'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Sample resource route with sub-resources:
|
29
|
+
# resources :products do
|
30
|
+
# resources :comments, :sales
|
31
|
+
# resource :seller
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Sample resource route with more complex sub-resources
|
35
|
+
# resources :products do
|
36
|
+
# resources :comments
|
37
|
+
# resources :sales do
|
38
|
+
# get 'recent', :on => :collection
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Sample resource route within a namespace:
|
43
|
+
# namespace :admin do
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
46
|
+
# resources :products
|
47
|
+
# end
|
48
|
+
|
49
|
+
# You can have the root of your site routed with "root"
|
50
|
+
# just remember to delete public/index.html.
|
51
|
+
# root :to => 'welcome#index'
|
52
|
+
|
53
|
+
# See how all your routes lay out with "rake routes"
|
54
|
+
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
57
|
+
# match ':controller(/:action(/:id))(.:format)'
|
58
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Connecting to database specified by database.yml
|
2
|
+
Connecting to database specified by database.yml
|
3
|
+
Connecting to database specified by database.yml
|
4
|
+
Connecting to database specified by database.yml
|
5
|
+
Connecting to database specified by database.yml
|
6
|
+
Connecting to database specified by database.yml
|
7
|
+
Connecting to database specified by database.yml
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JiffyEnums do
|
4
|
+
it { should be_a_kind_of Module }
|
5
|
+
end
|
6
|
+
|
7
|
+
class ExampleEnums < JiffyEnum
|
8
|
+
define :Yes do
|
9
|
+
def say
|
10
|
+
'I say hello'
|
11
|
+
end
|
12
|
+
|
13
|
+
def is_cool
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
define :No do
|
19
|
+
def say
|
20
|
+
'you say good bye'
|
21
|
+
end
|
22
|
+
|
23
|
+
def is_cool
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
define :Maybe do
|
29
|
+
def is_cool
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
define :Woot, 'Woot', 10 do
|
35
|
+
def is_cool
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def say
|
41
|
+
'no go'
|
42
|
+
end
|
43
|
+
|
44
|
+
def we_all_say
|
45
|
+
'something'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ExampleEnums do
|
50
|
+
subject { ExampleEnums }
|
51
|
+
describe 'the enums (accessed as class methods)' do
|
52
|
+
it 'has correct ordinal values' do
|
53
|
+
expect(subject.Yes.ordinal).to eq 1
|
54
|
+
expect(subject.No.ordinal).to eq 2
|
55
|
+
expect(subject.Maybe.ordinal).to eq 3
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'has correct key values' do
|
59
|
+
expect(subject.Yes.key).to eq :Yes
|
60
|
+
expect(subject.No.key).to eq :No
|
61
|
+
expect(subject.Maybe.key).to eq :Maybe
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'allows function calls to defined functions in the enum' do
|
65
|
+
expect(subject.Yes.say).to eq 'I say hello'
|
66
|
+
expect(subject.No.say).to eq 'you say good bye'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'has access to globally defined functions' do
|
70
|
+
expect(subject.Maybe.say).to eq 'no go'
|
71
|
+
expect(subject.Maybe.we_all_say).to eq 'something'
|
72
|
+
expect(subject.Yes.we_all_say).to eq 'something'
|
73
|
+
expect(subject.No.we_all_say).to eq 'something'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#for_ordinal(10)' do
|
78
|
+
it 'finds Woot' do
|
79
|
+
expect(subject.for_ordinal(10).value).to eq 'Woot'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'enumerable methods' do
|
84
|
+
it 'selects' do
|
85
|
+
result = subject.select { |enum| enum.is_cool }
|
86
|
+
expect(result).to match_array([ExampleEnums.Yes])
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jiffy_enums
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tejas Ravindra Mandke
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.13.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.13.0
|
41
|
+
description: Easy way to add enums
|
42
|
+
email:
|
43
|
+
- tejas@identified.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .travis.yml
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- MIT-LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- app/assets/images/jiffy_enums/.gitkeep
|
56
|
+
- app/assets/javascripts/jiffy_enum.js.coffee
|
57
|
+
- app/assets/javascripts/jiffy_enums.js.coffee
|
58
|
+
- app/assets/javascripts/jiffy_enums/.gitkeep
|
59
|
+
- app/assets/stylesheets/jiffy_enums/.gitkeep
|
60
|
+
- app/controllers/.gitkeep
|
61
|
+
- app/helpers/.gitkeep
|
62
|
+
- app/mailers/.gitkeep
|
63
|
+
- app/models/.gitkeep
|
64
|
+
- app/views/.gitkeep
|
65
|
+
- config/routes.rb
|
66
|
+
- jiffy_enums.gemspec
|
67
|
+
- lib/jiffy_enum.rb
|
68
|
+
- lib/jiffy_enums.rb
|
69
|
+
- lib/jiffy_enums/engine.rb
|
70
|
+
- lib/jiffy_enums/version.rb
|
71
|
+
- lib/tasks/jiffy_enums_tasks.rake
|
72
|
+
- script/rails
|
73
|
+
- spec/dummy/README.rdoc
|
74
|
+
- spec/dummy/Rakefile
|
75
|
+
- spec/dummy/app/assets/javascripts/application.js
|
76
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
77
|
+
- spec/dummy/app/controllers/application_controller.rb
|
78
|
+
- spec/dummy/app/helpers/application_helper.rb
|
79
|
+
- spec/dummy/app/mailers/.gitkeep
|
80
|
+
- spec/dummy/app/models/.gitkeep
|
81
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
82
|
+
- spec/dummy/config.ru
|
83
|
+
- spec/dummy/config/application.rb
|
84
|
+
- spec/dummy/config/boot.rb
|
85
|
+
- spec/dummy/config/database.yml
|
86
|
+
- spec/dummy/config/environment.rb
|
87
|
+
- spec/dummy/config/environments/development.rb
|
88
|
+
- spec/dummy/config/environments/production.rb
|
89
|
+
- spec/dummy/config/environments/test.rb
|
90
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
91
|
+
- spec/dummy/config/initializers/inflections.rb
|
92
|
+
- spec/dummy/config/initializers/mime_types.rb
|
93
|
+
- spec/dummy/config/initializers/secret_token.rb
|
94
|
+
- spec/dummy/config/initializers/session_store.rb
|
95
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
96
|
+
- spec/dummy/config/locales/en.yml
|
97
|
+
- spec/dummy/config/routes.rb
|
98
|
+
- spec/dummy/lib/assets/.gitkeep
|
99
|
+
- spec/dummy/log/.gitkeep
|
100
|
+
- spec/dummy/log/development.log
|
101
|
+
- spec/dummy/log/test.log
|
102
|
+
- spec/dummy/public/404.html
|
103
|
+
- spec/dummy/public/422.html
|
104
|
+
- spec/dummy/public/500.html
|
105
|
+
- spec/dummy/public/favicon.ico
|
106
|
+
- spec/dummy/script/rails
|
107
|
+
- spec/jiffy_enums_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
homepage: https://github.com/Identified/jiffy_enums
|
110
|
+
licenses: []
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.0.3
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Easy way to add enums
|
132
|
+
test_files:
|
133
|
+
- spec/dummy/README.rdoc
|
134
|
+
- spec/dummy/Rakefile
|
135
|
+
- spec/dummy/app/assets/javascripts/application.js
|
136
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
137
|
+
- spec/dummy/app/controllers/application_controller.rb
|
138
|
+
- spec/dummy/app/helpers/application_helper.rb
|
139
|
+
- spec/dummy/app/mailers/.gitkeep
|
140
|
+
- spec/dummy/app/models/.gitkeep
|
141
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
142
|
+
- spec/dummy/config.ru
|
143
|
+
- spec/dummy/config/application.rb
|
144
|
+
- spec/dummy/config/boot.rb
|
145
|
+
- spec/dummy/config/database.yml
|
146
|
+
- spec/dummy/config/environment.rb
|
147
|
+
- spec/dummy/config/environments/development.rb
|
148
|
+
- spec/dummy/config/environments/production.rb
|
149
|
+
- spec/dummy/config/environments/test.rb
|
150
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
151
|
+
- spec/dummy/config/initializers/inflections.rb
|
152
|
+
- spec/dummy/config/initializers/mime_types.rb
|
153
|
+
- spec/dummy/config/initializers/secret_token.rb
|
154
|
+
- spec/dummy/config/initializers/session_store.rb
|
155
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
156
|
+
- spec/dummy/config/locales/en.yml
|
157
|
+
- spec/dummy/config/routes.rb
|
158
|
+
- spec/dummy/lib/assets/.gitkeep
|
159
|
+
- spec/dummy/log/.gitkeep
|
160
|
+
- spec/dummy/log/development.log
|
161
|
+
- spec/dummy/log/test.log
|
162
|
+
- spec/dummy/public/404.html
|
163
|
+
- spec/dummy/public/422.html
|
164
|
+
- spec/dummy/public/500.html
|
165
|
+
- spec/dummy/public/favicon.ico
|
166
|
+
- spec/dummy/script/rails
|
167
|
+
- spec/jiffy_enums_spec.rb
|
168
|
+
- spec/spec_helper.rb
|