slayer_rails 0.4.0.beta4 → 0.5.0.beta

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
- SHA1:
3
- metadata.gz: 192013fb216e6826fb4f266f91877cd969a9c3fa
4
- data.tar.gz: dfe6ac7132934840e5e08a29810afd38b8636fe7
2
+ SHA256:
3
+ metadata.gz: c67f706f583469977288be1dd8114ec79bbca6f13f676d9bd71767d47e3423a1
4
+ data.tar.gz: 9f97911c6825359b2c04b6d715abcb7835268c914022705530b8ad5dd4fda8a9
5
5
  SHA512:
6
- metadata.gz: d60b04b36cbe90c9b18f38467226f0039c550c64102b5b94b757fdff0188064e3403bde8183e3cf5fe6c86065ab0163bbfd5cf9a6f37852c33f0b2509643a4d3
7
- data.tar.gz: 5657351315c691f4758dc68190ed1a2acd3ec421e0de97ebd68b895f1a0029694ef260b539b90b0ce31d07948086eba5e5a0749512799fd3abe2805f10954024
6
+ metadata.gz: e2fc7da7f190526cc491a99f9f12f2cb517d75685a66c71db91564c1c3c0bd2dcfa57f3e5301d966c98fb8db4ebd80d34d02249daf7a87f5cb7aa45f23c5da2c
7
+ data.tar.gz: a67ba310656947024f2001864cd1157cc2fb595a462e14f0b9585398476236ef1e2b43c089b74bac65c69d4228837c4166d56ddec78b057bcff5d83eddf898ea
@@ -0,0 +1,28 @@
1
+ # .github/workflows/release.yml
2
+
3
+ name: Release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ pull_request:
8
+
9
+ jobs:
10
+ release:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 3.0.0
17
+ - run: bundle install
18
+ - name: publish gem
19
+ run: |
20
+ mkdir -p $HOME/.gem
21
+ touch $HOME/.gem/credentials
22
+ chmod 0600 $HOME/.gem/credentials
23
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
24
+ gem build *.gemspec
25
+ gem push *.gem
26
+ env:
27
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
28
+
@@ -0,0 +1,31 @@
1
+ name: Test & Lint
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.7']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ - name: Install dependencies
24
+ run: |
25
+ bundle install
26
+ bundle exec appraisal install
27
+ RAILS_ENV=test bundle exec rake dummy:db:reset
28
+ - name: Rubocop
29
+ run: rubocop
30
+ - name: Run tests
31
+ run: bundle exec appraisal rspec
data/.gitignore CHANGED
@@ -11,6 +11,6 @@
11
11
  *Gemfile.lock
12
12
  .byebug_history
13
13
 
14
- /test/sample/tmp/
14
+ /spec/dummy/tmp/
15
15
  *.sqlite3
16
16
  *.log
data/.rubocop.yml ADDED
@@ -0,0 +1,66 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 3.1
5
+ Include:
6
+ - 'lib/**/*.rb'
7
+ - 'test/**/*.rb'
8
+ - 'spec/**/*.rb'
9
+ - '**/Gemfile'
10
+ - '**/Rakefile'
11
+ Exclude:
12
+ - 'bin/**/*'
13
+ - 'spec/fixtures/**/*.rb'
14
+ - 'spec/dummy/**/*.rb'
15
+ - 'lib/generators/**/templates/**'
16
+
17
+ Style/HashSyntax:
18
+ EnforcedShorthandSyntax: never
19
+
20
+ Style/Documentation:
21
+ Enabled: false
22
+
23
+ Naming/BlockForwarding:
24
+ Enabled: false
25
+
26
+ Style/RedundantSelf:
27
+ Enabled: false
28
+
29
+ Style/RedundantReturn:
30
+ Enabled: false
31
+
32
+ Style/GuardClause:
33
+ Enabled: false
34
+
35
+ Style/ClassAndModuleChildren:
36
+ Enabled: false
37
+
38
+ Layout/EmptyLinesAroundClassBody:
39
+ Enabled: false
40
+
41
+ Style/FrozenStringLiteralComment:
42
+ Enabled: false
43
+
44
+ Layout/CommentIndentation:
45
+ Enabled: false
46
+
47
+ Layout/LineLength:
48
+ Max: 120
49
+
50
+ Metrics/ClassLength:
51
+ Max: 120
52
+
53
+ Layout/EmptyLineBetweenDefs:
54
+ AllowAdjacentOneLineDefs: true
55
+
56
+ Naming/MethodParameterName:
57
+ AllowedNames:
58
+ - _
59
+
60
+ Style/ClassVars:
61
+ Exclude:
62
+ - 'lib/slayer/service.rb'
63
+
64
+ Style/MutableConstant:
65
+ Exclude:
66
+ - 'lib/slayer/version.rb'
data/Appraisals CHANGED
@@ -1,9 +1,11 @@
1
- appraise "rails-4.2" do
2
- gem "rails", "4.2.0"
3
- gem "tzinfo-data"
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'rails_6.1' do
4
+ gem 'rails', '6.1'
5
+ gem 'tzinfo-data'
4
6
  end
5
7
 
6
- appraise "rails-5.0" do
7
- gem "rails", "5.0.0"
8
- gem "tzinfo-data"
8
+ appraise 'rails_7.0' do
9
+ gem 'rails', '7.0'
10
+ gem 'tzinfo-data'
9
11
  end
data/Dockerfile CHANGED
@@ -1,16 +1,18 @@
1
- FROM ruby:2.5.1-alpine
2
- MAINTAINER wyatt@apsis.io
1
+ FROM ruby:2.7-buster
3
2
 
4
- RUN apk add --no-cache --update \
5
- bash \
6
- alpine-sdk \
7
- sqlite-dev
3
+ RUN apt-get update -qq && apt-get install -y --no-install-recommends \
4
+ build-essential \
5
+ git \
6
+ bash \
7
+ sqlite3
8
8
 
9
9
  ENV APP_HOME /app
10
10
  WORKDIR $APP_HOME
11
11
 
12
12
  COPY . $APP_HOME/
13
13
 
14
+ RUN bundle config set force_ruby_platform true
15
+
14
16
  EXPOSE 3000
15
17
 
16
18
  CMD ["bash"]
data/Gemfile CHANGED
@@ -1,4 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in slayer_rails.gemspec
4
6
  gemspec
7
+
8
+ gem 'appraisal'
9
+ gem 'byebug'
10
+ gem 'nokogiri'
11
+ gem 'rspec-rails'
12
+ gem 'sqlite3'
13
+ gem 'tzinfo-data'
data/Rakefile CHANGED
@@ -1,15 +1,15 @@
1
- require "rubygems"
2
- require "bundler/setup"
1
+ # frozen_string_literal: true
3
2
 
4
- require "bundler/gem_tasks"
5
- require "rake/testtask"
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ require 'bundler/gem_tasks'
6
6
 
7
- require "./tasks/db"
7
+ require 'rake'
8
+ require 'rspec/core/rake_task'
8
9
 
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << "test"
11
- t.libs << "lib"
12
- t.test_files = FileList['test/**/*_test.rb']
10
+ namespace :dummy do
11
+ require_relative 'spec/dummy/application'
12
+ Dummy::Application.load_tasks
13
13
  end
14
14
 
15
- task :default => :test
15
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "slayer_rails"
4
+ require 'bundler/setup'
5
+ require 'slayer_rails'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "slayer_rails"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -5,3 +5,5 @@ set -vx
5
5
 
6
6
  bundle check || bundle install
7
7
  bundle exec appraisal install
8
+
9
+ RAILS_ENV=test bundle exec rake dummy:db:reset
@@ -0,0 +1,14 @@
1
+ en:
2
+ commands:
3
+ good_customer:
4
+ awesome_product:
5
+ run_foo_bar:
6
+ demo: It Lives
7
+ transaction:
8
+ demo: Command
9
+ services:
10
+ transaction:
11
+ demo: Service
12
+ forms:
13
+ person:
14
+ demo: Form
data/config.ru ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+
6
+ Bundler.require :default, :development
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreatePerson < ActiveRecord::Migration[6.0]
4
+ def change
5
+ create_table :people do |t|
6
+ t.string :name
7
+ t.integer :age
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
data/db/schema.rb ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated from the current state of the database. Instead
4
+ # of editing this file, please use the migrations feature of Active Record to
5
+ # incrementally modify your database, and then regenerate this schema definition.
6
+ #
7
+ # This file is the source Rails uses to define your schema when running `bin/rails
8
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
9
+ # be faster and is potentially less error prone than running all of your
10
+ # migrations from scratch. Old migrations may fail to apply correctly if those
11
+ # migrations use external dependencies or application code.
12
+ #
13
+ # It's strongly recommended that you check this file into your version control system.
14
+
15
+ ActiveRecord::Schema.define(version: 20_170_214_100_255) do
16
+ create_table 'people', force: :cascade do |t|
17
+ t.string 'name'
18
+ t.integer 'age'
19
+ t.datetime 'created_at', precision: 6, null: false
20
+ t.datetime 'updated_at', precision: 6, null: false
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source 'https://rubygems.org'
6
+
7
+ gem 'appraisal'
8
+ gem 'byebug'
9
+ gem 'nokogiri'
10
+ gem 'rails', '6.1'
11
+ gem 'rspec-rails'
12
+ gem 'sqlite3'
13
+ gem 'tzinfo-data'
14
+
15
+ gemspec path: '../'
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source 'https://rubygems.org'
6
+
7
+ gem 'appraisal'
8
+ gem 'byebug'
9
+ gem 'nokogiri'
10
+ gem 'rails', '7.0'
11
+ gem 'rspec-rails'
12
+ gem 'sqlite3'
13
+ gem 'tzinfo-data'
14
+
15
+ gemspec path: '../'
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Slayer
2
4
  module Generators
3
5
  class CommandGenerator < NamedBase
4
- desc "This generator creates new Slayer::Commands"
6
+ desc 'This generator creates new Slayer::Commands'
5
7
 
6
- source_root File.expand_path("../templates", __FILE__)
7
- check_class_collision suffix: "Command"
8
+ source_root File.expand_path('templates', __dir__)
9
+ check_class_collision suffix: 'Command'
8
10
 
9
11
  def create_command_files
10
- template "command.rb", File.join("app", "commands", class_path, "#{file_name}_command.rb")
12
+ template 'command.rb', File.join('app', 'commands', class_path, "#{file_name}_command.rb")
11
13
  end
12
14
  end
13
15
  end
@@ -1,17 +1,17 @@
1
1
  <% module_namespacing do -%>
2
2
  class <%= class_name %>Command < Slayer::Command
3
- def call(<%= file_name %>_form:)
4
- fail! unless arguments_valid?(<%= file_name %>_form)
3
+ def call(args:)
4
+ return err unless args_valid?(args)
5
5
 
6
6
  transaction do
7
7
  # Do your database interaction here!
8
8
  end
9
9
 
10
- pass!
10
+ ok
11
11
  end
12
12
 
13
- def arguments_valid?(<%= file_name %>_form)
14
- <%= file_name %>_form.kind_of?(<%= class_name %>Form) && <%= file_name %>_form.valid?
13
+ def args_valid?(args)
14
+ true
15
15
  end
16
16
  end
17
17
  <% end -%>
@@ -1,22 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Slayer
2
4
  module Generators
3
5
  class FormGenerator < NamedBase
4
- desc "This generator creates new Slayer::Forms"
6
+ desc 'This generator creates new Slayer::Forms'
5
7
 
6
- source_root File.expand_path("../templates", __FILE__)
7
- check_class_collision suffix: "Form"
8
+ source_root File.expand_path('templates', __dir__)
9
+ check_class_collision suffix: 'Form'
8
10
 
9
11
  argument :name, type: :string
10
- argument :fields, :type => :array, :required => false, :desc => "The attributes of the generated form. name:String completed:Boolean"
12
+ argument :fields, type: :array, required: false,
13
+ desc: 'The attributes of the generated form. name:String completed:Boolean'
11
14
 
12
- def initialize(args, *options) #:nodoc:
15
+ def initialize(args, *options) # :nodoc:
13
16
  super
14
17
  args.shift
15
- @fields = args.map{|a| a.split(":")}
18
+ @fields = args.map { |a| a.split(':') }
16
19
  end
17
20
 
18
21
  def create_form_files
19
- template "form.rb", File.join("app", "forms", class_path, "#{file_name}_form.rb")
22
+ template 'form.rb', File.join('app', 'forms', class_path, "#{file_name}_form.rb")
20
23
  end
21
24
  end
22
25
  end
@@ -1,25 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Slayer
2
4
  module Generators
3
5
  class ScaffoldGenerator < NamedBase
4
- desc "This generator creates a new Slayer::Commands and a corresponding Slayer::Form"
6
+ desc 'This generator creates a new Slayer::Commands and a corresponding Slayer::Form'
5
7
 
6
- source_root File.expand_path("../templates", __FILE__)
7
- check_class_collision suffix: "Command"
8
+ source_root File.expand_path('templates', __dir__)
9
+ check_class_collision suffix: 'Command'
8
10
 
9
11
  argument :name, type: :string
10
- argument :fields, :type => :array, :required => false, :desc => "The attributes of the generated form. name:String completed:Boolean"
12
+ argument :fields, type: :array, required: false,
13
+ desc: 'The attributes of the generated form. name:String completed:Boolean'
11
14
 
12
- def initialize(args, *options) #:nodoc:
15
+ def initialize(args, *options) # :nodoc:
13
16
  super
14
17
  @args = args
15
18
  end
16
19
 
17
20
  def create_command_files
18
- generate "slayer:command", "#{file_name}"
21
+ generate 'slayer:command', file_name.to_s
19
22
  end
20
23
 
21
24
  def create_form_files
22
- generate "slayer:form", "#{@args.join(" ")}"
25
+ generate 'slayer:form', @args.join(' ').to_s
23
26
  end
24
27
  end
25
28
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
  require 'rails/generators/named_base'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
 
3
5
  module SlayerRails
@@ -5,11 +7,13 @@ module SlayerRails
5
7
  module Form
6
8
  extend ActiveSupport::Concern
7
9
 
10
+ # rubocop:disable Metrics/BlockLength
8
11
  included do
9
12
  include ActiveModel::Validations
10
13
 
11
14
  def validate!
12
15
  return if valid?
16
+
13
17
  message = errors.full_messages.join(', ')
14
18
  raise Slayer::FormValidationError, message unless valid?
15
19
  end
@@ -17,9 +21,9 @@ module SlayerRails
17
21
  def as_model(klass, attr_map = nil)
18
22
  all_attrs = klass.new.attributes.keys.map(&:to_sym)
19
23
  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
24
+
25
+ attrs = attr_map.transform_values do |val|
26
+ send(val)
23
27
  end
24
28
  klass.new(attrs)
25
29
  end
@@ -41,8 +45,8 @@ module SlayerRails
41
45
 
42
46
  def from_model(model)
43
47
  attr_hash = attribute_set.map(&:name)
44
- .select { |attr_name| model.respond_to?(attr_name) }
45
- .map { |attr_name| [attr_name, model.public_send(attr_name)] }
48
+ .select { |attr_name| model.respond_to?(attr_name) }
49
+ .map { |attr_name| [attr_name, model.public_send(attr_name)] }
46
50
 
47
51
  new(attr_hash.to_h)
48
52
  end
@@ -52,16 +56,17 @@ module SlayerRails
52
56
  end
53
57
 
54
58
  def validates_associated(*keys)
55
- self.validates_each(*keys) do |record, attr, value|
59
+ validates_each(*keys) do |record, attr, value|
56
60
  unless value.valid?
57
- value.errors.each do |field, err_message|
58
- record.errors.add(attr, "#{field} #{err_message}")
61
+ value.errors.each do |err|
62
+ record.errors.add(attr, "#{err.attribute} #{err.message}")
59
63
  end
60
64
  end
61
65
  end
62
66
  end
63
67
  end
64
68
  end
69
+ # rubocop:enable Metrics/BlockLength
65
70
  end
66
71
  end
67
72
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SlayerRails
2
4
  module Extensions
3
5
  module Transaction
@@ -1,42 +1,39 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SlayerRails
2
4
  module Extensions
3
5
  module Translation
4
6
  extend ActiveSupport::Concern
5
7
 
8
+ # rubocop:disable Metrics/BlockLength
6
9
  included do
7
- def translate(key, options={})
10
+ def translate(key, options = {})
8
11
  I18n.translate(self.class.full_key(key), options.dup)
9
12
  end
10
- alias :t :translate
11
-
13
+ alias_method :t, :translate
12
14
 
13
15
  def localize(*args)
14
16
  I18n.localize(*args)
15
17
  end
16
- alias :l :localize
17
-
18
+ alias_method :l, :localize
18
19
 
19
20
  class << self
20
21
  def full_key(key)
21
22
  return key unless key.start_with? '.'
22
23
 
23
- return "#{implied_path}#{key}"
24
+ "#{implied_path}#{key}"
24
25
  end
25
26
 
26
-
27
27
  def implied_path
28
28
  @implied_path ||= build_implied_path
29
29
  end
30
30
 
31
-
32
31
  def build_implied_path
33
- module_path = self.name.underscore.split('/')
32
+ module_path = name.underscore.split('/')
34
33
 
35
34
  class_name_parts = module_path.pop.split('_')
36
35
 
37
- if ['command', 'service', 'form'].include? class_name_parts.last
38
- class_name_parts.pop
39
- end
36
+ class_name_parts.pop if %w[command service form].include? class_name_parts.last
40
37
 
41
38
  module_path.unshift(slayer_type)
42
39
  module_path.push(class_name_parts.join('_'))
@@ -49,17 +46,14 @@ module SlayerRails
49
46
  end
50
47
 
51
48
  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}"
49
+ return 'commands' if self <= Slayer::Command
50
+ return 'forms' if self <= Slayer::Form
51
+
52
+ raise NotImplementedException, "Unknown Slayer Class: #{name}"
60
53
  end
61
54
  end
62
55
  end
56
+ # rubocop:enable Metrics/BlockLength
63
57
  end
64
58
  end
65
59
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SlayerRails
2
- VERSION = '0.4.0.beta4'
4
+ VERSION = '0.5.0.beta'
3
5
  end
data/lib/slayer_rails.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'active_model'
3
5
  require 'active_record'
@@ -10,7 +12,6 @@ require 'slayer_rails/extensions/translation'
10
12
 
11
13
  require 'generators/slayer_base'
12
14
  require 'generators/command/command_generator'
13
- require 'generators/service/service_generator'
14
15
  require 'generators/form/form_generator'
15
16
  require 'generators/scaffold/scaffold_generator'
16
17
 
@@ -24,9 +25,4 @@ module Slayer
24
25
  include SlayerRails::Extensions::Transaction
25
26
  include SlayerRails::Extensions::Translation
26
27
  end
27
-
28
- class Service
29
- include SlayerRails::Extensions::Transaction
30
- include SlayerRails::Extensions::Translation
31
- end
32
28
  end
data/slayer_rails.gemspec CHANGED
@@ -1,37 +1,31 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'slayer_rails/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "slayer_rails"
8
+ spec.name = 'slayer_rails'
8
9
  spec.version = SlayerRails::VERSION
9
- spec.authors = ["Wyatt Kirby"]
10
- spec.email = ["wyatt@apsis.io"]
10
+ spec.authors = ['Wyatt Kirby']
11
+ spec.email = ['wyatt@apsis.io']
11
12
 
12
- spec.summary = %q{Rails extensions for Slayer.}
13
- spec.homepage = "http://www.apsis.io"
14
- spec.license = "MIT"
13
+ spec.summary = 'Rails extensions for Slayer.'
14
+ spec.homepage = 'http://www.apsis.io'
15
+ spec.license = 'MIT'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
18
  f.match(%r{^(test|spec|features)/})
18
19
  end
19
20
 
20
- spec.bindir = "exe"
21
+ spec.bindir = 'exe'
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
23
+ spec.require_paths = ['lib']
23
24
 
24
- spec.add_runtime_dependency 'slayer', '> 0.3.0'
25
25
  spec.add_runtime_dependency 'rails', '>= 4.2.0'
26
+ spec.add_runtime_dependency 'slayer', '>= 0.5.0.beta'
26
27
 
27
- spec.add_development_dependency 'coveralls'
28
28
  spec.add_development_dependency 'bundler', '~> 2.0'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'appraisal', '~> 2.1'
31
- spec.add_development_dependency 'minitest', '~> 5.0'
32
- spec.add_development_dependency 'minitest-reporters', '~> 1.1'
33
- spec.add_development_dependency 'mocha', '~> 1.2'
34
- spec.add_development_dependency 'byebug', '~> 9.0'
35
- spec.add_development_dependency 'sqlite3', '~> 1.3'
36
- spec.add_development_dependency 'combustion', '~> 0.5.5'
29
+ spec.add_development_dependency 'rake', '~> 12.0'
30
+ spec.add_development_dependency 'rubocop', '= 1.38.0'
37
31
  end
data/tasks/db.rb CHANGED
@@ -1,45 +1,46 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # source: https://gist.github.com/schickling/6762581
2
4
 
3
5
  require 'slayer_rails'
4
6
  require 'active_record'
5
7
  require 'yaml'
6
8
 
7
- GEM_ROOT = File.dirname( __dir__ )
8
- DB_CONFIG = YAML.load(File.open('test/sample/config/database.yml'))
9
- SCHEMA_FILE = "#{GEM_ROOT}/test/sample/db/schema.rb"
10
- MIGRATION_DIR = "#{GEM_ROOT}/test/sample/db/migrate"
9
+ GEM_ROOT = File.dirname(__dir__)
10
+ DB_CONFIG = YAML.safe_load(File.open('spec/dummy/config/database.yml'))
11
+ SCHEMA_FILE = "#{GEM_ROOT}/spec/dummy/db/schema.rb"
12
+ MIGRATION_DIR = "#{GEM_ROOT}/spec/dummy/db/migrate"
11
13
 
12
14
  namespace :db do
13
- desc "Migrate the database"
15
+ desc 'Migrate the database'
14
16
  task :migrate do
15
17
  ActiveRecord::Base.establish_connection(DB_CONFIG)
16
18
  ActiveRecord::Migrator.migrate(MIGRATION_DIR)
17
- Rake::Task["db:schema"].invoke
18
- puts "Database migrated."
19
+ Rake::Task['db:schema'].invoke
20
+ puts 'Database migrated.'
19
21
  end
20
22
 
21
- desc "Create a db/schema.rb file that is portable against any supported DB"
23
+ desc 'Create a db/schema.rb file that is portable against any supported DB'
22
24
  task :schema do
23
25
  ActiveRecord::Base.establish_connection(DB_CONFIG)
24
26
  require 'active_record/schema_dumper'
25
27
 
26
- File.open(SCHEMA_FILE, "w:utf-8") do |file|
28
+ File.open(SCHEMA_FILE, 'w:utf-8') do |file|
27
29
  ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
28
30
  end
29
31
  end
30
32
  end
31
33
 
32
-
33
34
  namespace :g do
34
- desc "Generate migration"
35
+ desc 'Generate migration'
35
36
  task :migration do
36
- name = ARGV[1] || raise("Specify name: rake g:migration name")
37
- timestamp = Time.now.strftime("%Y%m%d%H%M%S")
37
+ name = ARGV[1] || raise('Specify name: rake g:migration name')
38
+ timestamp = Time.now.strftime('%Y%m%d%H%M%S')
38
39
  path = File.expand_path("#{MIGRATION_DIR}/#{timestamp}_#{name}.rb", __FILE__)
39
40
 
40
- migration_class = name.split("_").map(&:capitalize).join
41
+ migration_class = name.split('_').map(&:capitalize).join
41
42
 
42
- File.open(path, "w") do |file|
43
+ File.open(path, 'w') do |file|
43
44
  file.write <<-EOF.strip_heredoc
44
45
  class #{migration_class} < ActiveRecord::Migration
45
46
  def change
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slayer_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.beta4
4
+ version: 0.5.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wyatt Kirby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-22 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: slayer
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">"
18
- - !ruby/object:Gem::Version
19
- version: 0.3.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">"
25
- - !ruby/object:Gem::Version
26
- version: 0.3.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rails
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +25,19 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: 4.2.0
41
27
  - !ruby/object:Gem::Dependency
42
- name: coveralls
28
+ name: slayer
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
33
+ version: 0.5.0.beta
34
+ type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: 0.5.0.beta
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,112 +58,28 @@ dependencies:
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '10.0'
61
+ version: '12.0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '10.0'
68
+ version: '12.0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: appraisal
70
+ name: rubocop
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - "~>"
73
+ - - '='
88
74
  - !ruby/object:Gem::Version
89
- version: '2.1'
75
+ version: 1.38.0
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '2.1'
97
- - !ruby/object:Gem::Dependency
98
- name: minitest
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '5.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '5.0'
111
- - !ruby/object:Gem::Dependency
112
- name: minitest-reporters
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '1.1'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '1.1'
125
- - !ruby/object:Gem::Dependency
126
- name: mocha
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '1.2'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '1.2'
139
- - !ruby/object:Gem::Dependency
140
- name: byebug
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '9.0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '9.0'
153
- - !ruby/object:Gem::Dependency
154
- name: sqlite3
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '1.3'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '1.3'
167
- - !ruby/object:Gem::Dependency
168
- name: combustion
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: 0.5.5
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
80
+ - - '='
179
81
  - !ruby/object:Gem::Version
180
- version: 0.5.5
82
+ version: 1.38.0
181
83
  description:
182
84
  email:
183
85
  - wyatt@apsis.io
@@ -185,7 +87,10 @@ executables: []
185
87
  extensions: []
186
88
  extra_rdoc_files: []
187
89
  files:
90
+ - ".github/workflows/release.yml"
91
+ - ".github/workflows/test.yml"
188
92
  - ".gitignore"
93
+ - ".rubocop.yml"
189
94
  - ".travis.yml"
190
95
  - Appraisals
191
96
  - Dockerfile
@@ -193,22 +98,23 @@ files:
193
98
  - LICENSE.txt
194
99
  - README.md
195
100
  - Rakefile
101
+ - app/assets/config/manifest.js
196
102
  - bin/console
197
103
  - bin/helpers/docker
198
- - bin/run_tests
199
104
  - bin/setup
200
- - bin/ssh_to_container
105
+ - config.ru
106
+ - config/locales/en.yml
107
+ - db/migrate/20170214100255_create_person.rb
108
+ - db/schema.rb
201
109
  - docker-compose.yml
202
110
  - docker/start.sh
203
- - gemfiles/rails_4.2.gemfile
204
- - gemfiles/rails_5.0.gemfile
111
+ - gemfiles/rails_6.1.gemfile
112
+ - gemfiles/rails_7.0.gemfile
205
113
  - lib/generators/command/command_generator.rb
206
114
  - lib/generators/command/templates/command.rb
207
115
  - lib/generators/form/form_generator.rb
208
116
  - lib/generators/form/templates/form.rb
209
117
  - lib/generators/scaffold/scaffold_generator.rb
210
- - lib/generators/service/service_generator.rb
211
- - lib/generators/service/templates/service.rb
212
118
  - lib/generators/slayer_base.rb
213
119
  - lib/slayer_rails.rb
214
120
  - lib/slayer_rails/extensions/form.rb
@@ -236,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
142
  - !ruby/object:Gem::Version
237
143
  version: 1.3.1
238
144
  requirements: []
239
- rubyforge_project:
240
- rubygems_version: 2.6.13
145
+ rubygems_version: 3.2.3
241
146
  signing_key:
242
147
  specification_version: 4
243
148
  summary: Rails extensions for Slayer.
data/bin/run_tests DELETED
@@ -1,10 +0,0 @@
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/ssh_to_container DELETED
@@ -1,3 +0,0 @@
1
- #! /bin/bash
2
-
3
- docker-compose run ruby sh
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "4.2.0"
6
- gem "tzinfo-data"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "5.0.0"
6
- gem "tzinfo-data"
7
-
8
- gemspec path: "../"
@@ -1,14 +0,0 @@
1
- module Slayer
2
- module Generators
3
- class ServiceGenerator < NamedBase
4
- desc "This generator creates new Slayer::Services"
5
-
6
- source_root File.expand_path("../templates", __FILE__)
7
- check_class_collision suffix: "Service"
8
-
9
- def create_service_files
10
- template "service.rb", File.join("app", "services", class_path, "#{file_name}_service.rb")
11
- end
12
- end
13
- end
14
- end
@@ -1,6 +0,0 @@
1
- <% module_namespacing do -%>
2
- class <%= class_name %>Service < Slayer::Service
3
- class << self
4
- end
5
- end
6
- <% end -%>