slayer_rails 0.3.3 → 0.4.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +2 -0
- data/Dockerfile +16 -0
- data/README.md +8 -0
- data/bin/helpers/docker +12 -0
- data/bin/run_tests +10 -0
- data/bin/setup +1 -1
- data/bin/ssh_to_container +3 -0
- data/docker/start.sh +7 -0
- data/docker-compose.yml +19 -0
- data/gemfiles/rails_4.2.gemfile +2 -1
- data/gemfiles/rails_5.0.gemfile +2 -1
- data/lib/slayer_rails/extensions/form.rb +24 -2
- data/lib/slayer_rails/extensions/translation.rb +65 -0
- data/lib/slayer_rails/version.rb +1 -1
- data/lib/slayer_rails.rb +4 -0
- data/slayer_rails.gemspec +1 -1
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56d1b76a8cec09c228b30899af9ad9a0f0a4923f
|
4
|
+
data.tar.gz: 44a198a47c6bda5bcf014059ec82a26f70f909ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 618a9eb5d467125ff276be6ca8efbc869dfddc45f5be3c6ef7bccda2b37872d6e10f3aff3d857b88a80f6247c33e425a38f7159784d95670ff00d341ae20ec72
|
7
|
+
data.tar.gz: f4e18024eaff84859586100dfcfdb5cb45acffe817e327dd8a68a97591946ae738458a048b0e127a4b691c4edd6210f4d2863ef76e0025c200cadecfb6eb1000
|
data/Appraisals
CHANGED
data/Dockerfile
ADDED
data/README.md
CHANGED
@@ -31,3 +31,11 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/apsisl
|
|
31
31
|
## License
|
32
32
|
|
33
33
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
34
|
+
|
35
|
+
---
|
36
|
+
|
37
|
+
# Built by Apsis
|
38
|
+
|
39
|
+
[![apsis](https://s3-us-west-2.amazonaws.com/apsiscdn/apsis.png)](https://www.apsis.io)
|
40
|
+
|
41
|
+
`slayer_rails` was built by Apsis Labs. We love sharing what we build! Check out our [other libraries on Github](https://github.com/apsislabs), and if you like our work you can [hire us](https://www.apsis.io/work-with-us/) to build your vision.
|
data/bin/helpers/docker
ADDED
data/bin/run_tests
ADDED
data/bin/setup
CHANGED
data/docker/start.sh
ADDED
data/docker-compose.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
version: '3'
|
2
|
+
|
3
|
+
services:
|
4
|
+
ruby:
|
5
|
+
build: .
|
6
|
+
volumes:
|
7
|
+
- bundle_cache:/bundle
|
8
|
+
- .:/app
|
9
|
+
environment:
|
10
|
+
- BUNDLE_JOBS=5
|
11
|
+
- BUNDLE_PATH=/bundle
|
12
|
+
- BUNDLE_BIN=/bundle/bin
|
13
|
+
- GEM_HOME=/bundle
|
14
|
+
- DOCKER_CONTAINER=1
|
15
|
+
command:
|
16
|
+
- docker/start.sh
|
17
|
+
|
18
|
+
volumes:
|
19
|
+
bundle_cache:
|
data/gemfiles/rails_4.2.gemfile
CHANGED
data/gemfiles/rails_5.0.gemfile
CHANGED
@@ -6,10 +6,22 @@ module SlayerRails
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
-
include ActiveModel::
|
9
|
+
include ActiveModel::Validations
|
10
10
|
|
11
11
|
def validate!
|
12
|
-
|
12
|
+
return if valid?
|
13
|
+
message = errors.full_messages.join(', ')
|
14
|
+
raise Slayer::FormValidationError, message unless valid?
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_model(klass, attr_map = nil)
|
18
|
+
all_attrs = klass.new.attributes.keys.map(&:to_sym)
|
19
|
+
return klass.new(attributes.slice(*all_attrs)) if attr_map.nil?
|
20
|
+
attrs = attr_map.inject({}) do |memo, (key, val)|
|
21
|
+
memo[key] = self.send(val)
|
22
|
+
memo
|
23
|
+
end
|
24
|
+
klass.new(attrs)
|
13
25
|
end
|
14
26
|
|
15
27
|
class << self
|
@@ -38,6 +50,16 @@ module SlayerRails
|
|
38
50
|
def from_json(json)
|
39
51
|
from_params(JSON.parse(json))
|
40
52
|
end
|
53
|
+
|
54
|
+
def validates_associated(*keys)
|
55
|
+
self.validates_each(*keys) do |record, attr, value|
|
56
|
+
unless value.valid?
|
57
|
+
value.errors.each do |field, err_message|
|
58
|
+
record.errors.add(attr, "#{field} #{err_message}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
41
63
|
end
|
42
64
|
end
|
43
65
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module SlayerRails
|
2
|
+
module Extensions
|
3
|
+
module Translation
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
def translate(key, options={})
|
8
|
+
I18n.translate(self.class.full_key(key), options.dup)
|
9
|
+
end
|
10
|
+
alias :t :translate
|
11
|
+
|
12
|
+
|
13
|
+
def localize(*args)
|
14
|
+
I18n.localize(*args)
|
15
|
+
end
|
16
|
+
alias :l :localize
|
17
|
+
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def full_key(key)
|
21
|
+
return key unless key.start_with? '.'
|
22
|
+
|
23
|
+
return "#{implied_path}#{key}"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def implied_path
|
28
|
+
@implied_path ||= build_implied_path
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def build_implied_path
|
33
|
+
module_path = self.name.underscore.split('/')
|
34
|
+
|
35
|
+
class_name_parts = module_path.pop.split('_')
|
36
|
+
|
37
|
+
if ['command', 'service', 'form'].include? class_name_parts.last
|
38
|
+
class_name_parts.pop
|
39
|
+
end
|
40
|
+
|
41
|
+
module_path.unshift(slayer_type)
|
42
|
+
module_path.push(class_name_parts.join('_'))
|
43
|
+
|
44
|
+
module_path.join('.')
|
45
|
+
end
|
46
|
+
|
47
|
+
def slayer_type
|
48
|
+
@slayer_type ||= detect_slayer_type
|
49
|
+
end
|
50
|
+
|
51
|
+
def detect_slayer_type
|
52
|
+
if self <= Slayer::Command
|
53
|
+
return 'commands'
|
54
|
+
elsif self <= Slayer::Service
|
55
|
+
return 'services'
|
56
|
+
elsif self <= Slayer::Form
|
57
|
+
return 'forms'
|
58
|
+
end
|
59
|
+
raise NotImplementedException, "Unknown Slayer Class: #{self.name}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/slayer_rails/version.rb
CHANGED
data/lib/slayer_rails.rb
CHANGED
@@ -6,6 +6,7 @@ require 'slayer'
|
|
6
6
|
require 'slayer_rails/version'
|
7
7
|
require 'slayer_rails/extensions/form'
|
8
8
|
require 'slayer_rails/extensions/transaction'
|
9
|
+
require 'slayer_rails/extensions/translation'
|
9
10
|
|
10
11
|
require 'generators/slayer_base'
|
11
12
|
require 'generators/command/command_generator'
|
@@ -16,13 +17,16 @@ require 'generators/scaffold/scaffold_generator'
|
|
16
17
|
module Slayer
|
17
18
|
class Form
|
18
19
|
include SlayerRails::Extensions::Form
|
20
|
+
include SlayerRails::Extensions::Translation
|
19
21
|
end
|
20
22
|
|
21
23
|
class Command
|
22
24
|
include SlayerRails::Extensions::Transaction
|
25
|
+
include SlayerRails::Extensions::Translation
|
23
26
|
end
|
24
27
|
|
25
28
|
class Service
|
26
29
|
include SlayerRails::Extensions::Transaction
|
30
|
+
include SlayerRails::Extensions::Translation
|
27
31
|
end
|
28
32
|
end
|
data/slayer_rails.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_runtime_dependency 'rails', '>= 4.2.0'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'coveralls'
|
28
|
-
spec.add_development_dependency 'bundler', '~>
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
29
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
30
|
spec.add_development_dependency 'appraisal', '~> 2.1'
|
31
31
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slayer_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wyatt Kirby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slayer
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,12 +188,18 @@ files:
|
|
188
188
|
- ".gitignore"
|
189
189
|
- ".travis.yml"
|
190
190
|
- Appraisals
|
191
|
+
- Dockerfile
|
191
192
|
- Gemfile
|
192
193
|
- LICENSE.txt
|
193
194
|
- README.md
|
194
195
|
- Rakefile
|
195
196
|
- bin/console
|
197
|
+
- bin/helpers/docker
|
198
|
+
- bin/run_tests
|
196
199
|
- bin/setup
|
200
|
+
- bin/ssh_to_container
|
201
|
+
- docker-compose.yml
|
202
|
+
- docker/start.sh
|
197
203
|
- gemfiles/rails_4.2.gemfile
|
198
204
|
- gemfiles/rails_5.0.gemfile
|
199
205
|
- lib/generators/command/command_generator.rb
|
@@ -207,6 +213,7 @@ files:
|
|
207
213
|
- lib/slayer_rails.rb
|
208
214
|
- lib/slayer_rails/extensions/form.rb
|
209
215
|
- lib/slayer_rails/extensions/transaction.rb
|
216
|
+
- lib/slayer_rails/extensions/translation.rb
|
210
217
|
- lib/slayer_rails/version.rb
|
211
218
|
- slayer_rails.gemspec
|
212
219
|
- tasks/db.rb
|
@@ -225,9 +232,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
225
232
|
version: '0'
|
226
233
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
234
|
requirements:
|
228
|
-
- - "
|
235
|
+
- - ">"
|
229
236
|
- !ruby/object:Gem::Version
|
230
|
-
version:
|
237
|
+
version: 1.3.1
|
231
238
|
requirements: []
|
232
239
|
rubyforge_project:
|
233
240
|
rubygems_version: 2.6.13
|