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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc337a411672ab3426ea52e47a29e0ff26b584ca6d208d575de6d520c3e29527
4
- data.tar.gz: d0afa522e277f482ea096303adcccffd08fffa30031c9c545beb26e83b38492e
3
+ metadata.gz: 4b2197c36a7c731c1d9ea706a7cab756b4c0e677389796d3b175e789037fc8f5
4
+ data.tar.gz: 13da94ecb98568882bf09288e2d76424fcc543c169f5496fffeb9443ba478ec5
5
5
  SHA512:
6
- metadata.gz: 0b71039911641f03c1d4d3a70637e802fe2806c9eb1816a60907419bd387ba5aefef87da63438e14bb9caeaaf38d31e68194519ca32b5d33adabfc03383d29ca
7
- data.tar.gz: fe8a0e6430f2642ef22fb0909c9e2c215fd557b83612a16de5c35a258797183dce12e997665f458683d580ce4298627f4aa7569dbb17e7f7cbd5b40ef2fee738
6
+ metadata.gz: 49267d31ae70ed5c5fc0ce261da6a4f68923691e62e744212f0af6881546849f6ae4e3756bced865800f4a96a3968de8bfb0d7b74aa370a77cc14c807f7aad45
7
+ data.tar.gz: b4ed4b93e46d4569e32a6c183b88a9be5d3cd780d6ca8b2b216d9d55e3c43a0578ac087d8293991a7a3047404b20c15696108d68b441289d39a5c0862fc12112
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.5
4
+ install:
5
+ - gem install bundler
6
+ - bundle update --bundler
7
+ - bundle install
8
+ script:
9
+ - bundle exec rubocop
10
+ - bundle exec rspec
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'activerecord', '>= 5.2.0'
3
+ gem 'activerecord', '>= 6.0.1'
4
4
  gem 'rake'
5
- gem 'sqlite3'
5
+ gem 'sqlite3', '~> 1.4.0'
6
6
 
7
7
  group :development do
8
8
  gem 'byebug'
@@ -1,32 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mappd (0.0.3)
5
- activerecord (>= 5.2.0)
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 (5.2.0)
11
- activesupport (= 5.2.0)
12
- activerecord (5.2.0)
13
- activemodel (= 5.2.0)
14
- activesupport (= 5.2.0)
15
- arel (>= 9.0)
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
- arel (9.0.0)
22
- ast (2.4.0)
23
- byebug (10.0.2)
24
- coderay (1.1.2)
25
- concurrent-ruby (1.0.5)
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.9.23)
26
+ ffi (1.13.1)
28
27
  formatador (0.2.5)
29
- guard (2.14.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.0.1)
45
+ i18n (1.8.3)
47
46
  concurrent-ruby (~> 1.0)
48
- listen (3.1.5)
49
- rb-fsevent (~> 0.9, >= 0.9.4)
50
- rb-inotify (~> 0.9, >= 0.9.7)
51
- ruby_dep (~> 1.2)
52
- lumberjack (1.0.13)
53
- method_source (0.9.0)
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.1)
54
+ notiffany (0.1.3)
57
55
  nenv (~> 0.1)
58
56
  shellany (~> 0.0)
59
- parallel (1.12.1)
60
- parser (2.5.1.0)
57
+ parallel (1.19.2)
58
+ parser (2.7.1.3)
61
59
  ast (~> 2.4.0)
62
- powerpack (0.1.1)
63
- pry (0.11.3)
64
- coderay (~> 1.1.0)
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 (12.3.1)
68
- rb-fsevent (0.10.3)
69
- rb-inotify (0.9.10)
70
- ffi (>= 0.5.0, < 2)
71
- rspec (3.7.0)
72
- rspec-core (~> 3.7.0)
73
- rspec-expectations (~> 3.7.0)
74
- rspec-mocks (~> 3.7.0)
75
- rspec-core (3.7.1)
76
- rspec-support (~> 3.7.0)
77
- rspec-expectations (3.7.0)
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.7.0)
80
- rspec-mocks (3.7.0)
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.7.0)
83
- rspec-support (3.7.1)
84
- rubocop (0.55.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.5)
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 (~> 1.0, >= 1.0.1)
91
- ruby-progressbar (1.9.0)
92
- ruby_dep (1.5.0)
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.1.2)
95
- activesupport (>= 4.0.0)
96
- sqlite3 (1.3.13)
97
- thor (0.20.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.5)
101
+ tzinfo (1.2.7)
100
102
  thread_safe (~> 0.1)
101
- unicode-display_width (1.3.2)
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 (>= 5.2.0)
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.16.1
122
+ 1.17.3
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # README
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
- # Types & Options - Field
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
+ ```
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-cayman
@@ -2,4 +2,8 @@ require 'rubygems' unless defined?(Gem)
2
2
  require 'active_record'
3
3
  require 'mappd/mappd'
4
4
 
5
- ActiveRecord::Base.send(:include, Mappd)
5
+ module ActiveRecord
6
+ class Base
7
+ include Mappd
8
+ end
9
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Mappd
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '6.0.1'.freeze
3
3
  end
@@ -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
- # specify any dependencies here; for example:
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
@@ -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 { should have_db_column(:age).of_type(:string) }
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: 0.0.3
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: 2018-05-15 00:00:00.000000000 Z
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: 5.2.0
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: 5.2.0
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
- rubyforge_project: mappd
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