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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b6183c14afe0fbc490c8fd341755859b7c922f8
4
- data.tar.gz: a1dfeee3659a6909c439a88824629cc013356c1f
3
+ metadata.gz: 56d1b76a8cec09c228b30899af9ad9a0f0a4923f
4
+ data.tar.gz: 44a198a47c6bda5bcf014059ec82a26f70f909ed
5
5
  SHA512:
6
- metadata.gz: 4448025cfe3eb0cac0d7c055b4d55699f3500e9a9725c1f193d724510273bfc9c2b8a06559363ff8f08f3342852f84be7f9b18a0804c8b1b937faa8b196b618d
7
- data.tar.gz: 41c5c530c6820226fb0d2478990fe6b379f22110eb4fad285a4f637ec27538bceeacd46015eb48369593f16db6873b5ec0138e77b18b9bc775e77eada1d40f9a
6
+ metadata.gz: 618a9eb5d467125ff276be6ca8efbc869dfddc45f5be3c6ef7bccda2b37872d6e10f3aff3d857b88a80f6247c33e425a38f7159784d95670ff00d341ae20ec72
7
+ data.tar.gz: f4e18024eaff84859586100dfcfdb5cb45acffe817e327dd8a68a97591946ae738458a048b0e127a4b691c4edd6210f4d2863ef76e0025c200cadecfb6eb1000
data/Appraisals CHANGED
@@ -1,7 +1,9 @@
1
1
  appraise "rails-4.2" do
2
2
  gem "rails", "4.2.0"
3
+ gem "tzinfo-data"
3
4
  end
4
5
 
5
6
  appraise "rails-5.0" do
6
7
  gem "rails", "5.0.0"
8
+ gem "tzinfo-data"
7
9
  end
data/Dockerfile ADDED
@@ -0,0 +1,16 @@
1
+ FROM ruby:2.5.1-alpine
2
+ MAINTAINER wyatt@apsis.io
3
+
4
+ RUN apk add --no-cache --update \
5
+ bash \
6
+ alpine-sdk \
7
+ sqlite-dev
8
+
9
+ ENV APP_HOME /app
10
+ WORKDIR $APP_HOME
11
+
12
+ COPY . $APP_HOME/
13
+
14
+ EXPOSE 3000
15
+
16
+ CMD ["bash"]
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.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # runOnDocker SERVICE
4
+ runOnDocker() {
5
+ if [[ $DOCKER_CONTAINER -ne 1 ]]; then
6
+ echo "On Host. Executing command on container"
7
+ docker-compose exec -T $1 $0
8
+ exit $?
9
+ fi
10
+ }
11
+
12
+ export -f runOnDocker
data/bin/run_tests ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ source bin/helpers/docker
3
+ runOnDocker ruby
4
+
5
+ echo "== Starting unit tests =="
6
+ bundle exec appraisal rails-5.0 rake test
7
+ if [ $? -ne 0 ]; then
8
+ echo -e "\n== Tests failed; push aborted! ==\n"
9
+ exit 1
10
+ fi
data/bin/setup CHANGED
@@ -3,5 +3,5 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
- bundle install
6
+ bundle check || bundle install
7
7
  bundle exec appraisal install
@@ -0,0 +1,3 @@
1
+ #! /bin/bash
2
+
3
+ docker-compose run ruby sh
data/docker/start.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ echo "Beginning Setup"
4
+ /app/bin/setup
5
+
6
+ echo "Environment Ready"
7
+ tail -f /etc/hosts
@@ -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:
@@ -3,5 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "4.2.0"
6
+ gem "tzinfo-data"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -3,5 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "5.0.0"
6
+ gem "tzinfo-data"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -6,10 +6,22 @@ module SlayerRails
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- include ActiveModel::Model
9
+ include ActiveModel::Validations
10
10
 
11
11
  def validate!
12
- raise Slayer::FormValidationError, errors unless valid?
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
@@ -1,3 +1,3 @@
1
1
  module SlayerRails
2
- VERSION = "0.3.3"
2
+ VERSION = '0.4.0.beta3'
3
3
  end
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', '~> 1.14'
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.3.3
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: 2018-05-14 00:00:00.000000000 Z
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: '1.14'
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: '1.14'
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: '0'
237
+ version: 1.3.1
231
238
  requirements: []
232
239
  rubyforge_project:
233
240
  rubygems_version: 2.6.13