activerecord-mysql-enum 0.1.1 → 1.0.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +29 -0
  5. data/Appraisals +13 -0
  6. data/CHANGELOG.md +36 -1
  7. data/Gemfile +4 -1
  8. data/Gemfile.lock +51 -2
  9. data/README.md +3 -19
  10. data/Rakefile +15 -2
  11. data/app/assets/config/manifest.js +0 -0
  12. data/app/assets/images/.keep +0 -0
  13. data/app/assets/javascripts/application.js +16 -0
  14. data/app/assets/stylesheets/application.css +15 -0
  15. data/app/controllers/application_controller.rb +5 -0
  16. data/app/controllers/concerns/.keep +0 -0
  17. data/app/helpers/application_helper.rb +2 -0
  18. data/app/mailers/.keep +0 -0
  19. data/app/models/.keep +0 -0
  20. data/app/models/concerns/.keep +0 -0
  21. data/app/views/layouts/application.html.erb +14 -0
  22. data/bin/bundle +3 -0
  23. data/bin/rails +4 -0
  24. data/bin/rake +4 -0
  25. data/bin/setup +29 -0
  26. data/config/application.rb +35 -0
  27. data/config/boot.rb +3 -0
  28. data/config/database.yml +19 -0
  29. data/config/environment.rb +5 -0
  30. data/config/environments/development.rb +41 -0
  31. data/config/environments/production.rb +79 -0
  32. data/config/environments/test.rb +42 -0
  33. data/config/initializers/assets.rb +11 -0
  34. data/config/initializers/backtrace_silencers.rb +7 -0
  35. data/config/initializers/cookies_serializer.rb +3 -0
  36. data/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/config/initializers/inflections.rb +16 -0
  38. data/config/initializers/mime_types.rb +4 -0
  39. data/config/initializers/session_store.rb +3 -0
  40. data/config/initializers/to_time_preserves_timezone.rb +10 -0
  41. data/config/initializers/wrap_parameters.rb +14 -0
  42. data/config/locales/en.yml +23 -0
  43. data/config/routes.rb +56 -0
  44. data/config/secrets.yml +22 -0
  45. data/db/schema.rb +26 -0
  46. data/db/seeds.rb +7 -0
  47. data/enum_column.gemspec +1 -0
  48. data/gemfiles/.bundle/config +2 -0
  49. data/gemfiles/rails_4.gemfile +14 -0
  50. data/gemfiles/rails_5.gemfile +14 -0
  51. data/gemfiles/rails_6.gemfile +14 -0
  52. data/lib/active_record/mysql/enum.rb +0 -5
  53. data/lib/active_record/mysql/enum/enum_column_adapter.rb +38 -91
  54. data/lib/active_record/mysql/enum/mysql_adapter.rb +35 -26
  55. data/lib/active_record/mysql/enum/version.rb +1 -1
  56. data/lib/activerecord-mysql-enum.rb +1 -0
  57. data/log/.keep +0 -0
  58. data/public/404.html +67 -0
  59. data/public/422.html +67 -0
  60. data/public/500.html +66 -0
  61. data/public/favicon.ico +0 -0
  62. data/public/robots.txt +5 -0
  63. metadata +68 -6
  64. data/lib/active_record/mysql/enum/active_record_helper.rb +0 -65
  65. data/lib/active_record/mysql/enum/enum_adapter.rb +0 -27
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysql-enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pohodnya
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-18 00:00:00.000000000 Z
12
+ date: 2020-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -31,6 +31,20 @@ dependencies:
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '7'
34
+ - !ruby/object:Gem::Dependency
35
+ name: mysql2
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.5
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.5
34
48
  description: Enable enum type for the MySQL Adapter in ActiveRecord
35
49
  email:
36
50
  - development@invoca.com
@@ -41,17 +55,58 @@ files:
41
55
  - ".dependabot/config.yml"
42
56
  - ".github/workflows/gem_release.yml"
43
57
  - ".gitignore"
58
+ - ".rspec"
59
+ - ".travis.yml"
60
+ - Appraisals
44
61
  - CHANGELOG.md
45
62
  - Gemfile
46
63
  - Gemfile.lock
47
64
  - LICENSE
48
65
  - README.md
49
66
  - Rakefile
67
+ - app/assets/config/manifest.js
68
+ - app/assets/images/.keep
69
+ - app/assets/javascripts/application.js
70
+ - app/assets/stylesheets/application.css
71
+ - app/controllers/application_controller.rb
72
+ - app/controllers/concerns/.keep
73
+ - app/helpers/application_helper.rb
74
+ - app/mailers/.keep
75
+ - app/models/.keep
76
+ - app/models/concerns/.keep
77
+ - app/views/layouts/application.html.erb
78
+ - bin/bundle
79
+ - bin/rails
80
+ - bin/rake
81
+ - bin/setup
82
+ - config/application.rb
83
+ - config/boot.rb
84
+ - config/database.yml
85
+ - config/environment.rb
86
+ - config/environments/development.rb
87
+ - config/environments/production.rb
88
+ - config/environments/test.rb
89
+ - config/initializers/assets.rb
90
+ - config/initializers/backtrace_silencers.rb
91
+ - config/initializers/cookies_serializer.rb
92
+ - config/initializers/filter_parameter_logging.rb
93
+ - config/initializers/inflections.rb
94
+ - config/initializers/mime_types.rb
95
+ - config/initializers/session_store.rb
96
+ - config/initializers/to_time_preserves_timezone.rb
97
+ - config/initializers/wrap_parameters.rb
98
+ - config/locales/en.yml
99
+ - config/routes.rb
100
+ - config/secrets.yml
101
+ - db/schema.rb
102
+ - db/seeds.rb
50
103
  - enum_column.gemspec
104
+ - gemfiles/.bundle/config
105
+ - gemfiles/rails_4.gemfile
106
+ - gemfiles/rails_5.gemfile
107
+ - gemfiles/rails_6.gemfile
51
108
  - init.rb
52
109
  - lib/active_record/mysql/enum.rb
53
- - lib/active_record/mysql/enum/active_record_helper.rb
54
- - lib/active_record/mysql/enum/enum_adapter.rb
55
110
  - lib/active_record/mysql/enum/enum_column_adapter.rb
56
111
  - lib/active_record/mysql/enum/enum_type.rb
57
112
  - lib/active_record/mysql/enum/mysql_adapter.rb
@@ -59,6 +114,13 @@ files:
59
114
  - lib/active_record/mysql/enum/schema_definitions.rb
60
115
  - lib/active_record/mysql/enum/validations.rb
61
116
  - lib/active_record/mysql/enum/version.rb
117
+ - lib/activerecord-mysql-enum.rb
118
+ - log/.keep
119
+ - public/404.html
120
+ - public/422.html
121
+ - public/500.html
122
+ - public/favicon.ico
123
+ - public/robots.txt
62
124
  - rails/init.rb
63
125
  homepage: http://github.com/Invoca/activerecord-mysql-enum
64
126
  licenses: []
@@ -76,9 +138,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
138
  version: '0'
77
139
  required_rubygems_version: !ruby/object:Gem::Requirement
78
140
  requirements:
79
- - - ">="
141
+ - - ">"
80
142
  - !ruby/object:Gem::Version
81
- version: '0'
143
+ version: 1.3.1
82
144
  requirements: []
83
145
  rubygems_version: 3.0.1
84
146
  signing_key:
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if defined?(Rails::Generator)
4
- module Rails
5
- module Generator
6
- class GeneratedAttribute
7
- def field_type_with_enumerated_attribute
8
- return (@field_type = :enum_select) if type == :enum
9
- field_type_without_enumerated_attribute
10
- end
11
- alias_method_chain :field_type, :enumerated_attribute
12
- end
13
- end
14
- end
15
- end
16
-
17
- if defined?(ActionView::Base)
18
- module ActionView
19
- module Helpers
20
-
21
- #form_options_helper.rb
22
- module FormOptionsHelper
23
- #def select
24
- def enum_select(object, method, options={}, html_options={})
25
- InstanceTag.new(object, method, self, options.delete(:object)).to_enum_select_tag(options, html_options)
26
- end
27
- end
28
-
29
- class InstanceTag
30
- def to_enum_select_tag(options, html_options={})
31
- if self.object.respond_to?(method_name.to_sym)
32
- column = self.object.column_for_attribute(method_name)
33
- if (value = self.object.__send__(method_name.to_sym))
34
- options[:selected] ||= value.to_s
35
- else
36
- options[:include_blank] = column.null if options[:include_blank].nil?
37
- end
38
- end
39
- to_select_tag(column.limit, options, html_options)
40
- end
41
-
42
- #initialize record_name, method, self
43
- if respond_to?(:to_tag)
44
- def to_tag_with_enumerated_attribute(options={})
45
- #look for an enum
46
- if (column_type == :enum && self.object.class.respond_to?(method_name.to_sym))
47
- to_enum_select_tag(options)
48
- else
49
- to_tag_without_enumerated_attribute(options)
50
- end
51
- end
52
- alias_method_chain :to_tag, :enumerated_attribute
53
- end
54
-
55
- end
56
-
57
- class FormBuilder
58
- def enum_select(method, options={}, html_options={})
59
- @template.enum_select(@object_name, method, objectify_options(options), @default_options.merge(html_options))
60
- end
61
- end
62
-
63
- end
64
- end
65
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This module provides all the column helper methods to deal with the
4
- # values and adds the common type management code for the adapters.
5
-
6
- adapter_class = if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter
7
- ActiveRecord::ConnectionAdapters::Mysql2Adapter
8
- elsif defined? ActiveRecord::ConnectionAdapters::MysqlAdapter
9
- ActiveRecord::ConnectionAdapters::MysqlAdapter
10
- end
11
-
12
- if adapter_class
13
- adapter_class.class_eval do
14
-
15
- protected
16
- if instance_methods.include?(:initialize_type_map)
17
- def initialize_type_map_with_enum_types(m)
18
- initialize_type_map_without_enum_types(m)
19
- m.register_type(%r(enum)i) do |sql_type|
20
- limit = sql_type.sub(/^enum\('(.+)'\)/i, '\1').split("','").map { |v| v.intern }
21
- ActiveRecord::Type::Enum.new(limit: limit)
22
- end
23
- end
24
- alias_method_chain :initialize_type_map, :enum_types
25
- end
26
- end
27
- end