sixarm_ruby_migration_helper_extensions 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 31b928178a99fe07a06b43da5d774309893310bc0b2f5cc921128d0e9debf13c
4
+ data.tar.gz: 280e66028e93230891d668885c4f062ee32ae0cf0ba3bfac7a45751bbfa4e9fe
5
+ SHA512:
6
+ metadata.gz: 85fa31dae1edf1415220ec8cce1da52b02eab3aae8cd206ee7edfc1ae5a6fc20c09f60a89b8d8f71a5485a10e7d0c2bcceb08c5d3b375208d99c05c204a8613c
7
+ data.tar.gz: 7987a4ffcdcbe5e004ec01c1cd66f10f09c99d7d891d47bf2c785c37b27127382251cd142f36f5db5ada9abc99bc4b4e038d2900f7c2ccf5f5672705ca78dba9
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "rake"
3
+ require "rake/testtask"
4
+
5
+ task :default => :test
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs.push("lib", "test")
9
+ t.pattern = "test/**/*.rb"
10
+ end
@@ -0,0 +1,197 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Please see README
4
+ =end
5
+
6
+ module Ddb
7
+ module SixArm
8
+
9
+ module MigrationHelper
10
+
11
+ def self.included(base) # :nodoc:
12
+ base.send(:include, InstanceMethods)
13
+ end
14
+
15
+ module InstanceMethods
16
+
17
+ ##
18
+ #
19
+ # Contact
20
+ #
21
+ ##
22
+
23
+ ##
24
+ # Name
25
+ #
26
+ def name(column_name=:name)
27
+ column(column_name, :string)
28
+ index(column_name)
29
+ end
30
+
31
+ ##
32
+ # email: string limit is 320 because the email spec has pieces
33
+ # that total to 320, though then trims the limit to 254.
34
+ #
35
+ def email(column_name=:email)
36
+ column(column_name, :string, limit: 320)
37
+ index(column_name)
38
+ end
39
+
40
+ ##
41
+ # phone: string limit is 75 because that's our arbitrary limit,
42
+ # and long enough for international numbers and extensions.
43
+ #
44
+ def phone(column_name=:phone)
45
+ column(column_name, :string)
46
+ index(column_name)
47
+ end
48
+
49
+ ##
50
+ # uri: string is unlimited.
51
+ #
52
+ def uri(column_name=:uri)
53
+ column(column_name, :string)
54
+ index(column_name)
55
+ end
56
+
57
+ ##
58
+ #
59
+ # Size
60
+ #
61
+ ##
62
+
63
+ def height (column_name=:height) column(column_name, :decimal, precision: 13, scale: 10) end
64
+ def length (column_name=:length) column(column_name, :decimal, precision: 13, scale: 10) end
65
+ def width (column_name=:width) column(column_name, :decimal, precision: 13, scale: 10) end
66
+ def depth (column_name=:depth) column(column_name, :decimal, precision: 13, scale: 10) end
67
+ def mass (column_name=:mass) column(column_name, :decimal, precision: 13, scale: 10) end
68
+
69
+ ##
70
+ #
71
+ # Geolocation
72
+ #
73
+ ##
74
+
75
+ def latitude (column_name=:latitude) column(column_name, :decimal, precision: 13, scale: 10); index(column_name); end
76
+ def longitude (column_name=:longitude) column(column_name, :decimal, precision: 13, scale: 10); index(column_name); end
77
+ def altitude (column_name=:altitude) column(column_name, :decimal, precision: 13, scale: 10); index(column_name); end
78
+
79
+ def geolocation
80
+ latitude
81
+ longitude
82
+ altitude
83
+ end
84
+
85
+ ##
86
+ #
87
+ # Vendors
88
+ #
89
+ ##
90
+
91
+ def freebase(column_name=:freebase)
92
+ column(column_name, :string)
93
+ end
94
+
95
+ ##
96
+ #
97
+ # Administration
98
+ #
99
+ ##
100
+
101
+ ##
102
+ # uuid_string: we sometimes like to use UUID strings;
103
+ # for efficiency, we suggest using a database-native format.
104
+ #
105
+ def uuid_string(column_name=:uuid_string)
106
+ column(column_name, :string, limit: 36)
107
+ index(column_name, unique: true)
108
+ end
109
+
110
+ ##
111
+ # parent_id: we sometimes use parent-child relationships,
112
+ # where `parent_id` points to the parent row.
113
+ #
114
+ def parent_id(column_name=:parent_id)
115
+ column(column_name, :integer)
116
+ index(column_name)
117
+ end
118
+
119
+ ##
120
+ # position: we sometimes like to use ordered lists,
121
+ # where the `position` is the list position.
122
+ #
123
+ def position(column_name=:position)
124
+ column(column_name, :integer)
125
+ index(column_name)
126
+ end
127
+
128
+ ##
129
+ # state: we sometimes like to use state machines,
130
+ # where the `state` is an integer enumeration.
131
+ #
132
+ def state(column_name=:state)
133
+ column(column_name, :integer)
134
+ index(column_name)
135
+ end
136
+
137
+ ##
138
+ # lock_version: Rails row locking using either
139
+ # optimistic locking or pessimistic locking.
140
+ #
141
+ def lock_version(column_name=:lock_version)
142
+ column(column_name, :integer)
143
+ index(column_name)
144
+ end
145
+
146
+ ##
147
+ # type: Rails single table inheritance (STI)
148
+ # uses a magic field name `type`.
149
+ #
150
+ def type(column_name=:type)
151
+ column(column_name, :string)
152
+ index(column_name)
153
+ end
154
+
155
+ ##
156
+ # auditstamps: we like to track what's happening to a row,
157
+ # by using typical Rails timestamps and then some more.
158
+ #
159
+ def auditstamps
160
+ column(:created_at, :datetime); index(:created_at); column(:created_by, :integer); index(:created_by)
161
+ column(:updated_at, :datetime); index(:updated_at); column(:updated_by, :integer); index(:updated_by)
162
+ column(:proofed_at, :datetime); index(:proofed_at); column(:proofed_by, :integer); index(:proofed_by)
163
+ column(:retired_at, :datetime); index(:retired_at); column(:retired_by, :integer); index(:retired_by)
164
+ end
165
+
166
+ ##
167
+ # Database administration
168
+ #
169
+ # We build many Rails apps and we like to add some columns
170
+ # that help with database administration and easy growth.
171
+ #
172
+ # We like to add these columns during setup, even if we don't
173
+ # use them, because they make syncronization easy, and they
174
+ # work with some of our data auditing shared code.
175
+ #
176
+ # Use what you like, customize as you like, YMMV, etc.
177
+ #
178
+ def dba
179
+ uuid_string
180
+ auditstamps
181
+ lock_version
182
+ state
183
+ parent_id
184
+ position
185
+ type
186
+ end
187
+
188
+ end
189
+ end
190
+ end
191
+ end
192
+
193
+ require "active_record"
194
+ if defined?(ActiveRecord::ConnectionAdapters::TableDefinition)
195
+ ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Ddb::SixArm::MigrationHelper)
196
+ end
197
+
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "minitest/autorun"
3
+ require "simplecov"
4
+ SimpleCov.start
5
+ require "sixarm_ruby_active_record_migration_mock"
6
+ require "sixarm_ruby_migration_helper_extensions"
7
+
8
+ class Testing < Minitest::Test
9
+
10
+ def test_columns
11
+ CreateFoos.up
12
+ for col in [:email,:freebase,:height,:latitude,:length,:longitude,:phone,:thickness,:uri,:weight,:width] do
13
+ assert(ActiveRecordMigrationMock.tables['foos'].has_column?(col),"has_column?(:#{col})")
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+
20
+ class ActiveRecordMigrationTableMock
21
+ include Ddb::SixArm::MigrationHelper
22
+ end
23
+
24
+
25
+ class CreateFoos < ActiveRecordMigrationMock
26
+
27
+ def self.up
28
+ create_table 'foos', :force => true do |t|
29
+ t.email
30
+ t.freebase
31
+ t.height
32
+ t.latitude
33
+ t.latitude
34
+ t.length
35
+ t.longitude
36
+ t.phone
37
+ t.thickness
38
+ t.uri
39
+ t.weight
40
+ t.width
41
+ end
42
+ end
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sixarm_ruby_migration_helper_extensions
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: ruby
6
+ authors:
7
+ - SixArm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIFPDCCAyQCCQDx7Y5LWGuPPzANBgkqhkiG9w0BAQsFADBgMQswCQYDVQQGEwJV
14
+ UzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEP
15
+ MA0GA1UECgwGU2l4QXJtMRMwEQYDVQQDDApzaXhhcm0uY29tMB4XDTE4MDExMzIy
16
+ NDYyM1oXDTIwMTAwOTIy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wt1sgA823Rl35WVSMqiyoxwsrGFwMtayNrrlpdhB8Ny8CMA2NfKyEJkh4+xlE72a
33
+ D8Eu8NFr9Tt5lHWXdZBI5BhzhQxPPxeIuw0wZ3+kiwxRie7K4XhKsOIrPmu2i6QV
34
+ Yl/663wZgWpqrroSnc3PE3lsuTW7quUvayjtqMTU2qrh7i21oB+/Nn+I6gcxYJZb
35
+ UlK+tvsqoM94U6sFTjw9mDt62MLQGrJtHShS+ZZiGmWj1sKreuwGJnCVDoBk15xa
36
+ oqlvfvLAMBCqlfrHhvGUfbIMgzb9uXNmCjzYMsQxuIgF6IMis6Kq02NBAR91HPMe
37
+ 2RoY7CdBHMxW+O0tgS2xoQbOwb+ti1j4MbsWpCqS9Mteck0Z7jZpRRrUDjXU+/7Z
38
+ RmW9HX0oLIoCBDChCcEKG0Ma4IvHUgjv47f5iYpkXuhifiK4xMG/s+T5Euw3Wg9J
39
+ tzpk/VnZXj7Ek/earx+N/Z+Wtnl2xENm5IF8SFPeI1HFa9NH47pqtxF1YKpNIEVc
40
+ 2xa2BNHSePe7tys/2hbmZuyMu8X5ERmovsabSXB3a+YwtJh5c2jhA21wF7986s0q
41
+ -----END CERTIFICATE-----
42
+ date: 2018-03-04 00:00:00.000000000 Z
43
+ dependencies:
44
+ - !ruby/object:Gem::Dependency
45
+ name: activerecord
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.0.0
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '999'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.0.0
61
+ - - "<"
62
+ - !ruby/object:Gem::Version
63
+ version: '999'
64
+ - !ruby/object:Gem::Dependency
65
+ name: minitest
66
+ requirement: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 5.7.0
71
+ - - "<"
72
+ - !ruby/object:Gem::Version
73
+ version: '6'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 5.7.0
81
+ - - "<"
82
+ - !ruby/object:Gem::Version
83
+ version: '6'
84
+ - !ruby/object:Gem::Dependency
85
+ name: sixarm_ruby_minitest_extensions
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.0.8
91
+ - - "<"
92
+ - !ruby/object:Gem::Version
93
+ version: '2'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.0.8
101
+ - - "<"
102
+ - !ruby/object:Gem::Version
103
+ version: '2'
104
+ - !ruby/object:Gem::Dependency
105
+ name: rake
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">"
109
+ - !ruby/object:Gem::Version
110
+ version: 10.4.2
111
+ - - "<"
112
+ - !ruby/object:Gem::Version
113
+ version: '11'
114
+ type: :development
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">"
119
+ - !ruby/object:Gem::Version
120
+ version: 10.4.2
121
+ - - "<"
122
+ - !ruby/object:Gem::Version
123
+ version: '11'
124
+ - !ruby/object:Gem::Dependency
125
+ name: simplecov
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 0.10.0
131
+ - - "<"
132
+ - !ruby/object:Gem::Version
133
+ version: '2'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 0.10.0
141
+ - - "<"
142
+ - !ruby/object:Gem::Version
143
+ version: '2'
144
+ - !ruby/object:Gem::Dependency
145
+ name: coveralls
146
+ requirement: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: 0.8.2
151
+ - - "<"
152
+ - !ruby/object:Gem::Version
153
+ version: '2'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 0.8.2
161
+ - - "<"
162
+ - !ruby/object:Gem::Version
163
+ version: '2'
164
+ - !ruby/object:Gem::Dependency
165
+ name: sixarm_ruby_active_record_migration_mock
166
+ requirement: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 1.0.8
171
+ - - "<"
172
+ - !ruby/object:Gem::Version
173
+ version: '999'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 1.0.8
181
+ - - "<"
182
+ - !ruby/object:Gem::Version
183
+ version: '999'
184
+ description: Migration helper extensions for Ruby On Rails development
185
+ email: sixarm@sixarm.com
186
+ executables: []
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - Rakefile
191
+ - lib/sixarm_ruby_migration_helper_extensions.rb
192
+ - test/sixarm_ruby_migration_helper_extensions_test.rb
193
+ homepage: http://sixarm.com/
194
+ licenses:
195
+ - Apache-2.0
196
+ - Artistic-2.0
197
+ - BSD-3-Clause
198
+ - GPL-3.0
199
+ - MIT
200
+ - MPL-2.0
201
+ metadata: {}
202
+ post_install_message:
203
+ rdoc_options: []
204
+ require_paths:
205
+ - lib
206
+ required_ruby_version: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '2.2'
211
+ required_rubygems_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ requirements: []
217
+ rubyforge_project:
218
+ rubygems_version: 2.7.6
219
+ signing_key:
220
+ specification_version: 4
221
+ summary: SixArm.com → Ruby → Migration helper extensions
222
+ test_files:
223
+ - test/sixarm_ruby_migration_helper_extensions_test.rb
metadata.gz.sig ADDED
Binary file