levtera 0.2.1
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/.document +4 -0
- data/.gitignore +50 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/ChangeLog.rdoc +4 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +193 -0
- data/Guardfile +30 -0
- data/README.md +105 -0
- data/Rakefile +41 -0
- data/WTFP-LICENSE +13 -0
- data/levtera.gemspec +44 -0
- data/lib/levtera/concerns/make.rb +19 -0
- data/lib/levtera/concerns/model.rb +16 -0
- data/lib/levtera/concerns/provided.rb +12 -0
- data/lib/levtera/concerns/vehicle.rb +31 -0
- data/lib/levtera/concerns/version.rb +35 -0
- data/lib/levtera/rspec.rb +17 -0
- data/lib/levtera/version.rb +16 -0
- data/lib/levtera.rb +1 -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/models/make.rb +4 -0
- data/spec/dummy/app/models/model.rb +4 -0
- data/spec/dummy/app/models/vehicle.rb +4 -0
- data/spec/dummy/app/models/version.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +63 -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/mongoid.yml +68 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/log/development.log +1 -0
- data/spec/dummy/log/test.log +170 -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/fabricators/make_fabricator.rb +4 -0
- data/spec/fabricators/model_fabricator.rb +3 -0
- data/spec/fabricators/provider_fabricator.rb +4 -0
- data/spec/fabricators/vehicle_fabricator.rb +11 -0
- data/spec/fabricators/version_fabricator.rb +10 -0
- data/spec/levtera_spec.rb +8 -0
- data/spec/models/make_spec.rb +5 -0
- data/spec/models/model_spec.rb +5 -0
- data/spec/models/vehicle_spec.rb +5 -0
- data/spec/models/version_spec.rb +5 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/support/example_groups/make_groups.rb +6 -0
- data/spec/support/example_groups/model_groups.rb +5 -0
- data/spec/support/example_groups/provided_groups.rb +3 -0
- data/spec/support/example_groups/vehicle_groups.rb +8 -0
- data/spec/support/example_groups/version_groups.rb +13 -0
- data/tmp/rspec_guard_result +1 -0
- metadata +443 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 3c70dab4f31b93f4ba2c0fd6db2a7e8025521a7d
|
|
4
|
+
data.tar.gz: 41ea9cc3ee36c80512cdb57a76756aa9e6a5cf85
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2948161510dbb2af98c87f90cfaca5bc44a9c75929cdb996e88c96d0f9893519ef8a3b20ec3d649e72676f4148a137b0cb61760b0abc9689b9540c0200aa0698
|
|
7
|
+
data.tar.gz: 537ffc51ddb0cb72992729ec58332d80383e2fdb418f72a6116bad8cb30c7a570376ea8078db3ff3e8586f528af83aec788f47e5a04a8bb9a38e6c7d0335bb0f
|
data/.document
ADDED
data/.gitignore
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Mac OS X Files
|
|
2
|
+
.DS_*
|
|
3
|
+
|
|
4
|
+
# Bundler
|
|
5
|
+
.bundle
|
|
6
|
+
|
|
7
|
+
# Security Preventions
|
|
8
|
+
db/*.sqlite3
|
|
9
|
+
config/database.yml
|
|
10
|
+
config/pubnub.yml
|
|
11
|
+
config/mongoid.yml
|
|
12
|
+
spec/dummy/db/*.sqlite3
|
|
13
|
+
spec/dummy/config/database.yml
|
|
14
|
+
spec/dummy/config/pubnub.yml
|
|
15
|
+
spec/dummy/config/mongoid.yml
|
|
16
|
+
spec/dummy/config/initializers/smtp.rb
|
|
17
|
+
|
|
18
|
+
# Monitoring files
|
|
19
|
+
log/*
|
|
20
|
+
tmp
|
|
21
|
+
tmp/**/*
|
|
22
|
+
public/uploads/*
|
|
23
|
+
public/clicktale/*
|
|
24
|
+
public/uploads/*
|
|
25
|
+
spec/dummy/log/**/*
|
|
26
|
+
spec/dummy/tmp/**/*
|
|
27
|
+
spec/dummy/public/uploads/*
|
|
28
|
+
spec/dummy/public/clicktale/*
|
|
29
|
+
spec/dummy/public/uploads/*
|
|
30
|
+
|
|
31
|
+
# Run Commands Files
|
|
32
|
+
.rvmrc
|
|
33
|
+
.powrc
|
|
34
|
+
|
|
35
|
+
# Cache
|
|
36
|
+
test/dummy/.sass-cache
|
|
37
|
+
|
|
38
|
+
# Vendor and Data files
|
|
39
|
+
pkg/
|
|
40
|
+
test/dummy/public/uploads/*
|
|
41
|
+
test/dummy/public/clicktale/*
|
|
42
|
+
|
|
43
|
+
# Emacs Temporary Files
|
|
44
|
+
*~
|
|
45
|
+
*#
|
|
46
|
+
|
|
47
|
+
# Eclipse
|
|
48
|
+
.directory
|
|
49
|
+
.project
|
|
50
|
+
.loadpath
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--colour --format documentation
|
data/.rvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rvm use --create @levtera
|
data/ChangeLog.rdoc
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
# Declare your gem's dependencies in levtera.gemspec.
|
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
|
5
|
+
# development dependencies will be added by default to the :development group.
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
|
11
|
+
# your gem to rubygems.org.
|
|
12
|
+
|
|
13
|
+
# To use debugger
|
|
14
|
+
# gem 'debugger'
|
|
15
|
+
gem "mongoid", "~> 4.0", github: "mongoid/mongoid"
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
GIT
|
|
2
|
+
remote: git://github.com/mongoid/mongoid.git
|
|
3
|
+
revision: 7087ec96de927f347f754e1907ca64527df6b4ea
|
|
4
|
+
specs:
|
|
5
|
+
mongoid (4.0.0)
|
|
6
|
+
activemodel (~> 4.0.0)
|
|
7
|
+
moped (~> 1.5)
|
|
8
|
+
origin (~> 1.0)
|
|
9
|
+
tzinfo (~> 0.3.37)
|
|
10
|
+
|
|
11
|
+
PATH
|
|
12
|
+
remote: .
|
|
13
|
+
specs:
|
|
14
|
+
levtera (0.2.1)
|
|
15
|
+
mongoid
|
|
16
|
+
mongoid-rspec
|
|
17
|
+
rails (>= 3)
|
|
18
|
+
|
|
19
|
+
GEM
|
|
20
|
+
remote: http://rubygems.org/
|
|
21
|
+
specs:
|
|
22
|
+
actionmailer (4.0.0)
|
|
23
|
+
actionpack (= 4.0.0)
|
|
24
|
+
mail (~> 2.5.3)
|
|
25
|
+
actionpack (4.0.0)
|
|
26
|
+
activesupport (= 4.0.0)
|
|
27
|
+
builder (~> 3.1.0)
|
|
28
|
+
erubis (~> 2.7.0)
|
|
29
|
+
rack (~> 1.5.2)
|
|
30
|
+
rack-test (~> 0.6.2)
|
|
31
|
+
activemodel (4.0.0)
|
|
32
|
+
activesupport (= 4.0.0)
|
|
33
|
+
builder (~> 3.1.0)
|
|
34
|
+
activerecord (4.0.0)
|
|
35
|
+
activemodel (= 4.0.0)
|
|
36
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
|
37
|
+
activesupport (= 4.0.0)
|
|
38
|
+
arel (~> 4.0.0)
|
|
39
|
+
activerecord-deprecated_finders (1.0.3)
|
|
40
|
+
activesupport (4.0.0)
|
|
41
|
+
i18n (~> 0.6, >= 0.6.4)
|
|
42
|
+
minitest (~> 4.2)
|
|
43
|
+
multi_json (~> 1.3)
|
|
44
|
+
thread_safe (~> 0.1)
|
|
45
|
+
tzinfo (~> 0.3.37)
|
|
46
|
+
addressable (2.3.5)
|
|
47
|
+
arel (4.0.0)
|
|
48
|
+
atomic (1.1.14)
|
|
49
|
+
awesome_print (1.1.0)
|
|
50
|
+
binding_of_caller (0.7.2)
|
|
51
|
+
debug_inspector (>= 0.0.1)
|
|
52
|
+
builder (3.1.4)
|
|
53
|
+
coderay (1.0.9)
|
|
54
|
+
database_cleaner (1.1.1)
|
|
55
|
+
debug_inspector (0.0.2)
|
|
56
|
+
diff-lcs (1.2.4)
|
|
57
|
+
email_spec (1.5.0)
|
|
58
|
+
launchy (~> 2.1)
|
|
59
|
+
mail (~> 2.2)
|
|
60
|
+
erubis (2.7.0)
|
|
61
|
+
fabrication (2.8.0)
|
|
62
|
+
ffi (1.9.0)
|
|
63
|
+
forgery (0.5.0)
|
|
64
|
+
formatador (0.2.4)
|
|
65
|
+
growl (1.0.3)
|
|
66
|
+
guard (1.8.2)
|
|
67
|
+
formatador (>= 0.2.4)
|
|
68
|
+
listen (>= 1.0.0)
|
|
69
|
+
lumberjack (>= 1.0.2)
|
|
70
|
+
pry (>= 0.9.10)
|
|
71
|
+
thor (>= 0.14.6)
|
|
72
|
+
guard-rspec (3.0.3)
|
|
73
|
+
guard (>= 1.8)
|
|
74
|
+
rspec (~> 2.13)
|
|
75
|
+
hike (1.2.3)
|
|
76
|
+
i18n (0.6.5)
|
|
77
|
+
interception (0.3)
|
|
78
|
+
json (1.8.0)
|
|
79
|
+
launchy (2.3.0)
|
|
80
|
+
addressable (~> 2.3)
|
|
81
|
+
listen (1.3.1)
|
|
82
|
+
rb-fsevent (>= 0.9.3)
|
|
83
|
+
rb-inotify (>= 0.9)
|
|
84
|
+
rb-kqueue (>= 0.2)
|
|
85
|
+
lumberjack (1.0.4)
|
|
86
|
+
mail (2.5.4)
|
|
87
|
+
mime-types (~> 1.16)
|
|
88
|
+
treetop (~> 1.4.8)
|
|
89
|
+
method_source (0.8.2)
|
|
90
|
+
mime-types (1.25)
|
|
91
|
+
minitest (4.7.5)
|
|
92
|
+
mongoid-rspec (1.9.0)
|
|
93
|
+
mongoid (>= 3.0.1)
|
|
94
|
+
rake
|
|
95
|
+
rspec (>= 2.14)
|
|
96
|
+
moped (1.5.1)
|
|
97
|
+
multi_json (1.8.2)
|
|
98
|
+
origin (1.1.0)
|
|
99
|
+
polyglot (0.3.3)
|
|
100
|
+
pry (0.9.12.2)
|
|
101
|
+
coderay (~> 1.0.5)
|
|
102
|
+
method_source (~> 0.8)
|
|
103
|
+
slop (~> 3.4)
|
|
104
|
+
pry-rails (0.3.2)
|
|
105
|
+
pry (>= 0.9.10)
|
|
106
|
+
pry-rescue (1.1.1)
|
|
107
|
+
interception (>= 0.3)
|
|
108
|
+
pry
|
|
109
|
+
pry-stack_explorer (0.4.9.1)
|
|
110
|
+
binding_of_caller (>= 0.7)
|
|
111
|
+
pry (>= 0.9.11)
|
|
112
|
+
rack (1.5.2)
|
|
113
|
+
rack-test (0.6.2)
|
|
114
|
+
rack (>= 1.0)
|
|
115
|
+
rails (4.0.0)
|
|
116
|
+
actionmailer (= 4.0.0)
|
|
117
|
+
actionpack (= 4.0.0)
|
|
118
|
+
activerecord (= 4.0.0)
|
|
119
|
+
activesupport (= 4.0.0)
|
|
120
|
+
bundler (>= 1.3.0, < 2.0)
|
|
121
|
+
railties (= 4.0.0)
|
|
122
|
+
sprockets-rails (~> 2.0.0)
|
|
123
|
+
railties (4.0.0)
|
|
124
|
+
actionpack (= 4.0.0)
|
|
125
|
+
activesupport (= 4.0.0)
|
|
126
|
+
rake (>= 0.8.7)
|
|
127
|
+
thor (>= 0.18.1, < 2.0)
|
|
128
|
+
rake (10.1.0)
|
|
129
|
+
rb-fsevent (0.9.3)
|
|
130
|
+
rb-inotify (0.9.1)
|
|
131
|
+
ffi (>= 0.5.0)
|
|
132
|
+
rb-kqueue (0.2.0)
|
|
133
|
+
ffi (>= 0.5.0)
|
|
134
|
+
rdoc (3.12.2)
|
|
135
|
+
json (~> 1.4)
|
|
136
|
+
rspec (2.14.1)
|
|
137
|
+
rspec-core (~> 2.14.0)
|
|
138
|
+
rspec-expectations (~> 2.14.0)
|
|
139
|
+
rspec-mocks (~> 2.14.0)
|
|
140
|
+
rspec-core (2.14.5)
|
|
141
|
+
rspec-expectations (2.14.2)
|
|
142
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
143
|
+
rspec-mocks (2.14.3)
|
|
144
|
+
rspec-rails (2.14.0)
|
|
145
|
+
actionpack (>= 3.0)
|
|
146
|
+
activesupport (>= 3.0)
|
|
147
|
+
railties (>= 3.0)
|
|
148
|
+
rspec-core (~> 2.14.0)
|
|
149
|
+
rspec-expectations (~> 2.14.0)
|
|
150
|
+
rspec-mocks (~> 2.14.0)
|
|
151
|
+
rubygems-tasks (0.2.4)
|
|
152
|
+
slop (3.4.6)
|
|
153
|
+
sprockets (2.10.0)
|
|
154
|
+
hike (~> 1.2)
|
|
155
|
+
multi_json (~> 1.0)
|
|
156
|
+
rack (~> 1.0)
|
|
157
|
+
tilt (~> 1.1, != 1.3.0)
|
|
158
|
+
sprockets-rails (2.0.0)
|
|
159
|
+
actionpack (>= 3.0)
|
|
160
|
+
activesupport (>= 3.0)
|
|
161
|
+
sprockets (~> 2.8)
|
|
162
|
+
sqlite3 (1.3.8)
|
|
163
|
+
thor (0.18.1)
|
|
164
|
+
thread_safe (0.1.3)
|
|
165
|
+
atomic
|
|
166
|
+
tilt (1.4.1)
|
|
167
|
+
treetop (1.4.15)
|
|
168
|
+
polyglot
|
|
169
|
+
polyglot (>= 0.3.1)
|
|
170
|
+
tzinfo (0.3.38)
|
|
171
|
+
|
|
172
|
+
PLATFORMS
|
|
173
|
+
ruby
|
|
174
|
+
|
|
175
|
+
DEPENDENCIES
|
|
176
|
+
awesome_print
|
|
177
|
+
database_cleaner
|
|
178
|
+
email_spec
|
|
179
|
+
fabrication
|
|
180
|
+
forgery
|
|
181
|
+
growl
|
|
182
|
+
guard-rspec
|
|
183
|
+
levtera!
|
|
184
|
+
mongoid (~> 4.0)!
|
|
185
|
+
pry-rails
|
|
186
|
+
pry-rescue
|
|
187
|
+
pry-stack_explorer
|
|
188
|
+
rails
|
|
189
|
+
rdoc (~> 3.0)
|
|
190
|
+
rspec (~> 2.4)
|
|
191
|
+
rspec-rails
|
|
192
|
+
rubygems-tasks (~> 0.2)
|
|
193
|
+
sqlite3
|
data/Guardfile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
guard :rspec do
|
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
8
|
+
|
|
9
|
+
# Rails example
|
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
|
16
|
+
|
|
17
|
+
# Canmoia Concerns
|
|
18
|
+
watch(%r{^lib/canmoia/concerns(.+)\.rb$}) { |m| ["spec/#{m[1]}_spec.rb", "spec/lib/concerns/#{m[1]}_spec.rb"] }
|
|
19
|
+
watch(%r{^lib/canmoia/features(.+)\.rb$}) { |m| ["spec/#{m[1]}_spec.rb", "spec/lib/features/#{m[1]}_spec.rb"] }
|
|
20
|
+
|
|
21
|
+
# Fabricators
|
|
22
|
+
watch(%r{^spec/fabricators/(.+)\.rb$}) { |m| ["spec/#{m[1]}_spec.rb", "spec/concerns/#{m[1]}_spec.rb", "spec/models/#{m[1]}_spec.rb"] }
|
|
23
|
+
|
|
24
|
+
# Capybara features specs
|
|
25
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
|
26
|
+
|
|
27
|
+
# Turnip features and steps
|
|
28
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
29
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
|
30
|
+
end
|
data/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
|
|
2
|
+
levtéra
|
|
3
|
+
=======
|
|
4
|
+
|
|
5
|
+
<!---
|
|
6
|
+
|
|
7
|
+
TODO Add badges of this services
|
|
8
|
+
|
|
9
|
+
[](http://travis-ci.org/indefinido/canmoia)
|
|
10
|
+
[](https://coveralls.io/r/indefinido/canmoia)
|
|
11
|
+
[](https://codeclimate.com/github/indefinido/canmoia)
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
Summary
|
|
17
|
+
-------
|
|
18
|
+
|
|
19
|
+
Levtéra (lev = move, téra = straight). The core functionality of Vehicle domain.
|
|
20
|
+
|
|
21
|
+
Description
|
|
22
|
+
-----------
|
|
23
|
+
|
|
24
|
+
The core domain concerns for Vehicles (Makes, Versions, Models, Plates)
|
|
25
|
+
|
|
26
|
+
Mainly for brasilian makes, but hopefully will expand and used in more services.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Features
|
|
30
|
+
--------
|
|
31
|
+
|
|
32
|
+
Domain Rules for
|
|
33
|
+
|
|
34
|
+
- Makes
|
|
35
|
+
- Provider validation
|
|
36
|
+
- Version
|
|
37
|
+
- Provider ivalidation
|
|
38
|
+
- Power, doors and valves numericality check
|
|
39
|
+
- Transmission type check (automatic, semi-automatic ...)
|
|
40
|
+
- Body type check (truck, convertible, ...)
|
|
41
|
+
- Models
|
|
42
|
+
- Provider ivalidation
|
|
43
|
+
- Vehicle type check (car, motorcycle, ...)
|
|
44
|
+
- Vehicles
|
|
45
|
+
- Provider ivalidation
|
|
46
|
+
- Fabrication and model years numericality
|
|
47
|
+
- Engine feeding check (alcohol, flexible, gasoline, ...)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Examples
|
|
51
|
+
--------
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
|
|
55
|
+
require 'levtera'
|
|
56
|
+
|
|
57
|
+
class Version
|
|
58
|
+
include Mongoid::Document
|
|
59
|
+
include Levtera::Concerns::Version
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
version.transmission_type = :automatic
|
|
63
|
+
version.valid? // true
|
|
64
|
+
|
|
65
|
+
version.transmission_type = :potatoe
|
|
66
|
+
version.valid? // false
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Requirements
|
|
71
|
+
------------
|
|
72
|
+
|
|
73
|
+
Currently ORM dependend, sorry folks.
|
|
74
|
+
|
|
75
|
+
- rails >= 3
|
|
76
|
+
- mongoid >= 3
|
|
77
|
+
|
|
78
|
+
Install
|
|
79
|
+
-------
|
|
80
|
+
|
|
81
|
+
Through gem command
|
|
82
|
+
|
|
83
|
+
$ gem install levtera
|
|
84
|
+
|
|
85
|
+
Or add to your gemfile
|
|
86
|
+
|
|
87
|
+
Testing
|
|
88
|
+
=======
|
|
89
|
+
|
|
90
|
+
On your spec_helper.rb, require integration to use shared examples
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
|
|
94
|
+
require 'levtera/rspec'
|
|
95
|
+
|
|
96
|
+
describe Make do
|
|
97
|
+
it_should_behave_like :levtera_make
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
This project rocks and uses WTFP-LICENSE.
|
|
105
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'rake'
|
|
5
|
+
|
|
6
|
+
begin
|
|
7
|
+
gem 'rubygems-tasks', '~> 0.2'
|
|
8
|
+
require 'rubygems/tasks'
|
|
9
|
+
|
|
10
|
+
Gem::Tasks.new
|
|
11
|
+
rescue LoadError => e
|
|
12
|
+
warn e.message
|
|
13
|
+
warn "Run `gem install rubygems-tasks` to install Gem::Tasks."
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
begin
|
|
17
|
+
gem 'rdoc', '~> 3.0'
|
|
18
|
+
require 'rdoc/task'
|
|
19
|
+
|
|
20
|
+
RDoc::Task.new do |rdoc|
|
|
21
|
+
rdoc.title = "levtera"
|
|
22
|
+
end
|
|
23
|
+
rescue LoadError => e
|
|
24
|
+
warn e.message
|
|
25
|
+
warn "Run `gem install rdoc` to install 'rdoc/task'."
|
|
26
|
+
end
|
|
27
|
+
task :doc => :rdoc
|
|
28
|
+
|
|
29
|
+
begin
|
|
30
|
+
gem 'rspec', '~> 2.4'
|
|
31
|
+
require 'rspec/core/rake_task'
|
|
32
|
+
|
|
33
|
+
RSpec::Core::RakeTask.new
|
|
34
|
+
rescue LoadError => e
|
|
35
|
+
task :spec do
|
|
36
|
+
abort "Please run `gem install rspec` to install RSpec."
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
task :test => :spec
|
|
41
|
+
task :default => :spec
|
data/WTFP-LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
2
|
+
Version 2, December 2004
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
|
5
|
+
|
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
|
7
|
+
copies of this license document, and changing it is allowed as long
|
|
8
|
+
as the name is changed.
|
|
9
|
+
|
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
12
|
+
|
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
data/levtera.gemspec
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'levtera/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |gem|
|
|
6
|
+
gem.name = "levtera"
|
|
7
|
+
gem.version = Levtera::VERSION
|
|
8
|
+
gem.summary = %q{Levtéra (lev = move, téra = straight). The core functionality of Vehicle domain.}
|
|
9
|
+
gem.description = %q{The core domain concerns for Vehicles (Makes, Versions, Models, Plates).}
|
|
10
|
+
gem.license = "WTFP"
|
|
11
|
+
gem.authors = ["Heitor Salazar Baldelli"]
|
|
12
|
+
gem.email = "heitor@indefini.do"
|
|
13
|
+
gem.homepage = "https://rubygems.org/gems/levtera"
|
|
14
|
+
|
|
15
|
+
gem.files = `git ls-files`.split($/)
|
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
gem.require_paths = ['lib']
|
|
19
|
+
|
|
20
|
+
gem.add_dependency "rails", ">= 3"
|
|
21
|
+
gem.add_dependency "mongoid"
|
|
22
|
+
|
|
23
|
+
# When using levtera/rspec
|
|
24
|
+
gem.add_dependency 'mongoid-rspec'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
gem.add_development_dependency 'rdoc', '~> 3.0'
|
|
28
|
+
gem.add_development_dependency 'rspec', '~> 2.4'
|
|
29
|
+
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
|
30
|
+
|
|
31
|
+
gem.add_development_dependency 'rails'
|
|
32
|
+
gem.add_development_dependency 'awesome_print'
|
|
33
|
+
gem.add_development_dependency 'fabrication'
|
|
34
|
+
gem.add_development_dependency 'forgery'
|
|
35
|
+
gem.add_development_dependency 'database_cleaner'
|
|
36
|
+
gem.add_development_dependency 'rspec-rails'
|
|
37
|
+
gem.add_development_dependency 'growl'
|
|
38
|
+
gem.add_development_dependency 'email_spec'
|
|
39
|
+
gem.add_development_dependency 'pry-rescue'
|
|
40
|
+
gem.add_development_dependency 'pry-stack_explorer'
|
|
41
|
+
gem.add_development_dependency 'pry-rails'
|
|
42
|
+
gem.add_development_dependency 'guard-rspec'
|
|
43
|
+
gem.add_development_dependency 'sqlite3'
|
|
44
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Levtera::Concerns
|
|
2
|
+
module Make
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do
|
|
6
|
+
include Provided
|
|
7
|
+
|
|
8
|
+
VEHICLE_TYPES = %w(motorcycle car)
|
|
9
|
+
|
|
10
|
+
field :name, type: String
|
|
11
|
+
field :vehicle_type, type: String
|
|
12
|
+
|
|
13
|
+
has_many :models
|
|
14
|
+
|
|
15
|
+
validates :name, presence: true
|
|
16
|
+
validates :vehicle_type, inclusion: { in: VEHICLE_TYPES }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Levtera::Concerns
|
|
2
|
+
module Vehicle
|
|
3
|
+
ENGINE_FEEDINGS_NAMES = %i(gasoline alcohol diesel multifuel)
|
|
4
|
+
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
included do
|
|
8
|
+
field :fabrication_year , type: Integer
|
|
9
|
+
field :model_year , type: Integer
|
|
10
|
+
field :plate , type: String
|
|
11
|
+
field :engine_feeding , type: Symbol
|
|
12
|
+
|
|
13
|
+
belongs_to :version
|
|
14
|
+
|
|
15
|
+
validates :fabrication_year , numericality: { only_integer: true, allow_nil: true, greater_than: 0 }
|
|
16
|
+
validates :model_year , numericality: { only_integer: true, allow_nil: true, greater_than: 0 }
|
|
17
|
+
# Only allowing nil because motorcycle sometimes comes with unknown feeding type
|
|
18
|
+
validates :engine_feeding , inclusion: { in: ENGINE_FEEDINGS_NAMES, allow_nil: true }
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# TODO implement provider domain creation configuration method on include Provided
|
|
22
|
+
|
|
23
|
+
# Provider data on an vehicle entity must be scoped within the
|
|
24
|
+
# version
|
|
25
|
+
field :provider_id , type: String
|
|
26
|
+
field :provider , type: Symbol
|
|
27
|
+
|
|
28
|
+
validates :provider_id, uniqueness: { allow_nil: true, scope: :version_id }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Levtera::Concerns
|
|
2
|
+
|
|
3
|
+
module Version
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
BODY_TYPES = %i(covertible coupe pickup minivan truck)
|
|
7
|
+
TRANSMISSION_TYPES = %i(mechanic automatic semi-automatic)
|
|
8
|
+
|
|
9
|
+
included do
|
|
10
|
+
include Provided
|
|
11
|
+
|
|
12
|
+
# TODO implement array validator
|
|
13
|
+
# http://zogovic.com/post/32932492190/how-to-validate-array-fields-in-mongoid
|
|
14
|
+
field :name , type: String
|
|
15
|
+
field :engine_displacements, type: Array
|
|
16
|
+
field :tractions , type: Array
|
|
17
|
+
field :powers , type: Array
|
|
18
|
+
field :doors_amounts , type: Array
|
|
19
|
+
field :valves_amounts , type: Array
|
|
20
|
+
field :body_types , type: Array
|
|
21
|
+
field :transmission_types , type: Array
|
|
22
|
+
|
|
23
|
+
belongs_to :model
|
|
24
|
+
has_many :vehicles
|
|
25
|
+
|
|
26
|
+
# TODO figure out why this is commented
|
|
27
|
+
# TODO implement array validator
|
|
28
|
+
# validates :powers , numericality: { only_integer: true, allow_nil: true, greater_than: 0 }
|
|
29
|
+
# validates :doors_amounts , numericality: { only_integer: true, allow_nil: true, greater_than_or_equal_to: 0 }
|
|
30
|
+
# validates :valves_amounts , numericality: { only_integer: true, allow_nil: true, greater_than: 0 }
|
|
31
|
+
# validates :body_types , inclusion: { in: BODY_TYPES }
|
|
32
|
+
# validates :transmission_types , inclusion: { in: TRANSMISSION_TYPES }
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
if defined?(RSpec)
|
|
2
|
+
require 'mongoid-rspec'
|
|
3
|
+
require 'fabrication'
|
|
4
|
+
|
|
5
|
+
root = Pathname.new(__FILE__).parent.parent.parent
|
|
6
|
+
|
|
7
|
+
Dir[root.join('spec', 'support', '**', '*.rb').to_s].each { |f| require f }
|
|
8
|
+
Dir[root.join('spec', 'fabricators', '**', '*.rb').to_s].each { |f| require f }
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
RSpec.configure do |config|
|
|
12
|
+
config.include Mongoid::Matchers
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
else
|
|
16
|
+
puts 'Cannot add levtera shared examples, RSpec not defined!'
|
|
17
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'active_support'
|
|
2
|
+
|
|
3
|
+
module Levtera
|
|
4
|
+
# levtera version
|
|
5
|
+
VERSION = "0.2.1"
|
|
6
|
+
|
|
7
|
+
module Concerns
|
|
8
|
+
extend ActiveSupport::Autoload
|
|
9
|
+
|
|
10
|
+
autoload :Provided
|
|
11
|
+
autoload :Make
|
|
12
|
+
autoload :Model
|
|
13
|
+
autoload :Version
|
|
14
|
+
autoload :Vehicle
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/levtera.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'levtera/version'
|