mappd 0.0.3 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +64 -61
- data/README.md +31 -2
- data/_config.yml +1 -0
- data/lib/mappd.rb +5 -1
- data/lib/mappd/mappd.rb +4 -0
- data/lib/mappd/version.rb +1 -1
- data/mappd.gemspec +1 -4
- data/spec/mappd_spec.rb +14 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b2197c36a7c731c1d9ea706a7cab756b4c0e677389796d3b175e789037fc8f5
|
4
|
+
data.tar.gz: 13da94ecb98568882bf09288e2d76424fcc543c169f5496fffeb9443ba478ec5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49267d31ae70ed5c5fc0ce261da6a4f68923691e62e744212f0af6881546849f6ae4e3756bced865800f4a96a3968de8bfb0d7b74aa370a77cc14c807f7aad45
|
7
|
+
data.tar.gz: b4ed4b93e46d4569e32a6c183b88a9be5d3cd780d6ca8b2b216d9d55e3c43a0578ac087d8293991a7a3047404b20c15696108d68b441289d39a5c0862fc12112
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,32 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mappd (
|
5
|
-
activerecord (>=
|
4
|
+
mappd (6.0.1)
|
5
|
+
activerecord (>= 6.0.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (
|
11
|
-
activesupport (=
|
12
|
-
activerecord (
|
13
|
-
activemodel (=
|
14
|
-
activesupport (=
|
15
|
-
|
16
|
-
activesupport (5.2.0)
|
10
|
+
activemodel (6.0.3.2)
|
11
|
+
activesupport (= 6.0.3.2)
|
12
|
+
activerecord (6.0.3.2)
|
13
|
+
activemodel (= 6.0.3.2)
|
14
|
+
activesupport (= 6.0.3.2)
|
15
|
+
activesupport (6.0.3.2)
|
17
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
17
|
i18n (>= 0.7, < 2)
|
19
18
|
minitest (~> 5.1)
|
20
19
|
tzinfo (~> 1.1)
|
21
|
-
|
22
|
-
ast (2.4.
|
23
|
-
byebug (
|
24
|
-
coderay (1.1.
|
25
|
-
concurrent-ruby (1.
|
20
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
21
|
+
ast (2.4.1)
|
22
|
+
byebug (11.1.3)
|
23
|
+
coderay (1.1.3)
|
24
|
+
concurrent-ruby (1.1.6)
|
26
25
|
diff-lcs (1.3)
|
27
|
-
ffi (1.
|
26
|
+
ffi (1.13.1)
|
28
27
|
formatador (0.2.5)
|
29
|
-
guard (2.
|
28
|
+
guard (2.16.2)
|
30
29
|
formatador (>= 0.2.4)
|
31
30
|
listen (>= 2.7, < 4.0)
|
32
31
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -43,68 +42,72 @@ GEM
|
|
43
42
|
guard-rubocop (1.3.0)
|
44
43
|
guard (~> 2.0)
|
45
44
|
rubocop (~> 0.20)
|
46
|
-
i18n (1.
|
45
|
+
i18n (1.8.3)
|
47
46
|
concurrent-ruby (~> 1.0)
|
48
|
-
listen (3.1
|
49
|
-
rb-fsevent (~> 0.
|
50
|
-
rb-inotify (~> 0.9, >= 0.9.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
minitest (5.11.3)
|
47
|
+
listen (3.2.1)
|
48
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
49
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
50
|
+
lumberjack (1.2.5)
|
51
|
+
method_source (1.0.0)
|
52
|
+
minitest (5.14.1)
|
55
53
|
nenv (0.3.0)
|
56
|
-
notiffany (0.1.
|
54
|
+
notiffany (0.1.3)
|
57
55
|
nenv (~> 0.1)
|
58
56
|
shellany (~> 0.0)
|
59
|
-
parallel (1.
|
60
|
-
parser (2.
|
57
|
+
parallel (1.19.2)
|
58
|
+
parser (2.7.1.3)
|
61
59
|
ast (~> 2.4.0)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
method_source (~> 0.9.0)
|
60
|
+
pry (0.13.1)
|
61
|
+
coderay (~> 1.1)
|
62
|
+
method_source (~> 1.0)
|
66
63
|
rainbow (3.0.0)
|
67
|
-
rake (
|
68
|
-
rb-fsevent (0.10.
|
69
|
-
rb-inotify (0.
|
70
|
-
ffi (
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
rspec-
|
75
|
-
|
76
|
-
rspec-
|
77
|
-
rspec-
|
64
|
+
rake (13.0.1)
|
65
|
+
rb-fsevent (0.10.4)
|
66
|
+
rb-inotify (0.10.1)
|
67
|
+
ffi (~> 1.0)
|
68
|
+
regexp_parser (1.7.1)
|
69
|
+
rexml (3.2.4)
|
70
|
+
rspec (3.9.0)
|
71
|
+
rspec-core (~> 3.9.0)
|
72
|
+
rspec-expectations (~> 3.9.0)
|
73
|
+
rspec-mocks (~> 3.9.0)
|
74
|
+
rspec-core (3.9.2)
|
75
|
+
rspec-support (~> 3.9.3)
|
76
|
+
rspec-expectations (3.9.2)
|
78
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-mocks (3.
|
78
|
+
rspec-support (~> 3.9.0)
|
79
|
+
rspec-mocks (3.9.1)
|
81
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-support (3.
|
84
|
-
rubocop (0.
|
81
|
+
rspec-support (~> 3.9.0)
|
82
|
+
rspec-support (3.9.3)
|
83
|
+
rubocop (0.85.1)
|
85
84
|
parallel (~> 1.10)
|
86
|
-
parser (>= 2.
|
87
|
-
powerpack (~> 0.1)
|
85
|
+
parser (>= 2.7.0.1)
|
88
86
|
rainbow (>= 2.2.2, < 4.0)
|
87
|
+
regexp_parser (>= 1.7)
|
88
|
+
rexml
|
89
|
+
rubocop-ast (>= 0.0.3)
|
89
90
|
ruby-progressbar (~> 1.7)
|
90
|
-
unicode-display_width (
|
91
|
-
|
92
|
-
|
91
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
92
|
+
rubocop-ast (0.0.3)
|
93
|
+
parser (>= 2.7.0.1)
|
94
|
+
ruby-progressbar (1.10.1)
|
93
95
|
shellany (0.0.1)
|
94
|
-
shoulda-matchers (3.
|
95
|
-
activesupport (>= 4.
|
96
|
-
sqlite3 (1.
|
97
|
-
thor (0.
|
96
|
+
shoulda-matchers (4.3.0)
|
97
|
+
activesupport (>= 4.2.0)
|
98
|
+
sqlite3 (1.4.2)
|
99
|
+
thor (1.0.1)
|
98
100
|
thread_safe (0.3.6)
|
99
|
-
tzinfo (1.2.
|
101
|
+
tzinfo (1.2.7)
|
100
102
|
thread_safe (~> 0.1)
|
101
|
-
unicode-display_width (1.
|
103
|
+
unicode-display_width (1.7.0)
|
104
|
+
zeitwerk (2.3.0)
|
102
105
|
|
103
106
|
PLATFORMS
|
104
107
|
ruby
|
105
108
|
|
106
109
|
DEPENDENCIES
|
107
|
-
activerecord (>=
|
110
|
+
activerecord (>= 6.0.1)
|
108
111
|
byebug
|
109
112
|
guard-rspec
|
110
113
|
guard-rubocop
|
@@ -113,7 +116,7 @@ DEPENDENCIES
|
|
113
116
|
rspec
|
114
117
|
rubocop
|
115
118
|
shoulda-matchers
|
116
|
-
sqlite3
|
119
|
+
sqlite3 (~> 1.4.0)
|
117
120
|
|
118
121
|
BUNDLED WITH
|
119
|
-
1.
|
122
|
+
1.17.3
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Mappd
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/dan-watson/mappd.svg?branch=master)](https://travis-ci.org/dan-watson/mappd)
|
2
4
|
|
3
5
|
Mappd is a replacement gem for [mini_record](https://github.com/DAddYE/mini_record). Mini record is great and I have been using it for a number of years. Unfortunately the mini_record repo has not been updated in some time. With recent rails upgrades mini_record is not working well.
|
4
6
|
|
@@ -6,6 +8,20 @@ Mappd is designed to work with ActiveRecord 5.2 >.
|
|
6
8
|
|
7
9
|
It's simple to use.
|
8
10
|
|
11
|
+
## Setup
|
12
|
+
|
13
|
+
```
|
14
|
+
gem install mappd
|
15
|
+
```
|
16
|
+
|
17
|
+
Or add to your `Gemfile`:
|
18
|
+
|
19
|
+
```
|
20
|
+
gem 'mappd'
|
21
|
+
```
|
22
|
+
|
23
|
+
## Models
|
24
|
+
|
9
25
|
```ruby
|
10
26
|
class Person < ActiveRecord::Base
|
11
27
|
field :name, :string, null: false, default: ''
|
@@ -17,6 +33,9 @@ class Person < ActiveRecord::Base
|
|
17
33
|
field :external_id, :string, length: 10
|
18
34
|
rename :external_id, :e_id
|
19
35
|
field :e_id, :string, length: 10
|
36
|
+
# Delete a field - the old field and drop could be removed after
|
37
|
+
# migrate! is called
|
38
|
+
drop :name
|
20
39
|
|
21
40
|
# Hooks into belongs_to and creates a country_id column
|
22
41
|
# with an index
|
@@ -56,7 +75,7 @@ Role.migrate!
|
|
56
75
|
|
57
76
|
Hey presto your database has been created with the correct schema.
|
58
77
|
|
59
|
-
|
78
|
+
## Types & Options - Field
|
60
79
|
|
61
80
|
```field :name, :type, options = {}```
|
62
81
|
|
@@ -92,5 +111,15 @@ Available options are (none of these exists by default):
|
|
92
111
|
|
93
112
|
```:comment``` - Specifies the comment for the column. This option is ignored by some backends.
|
94
113
|
|
114
|
+
## Using Rails?
|
95
115
|
|
116
|
+
Create a `mappd.rb` initializer inside `config/initializers` and add the following code to auto migrate rails models on every application restart.
|
96
117
|
|
118
|
+
```ruby
|
119
|
+
Dir.glob('app/models/**/*.rb').each do |file_path|
|
120
|
+
basename = File.basename(file_path, File.extname(file_path))
|
121
|
+
clazz = basename.camelize.constantize
|
122
|
+
next if clazz.abstract_class
|
123
|
+
clazz.migrate! if clazz.ancestors.include?(ActiveRecord::Base)
|
124
|
+
end
|
125
|
+
```
|
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-cayman
|
data/lib/mappd.rb
CHANGED
data/lib/mappd/mappd.rb
CHANGED
@@ -12,6 +12,10 @@ module Mappd
|
|
12
12
|
commands << [:rename_column, [table_name, from, to]]
|
13
13
|
end
|
14
14
|
|
15
|
+
def drop(name)
|
16
|
+
commands << [:remove_column, [table_name, name]]
|
17
|
+
end
|
18
|
+
|
15
19
|
def field(name, type = :string, options = {})
|
16
20
|
commands << [:add_column, [table_name, name, type, options]]
|
17
21
|
end
|
data/lib/mappd/version.rb
CHANGED
data/mappd.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
3
2
|
require 'mappd/version'
|
4
3
|
|
@@ -23,7 +22,5 @@ at you just know in others projects like DataMapper or MongoMapper.
|
|
23
22
|
.split("\n").map { |f| File.basename(f) }
|
24
23
|
s.require_paths = ['lib']
|
25
24
|
|
26
|
-
|
27
|
-
# s.add_development_dependency "rspec"
|
28
|
-
s.add_dependency 'activerecord', '>=5.2.0'
|
25
|
+
s.add_dependency 'activerecord', '>=6.0.1'
|
29
26
|
end
|
data/spec/mappd_spec.rb
CHANGED
@@ -31,9 +31,22 @@ RSpec.describe Person, type: :model do
|
|
31
31
|
before(:all) do
|
32
32
|
Person.field(:age, :string)
|
33
33
|
Person.migrate!
|
34
|
+
Person.rename(:age, :ages)
|
35
|
+
Person.migrate!
|
36
|
+
end
|
37
|
+
|
38
|
+
it { should have_db_column(:ages).of_type(:string) }
|
39
|
+
end
|
40
|
+
|
41
|
+
context '#delete column' do
|
42
|
+
before(:all) do
|
43
|
+
Person.field(:ages, :string)
|
44
|
+
Person.migrate!
|
45
|
+
Person.drop(:ages)
|
46
|
+
Person.migrate!
|
34
47
|
end
|
35
48
|
|
36
|
-
it {
|
49
|
+
it { should_not have_db_column(:ages).of_type(:string) }
|
37
50
|
end
|
38
51
|
end
|
39
52
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mappd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Watson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.1
|
27
27
|
description: "With it you can add the ability to create columns\noutside the default
|
28
28
|
schema, directly in your model in a similar way t\nat you just know in others projects
|
29
29
|
like DataMapper or MongoMapper.\n "
|
@@ -36,12 +36,14 @@ files:
|
|
36
36
|
- ".gitignore"
|
37
37
|
- ".rspec"
|
38
38
|
- ".rubocop.yml"
|
39
|
+
- ".travis.yml"
|
39
40
|
- Dockerfile
|
40
41
|
- Gemfile
|
41
42
|
- Gemfile.lock
|
42
43
|
- Guardfile
|
43
44
|
- Makefile
|
44
45
|
- README.md
|
46
|
+
- _config.yml
|
45
47
|
- docker-compose.yml
|
46
48
|
- lib/mappd.rb
|
47
49
|
- lib/mappd/mappd.rb
|
@@ -69,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
71
|
- !ruby/object:Gem::Version
|
70
72
|
version: '0'
|
71
73
|
requirements: []
|
72
|
-
|
73
|
-
rubygems_version: 2.7.6
|
74
|
+
rubygems_version: 3.0.3
|
74
75
|
signing_key:
|
75
76
|
specification_version: 4
|
76
77
|
summary: Mappd is a micro gem that allow you to write schema inside your model as
|