better_record 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b34680cbdfc9ffc808911351efc1e7694a8ba71d7b3cfb8420cfed2af6cbc2ef
4
- data.tar.gz: f0940956cf68e9043664be86359be4c0fe60a0c01165ab0e8c430547a2ee1957
3
+ metadata.gz: 803f9edf13136798110fca60d3190054e93b256ef2287e3ee9743ea6ae50c930
4
+ data.tar.gz: 30d0949b3e9b30188c701a733217066eeb16ad785a9a4bcbf5f243d449d7dca0
5
5
  SHA512:
6
- metadata.gz: 826c96881eeb3caaa6cc37bf72adfc9dbba9a78a30854a63954295c57717e41bf96e7013de9f5c5d6700d4f61c6fd50a22eeb117d3752e60d9bdace03dce4d41
7
- data.tar.gz: a1a368f27c284f95b99639cd839d17fde9b2e6d9331f4101262658b08b29a77c7d42cab718fd4671ae86f5ac5d3d37e24acd113ed7846912b65f9cedda4af0ba
6
+ metadata.gz: cadeb2d9eef8f3d021710c349a0d2f7816b49f64735ee261a7a9ccc8db542338fcadac3587417e4c5640cb2a49f8e64628f8abb85a55125fbe55a50efd9dd591
7
+ data.tar.gz: d94df2c8f318fa7bccd97b1ebb31b4cdabcafd37ea07cbbec0be27febe2ba4d729a1d4dfa061d26afd59d23f7cc76ac0f57739f6a09b921007f2c7afb3cc7646
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ load 'rails/tasks/engine.rake'
10
10
 
11
11
  Bundler::GemHelper.install_tasks
12
12
 
13
- Dir[File.join(File.dirname(__FILE__), 'lib/tasks/**/*.rake')].each {|f| load f }
13
+ Dir[File.join(File.dirname(__FILE__), 'lib/better_record/tasks/**/*.rake')].each {|f| load f }
14
14
 
15
15
  require 'rspec/core'
16
16
  require 'rspec/core/rake_task'
data/lib/better_record.rb CHANGED
@@ -32,3 +32,9 @@ ActiveSupport.on_load(:active_record) do
32
32
  end
33
33
  include BetterRecord::NullifyBlankAttributes
34
34
  end
35
+ # !centered[## [Men's Results](/assets/pdfs/2018-golf-international-results-male.pdf)--br--[![Mens Results](/assets/images/2018-golf-international-results-male.jpg)](/assets/pdfs/2018-golf-international-results-male.pdf)]
36
+ # !centered[## [Women's Results](/assets/pdfs/2018-golf-international-results-female.pdf)--br--[![Womens Results](/assets/images/2018-golf-international-results-female.jpg)](/assets/pdfs/2018-golf-international-results-female.pdf)]
37
+ # !centered[## [Team Results](/assets/pdfs/2018-golf-international-results-team.pdf)--br--[![Team Results](/assets/images/2018-golf-international-results-team)](/assets/pdfs/2018-golf-international-results-team.pdf)]
38
+ #
39
+ # !centered[## [Team Results](/assets/pdfs/2018-golf-international-results-summary.pdf)--br--[![Team Results](/assets/images/2018-golf-international-results-summary.jpg)](/assets/pdfs/2018-golf-international-results-summary.pdf)]
40
+ # !centered[## [Individual Results](/assets/pdfs/2018-golf-international-results.pdf)--br--[![Team Results](/assets/images/2018-golf-international-results.jpg)](/assets/pdfs/2018-golf-international-results.pdf)]
@@ -1,6 +1,7 @@
1
1
  module BetterRecord
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace BetterRecord
4
+
4
5
  config.generators do |g|
5
6
  g.templates.unshift File::expand_path("../templates", File.dirname(__FILE__))
6
7
  g.test_framework :rspec, :fixture => false
@@ -1,4 +1,9 @@
1
1
  module BetterRecord
2
2
  class Railtie < ::Rails::Railtie
3
+ rake_tasks do
4
+ Dir[File.expand_path('/tasks/**/*.rake', __dir__)].each do |f|
5
+ load f
6
+ end
7
+ end
3
8
  end
4
9
  end
@@ -0,0 +1,6 @@
1
+ namespace :better_record do
2
+ desc 'run better record setup'
3
+ task install: :environment do |t, args|
4
+ sh 'rails generate better_record:setup'
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module BetterRecord
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -6,52 +6,51 @@ class BetterRecord::SetupGenerator < ActiveRecord::Generators::Base
6
6
  argument :name, type: :string, default: 'testes'
7
7
  class_option :eject, type: :boolean, default: false
8
8
 
9
- def copy_migrations
10
- rake("better_record:install:migrations")
9
+ def run_generator
10
+ copy_templates
11
+ copy_migrations
12
+ gsub_files
11
13
  end
12
14
 
13
- def copy_templates
14
- template 'gitattributes', '.gitattributes'
15
- template 'gitignore', '.gitignore'
16
- template 'irbrc', '.irbrc'
17
- template 'jsbeautifyrc', '.jsbeautifyrc'
18
- template 'pryrc', '.pryrc'
19
- template 'rspec', '.rspec'
20
- template 'ruby-version', '.ruby-version'
21
- template 'initializer.rb', 'config/initializers/better_record.rb'
22
- directory "#{BetterRecord::Engine.root}/lib/templates", 'lib/templates'
23
- template "#{BetterRecord::Engine.root}/spec/method_helper.rb", 'spec/method_helper.rb'
24
- directory "#{BetterRecord::Engine.root}/spec/method_helper", 'spec/method_helper'
25
- directory "tasks", 'lib/tasks'
26
-
27
- eject_files if !!options['eject']
28
- end
29
-
30
- def gsub_files
31
- eager_line = 'config.eager_load_paths += Dir["#{config.root}/lib/modules/**/"]'
32
- structure_line = 'config.active_record.schema_format'
33
-
34
- gsub_file 'config/application.rb', /([ \t]*?(#{Regexp.escape(eager_line)}|#{Regexp.escape(structure_line)})[ ='":]*?(rb|sql)?['"]?[ \t0-9\.]*?)\n/mi do |match|
35
- ""
15
+ private
16
+ def audit_schema
17
+ @audit_schema ||= options['audit_schema'].presence || 'auditing'
36
18
  end
37
19
 
38
- gsub_file 'config/application.rb', /#{Regexp.escape("config.load_defaults")}[ 0-9\.]+\n/mi do |match|
39
- "#{match} #{eager_line}\n #{structure_line} = :sql"
20
+ def copy_migrations
21
+ rake("better_record:install:migrations")
40
22
  end
41
23
 
42
- gsub_file 'app/models/application_record.rb', /(#{Regexp.escape("class ApplicationRecord < ActiveRecord::Base")})/mi do |match|
43
- p match
44
- "class ApplicationRecord < BetterRecord::Base"
24
+ def copy_templates
25
+ template 'gitattributes', '.gitattributes'
26
+ template 'gitignore', '.gitignore'
27
+ template 'irbrc', '.irbrc'
28
+ template 'jsbeautifyrc', '.jsbeautifyrc'
29
+ template 'pryrc', '.pryrc'
30
+ template 'rspec', '.rspec'
31
+ template 'ruby-version', '.ruby-version'
32
+ template 'initializer.rb', 'config/initializers/better_record.rb'
33
+ directory "#{BetterRecord::Engine.root}/lib/templates", 'lib/templates'
34
+
35
+ eject_files if !!options['eject']
45
36
  end
46
- end
47
37
 
48
- def copy_migrations
49
- rake("better_record:install:migrations")
50
- end
38
+ def gsub_files
39
+ eager_line = 'config.eager_load_paths += Dir["#{config.root}/lib/modules/**/"]'
40
+ structure_line = 'config.active_record.schema_format'
51
41
 
52
- private
53
- def audit_schema
54
- @audit_schema ||= options['audit_schema'].presence || 'auditing'
42
+ gsub_file 'config/application.rb', /([ \t]*?(#{Regexp.escape(eager_line)}|#{Regexp.escape(structure_line)})[ ='":]*?(rb|sql)?['"]?[ \t0-9\.]*?)\n/mi do |match|
43
+ ""
44
+ end
45
+
46
+ gsub_file 'config/application.rb', /#{Regexp.escape("config.load_defaults")}[ 0-9\.]+\n/mi do |match|
47
+ "#{match} #{eager_line}\n #{structure_line} = :sql\n"
48
+ end
49
+
50
+ gsub_file 'app/models/application_record.rb', /(#{Regexp.escape("class ApplicationRecord < ActiveRecord::Base")})/mi do |match|
51
+ p match
52
+ "class ApplicationRecord < BetterRecord::Base"
53
+ end
55
54
  end
56
55
 
57
56
  def eject_files
@@ -9,16 +9,25 @@
9
9
  # Ignore the default SQLite database.
10
10
  /db/*.sqlite3
11
11
  /db/*.sqlite3-journal
12
+ /**/db/*.sqlite3
13
+ /**/db/*.sqlite3-journal
12
14
 
13
15
  # Ignore all logfiles and tempfiles.
14
- /log/*
15
16
  /tmp/*
16
- !/log/.keep
17
+ /**/tmp/*
17
18
  !/tmp/.keep
19
+ !/**/tmp/.keep
20
+ /log/*
21
+ /**/log/*
22
+ !/log/.keep
23
+ !/**/log/.keep
24
+ /**/yarn-error.log
18
25
 
19
26
  # Ignore uploaded files in development and files that will be compiled in production
20
27
  /public/*
28
+ /**/dummy/public/*
21
29
  /storage/*
30
+ /**/dummy/storage/*
22
31
  !/public/.keep
23
32
  !/storage/.keep
24
33
 
@@ -42,3 +51,6 @@
42
51
  *.log*
43
52
  *.rdb
44
53
  !Gemfile.lock
54
+
55
+ .bundle/
56
+ pkg/
@@ -13,7 +13,7 @@ module BetterRecord
13
13
  # uncomment the following line to use table_names instead of model names
14
14
  # as the 'type' value in polymorphic relationships
15
15
 
16
- # self.default_polymorphic_method = :polymorphic_name
16
+ # self.default_polymorphic_method = :table_name
17
17
 
18
18
  # uncomment the following line to use change the database schema
19
19
  # for auditing functions and logged_actions. DEFAULT - 'auditing'
@@ -1,42 +1,46 @@
1
1
  og_print = Pry.config.print
2
2
 
3
3
  Pry.config.print = proc do |output, value, *args|
4
- if (ActiveRecord::Base === value) ||
5
- (ActiveRecord::Relation === value)
6
- is_relation = ActiveRecord::Relation === value
7
- base = (is_relation ? value.limit(1).first : value)
8
- i = 0
9
- idx = {' #' => ->(*args) { " #{i += 1}" }}
10
- keys = [
11
- idx, *(
12
- (
13
- base ? (
14
- (
15
- (base.class.first).present? &&
16
- (base.class.first.attributes.keys - base.attributes.keys).present?
17
- ) ?
18
- base.attributes.keys :
19
- (base.class.respond_to?(:default_print) ? base.class.default_print : base.class.column_names)
20
- ) : (value.klass.respond_to?(:default_print) ? value.klass.default_print : value.klass.column_names)
4
+ begin
5
+ if (ActiveRecord::Base === value) ||
6
+ (ActiveRecord::Relation === value)
7
+ is_relation = ActiveRecord::Relation === value
8
+ base = (is_relation ? value.limit(1).first : value)
9
+ i = 0
10
+ idx = {' #' => ->(*args) { " #{i += 1}" }}
11
+ keys = [
12
+ idx, *(
13
+ (
14
+ base ? (
15
+ (
16
+ (base.class.first).present? &&
17
+ (base.class.first.attributes.keys - base.attributes.keys).present?
18
+ ) ?
19
+ base.attributes.keys :
20
+ (base.class.respond_to?(:default_print) ? base.class.default_print : base.class.column_names)
21
+ ) : (value.klass.respond_to?(:default_print) ? value.klass.default_print : value.klass.column_names)
22
+ )
21
23
  )
22
- )
23
- ]
24
- puts "\n"
25
- if is_relation
26
- sz = 0
27
- begin
28
- tp value, keys if value.size > 0
29
- sz = value.size
30
- rescue
31
- tp value, keys if value.size.size > 0
32
- sz = value.size.size
24
+ ]
25
+ puts "\n"
26
+ if is_relation
27
+ sz = 0
28
+ begin
29
+ tp value, keys if value.size > 0
30
+ sz = value.size
31
+ rescue
32
+ tp value, keys if value.size.size > 0
33
+ sz = value.size.size
34
+ end
35
+ puts "\n #{sz} rows returned" if is_relation
36
+ else
37
+ tp value, keys
33
38
  end
34
- puts "\n #{sz} rows returned" if is_relation
39
+ puts "\n"
35
40
  else
36
- tp value, keys
41
+ og_print.call output, value, *args
37
42
  end
38
- puts "\n"
39
- else
43
+ rescue
40
44
  og_print.call output, value, *args
41
45
  end
42
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley
@@ -201,6 +201,8 @@ files:
201
201
  - lib/better_record/rspec/extensions/has_valid_factory.rb
202
202
  - lib/better_record/rspec/extensions/optional_column.rb
203
203
  - lib/better_record/rspec/extensions/required_column.rb
204
+ - lib/better_record/tasks/better_record/install.rake
205
+ - lib/better_record/tasks/spec/attributes.rake
204
206
  - lib/better_record/version.rb
205
207
  - lib/generators/better_record/eject_rspec_extensions/USAGE
206
208
  - lib/generators/better_record/eject_rspec_extensions/eject_rspec_extensions_generator.rb
@@ -214,7 +216,6 @@ files:
214
216
  - lib/generators/better_record/setup/templates/pryrc
215
217
  - lib/generators/better_record/setup/templates/rspec
216
218
  - lib/generators/better_record/setup/templates/ruby-version
217
- - lib/tasks/spec/attributes.rake
218
219
  - lib/templates/active_record/model/model.rb
219
220
  - lib/templates/migration/templates/create_table_migration.rb
220
221
  - lib/templates/rspec/model/model_spec.rb