schema_monkey 0.4.0 → 0.4.1

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
  SHA1:
3
- metadata.gz: 2d6e7678f91c469b42eeac242d5095283edcaf4a
4
- data.tar.gz: 11e38e5ba367ced242293615096012c752150cd3
3
+ metadata.gz: 79b4b171241c85efd322e1110d21c832a3496ed8
4
+ data.tar.gz: ffd34501fbe45a95ed29750639c4e1dca540e6f0
5
5
  SHA512:
6
- metadata.gz: 1022cc53e764a97faca78bec36a612a5a1b69a13369ba74af3b19a93ece5cbe1dd80002bb50430360e2027b717b3082aefa6c66e2f6422d8936978884ae0ae15
7
- data.tar.gz: ff13029ef2dd6a8ecf5084e8c16526ae1439ce14df10710914c21afb69abb4927bc6d5275c141e94434c0f631471d3432a820d872e1086bb6ad4fd7b0faf3f8f
6
+ metadata.gz: 46d478aa24930337a10ce7fa4d672246fa6b6eb2c2ff214ed78eaa09ba6a8c84b751cdb6ba270bbc5efd0a14a4bcf7d262c0bb5ed8d045a361295d133488d9b0
7
+ data.tar.gz: 4cc5f36af665873d97bc8d8a1e502d8b1564cb79e60597708fd11a97745f6dfd3d3866eeb5aefa09e5a4459ecfa8c6afce2119189d4643c8a84c36393ebeeea0
data/.travis.yml CHANGED
@@ -8,9 +8,9 @@ rvm:
8
8
  - 1.9.3
9
9
  - 2.1.5
10
10
  gemfile:
11
- - gemfiles/rails-4.2/Gemfile.mysql2
12
- - gemfiles/rails-4.2/Gemfile.postgresql
13
- - gemfiles/rails-4.2/Gemfile.sqlite3
11
+ - gemfiles/activerecord-4.2/Gemfile.mysql2
12
+ - gemfiles/activerecord-4.2/Gemfile.postgresql
13
+ - gemfiles/activerecord-4.2/Gemfile.sqlite3
14
14
  env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
15
15
  addons:
16
16
  postgresql: '9.3'
data/README.md CHANGED
@@ -5,23 +5,27 @@
5
5
 
6
6
  # SchemaMonkey
7
7
 
8
- SchemaMonkey is a behind-the-scenes gem to facilitate writing other gems that extend ActiveRecord. It provides:
8
+ SchemaMonkey is a behind-the-scenes gem to facilitate writing extensions to ActiveRecord (typically other gems, but could also be in an application). It provides:
9
9
 
10
10
  * A "middleware"-style interface to key ActiveRecord internal functions. For example, there's a middleware hook to let you insert a handler for migration column definition options, and there are several hooks to insert handlers for the various parts of a schema dump.
11
11
 
12
12
  * A convention-based protocol for `include`'ing custom modules into ActiveRecord. You just define your modules and SchemaMonkey will automatically include them in the right places.
13
13
 
14
- * It takes care of setting up the Railtie appropriately to invoke the gems.
14
+ * (If you're using Rails) It takes care of setting up a Railtie appropriately to invoke the extensions.
15
15
 
16
- The middleware interface has two benefits: it provides a clean API so that the client gems don't need to monkey-patch ActiveRecord (SchemaMonkey does all the monkey-patching for you), and it lets the client gems operate in parallel without concern about conflicting monkey-patches.
16
+ The middleware interface has two benefits: it provides a clean API so that the gem or aplication code doesn't need to monkey-patch ActiveRecord (SchemaMonkey does all the monkey-patching for you), and it lets multiple client gems operate in parallel without concern about conflicting monkey-patches.
17
17
 
18
18
 
19
19
  ## Installation
20
20
 
21
- In your gem's `gemspec`, specify a dependency:
21
+ As usual:
22
22
 
23
23
  ```ruby
24
+ # In a gem's .gemspec:
24
25
  spec.add_dependency "schema_monkey", "~> <MAJOR>.<MINOR>", ">= <MAJOR>.<MINOR>.<PATCH>"
26
+
27
+ # In an applications Gemfile:
28
+ gem "schema_monkey", "~> <MAJOR>.<MINOR>", ">= <MAJOR>.<MINOR>.<PATCH>"
25
29
  ```
26
30
 
27
31
  SchemaMonkey follows semantic versioning; it's a good idea to explicitly use the `~>` and `>=` dependencies to make sure your gem's clients don't accidentally pull in a version of SchemaMonkey that your gem isn't compatible with.
@@ -32,15 +36,15 @@ SchemaMonkey is tested on:
32
36
 
33
37
  <!-- SCHEMA_DEV: MATRIX - begin -->
34
38
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
35
- * ruby **1.9.3** with rails **4.2**, using **mysql2**, **sqlite3** or **postgresql**
36
- * ruby **2.1.5** with rails **4.2**, using **mysql2**, **sqlite3** or **postgresql**
39
+ * ruby **1.9.3** with activerecord **4.2**, using **mysql2**, **sqlite3** or **postgresql**
40
+ * ruby **2.1.5** with activerecord **4.2**, using **mysql2**, **sqlite3** or **postgresql**
37
41
 
38
42
  <!-- SCHEMA_DEV: MATRIX - end -->
39
43
 
40
44
  ## Usage
41
45
 
42
46
 
43
- **Sorry -- no real documentation yet. Will get to that as soon as I can.**
47
+ **Sorry -- no real documentation yet. Too much is still in flux.**
44
48
 
45
49
 
46
50
 
@@ -51,7 +55,7 @@ the standard protocol: fork, feature branch, develop, push, and issue pull reque
51
55
 
52
56
  Some things to know about to help you develop and test:
53
57
 
54
- * **Ugh -- no specs yet. SchemaMonkey is currently tested indirectly by testing the client gems that use it. That's another thing to get to as soon as I can.**
58
+ * **Ugh -- not many specs yet. SchemaMonkey is currently tested indirectly by testing the client gems that use it. Working on it...**
55
59
 
56
60
  * **schema_dev**: SchemaMonkey uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
57
61
  facilitate running rspec tests on the matrix of ruby, rails, and database
@@ -1,3 +1,3 @@
1
1
  eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
2
 
3
- gem "rails", "~> 4.2.0"
3
+ gem "activerecord", "~> 4.2.0"
data/lib/schema_monkey.rb CHANGED
@@ -2,6 +2,7 @@ require 'hash_keyword_args'
2
2
  require 'its-it'
3
3
  require 'key_struct'
4
4
  require 'middleware'
5
+ require 'active_record'
5
6
  require 'active_support/core_ext/string'
6
7
 
7
8
  require_relative "schema_monkey/client"
@@ -13,7 +14,7 @@ require_relative "schema_monkey/active_record/connection_adapters/table_definiti
13
14
  require_relative 'schema_monkey/active_record/connection_adapters/schema_statements'
14
15
  require_relative 'schema_monkey/active_record/migration/command_recorder'
15
16
  require_relative 'schema_monkey/active_record/schema_dumper'
16
- require_relative 'schema_monkey/railtie' if defined?(Rails::Railtie)
17
+ require_relative 'schema_monkey/rake'
17
18
 
18
19
  module SchemaMonkey
19
20
  extend Module
@@ -0,0 +1,12 @@
1
+ module SchemaMonkey
2
+ module Rake
3
+ TASKS_PATH = Pathname.new(__FILE__).dirname + "tasks"
4
+
5
+ def self.insert(*task_names)
6
+ ::Rake.load_rakefile TASKS_PATH + "insert.rake"
7
+ task_names.each do |name|
8
+ ::Rake.application.lookup(name).enhance(["schema_monkey:insert"])
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ namespace :schema_monkey do
2
+ task :insert do
3
+ SchemaMonkey.insert
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module SchemaMonkey
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/schema_dev.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  ruby:
2
2
  - 1.9.3
3
3
  - 2.1.5
4
- rails:
4
+ activerecord:
5
5
  - 4.2
6
6
  db:
7
7
  - mysql2
@@ -26,8 +26,9 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.7"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
- spec.add_development_dependency "rspec", "~> 3.0.0"
30
- spec.add_development_dependency "schema_dev", "~> 2.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "rspec-given", "~> 3.6"
31
+ spec.add_development_dependency "schema_dev", "~> 3.0"
31
32
  spec.add_development_dependency "simplecov"
32
33
  spec.add_development_dependency "simplecov-gem-profile"
33
34
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Connection" do
4
+
5
+ it "is connected" do
6
+ expect(ActiveRecord::Base).to be_connected
7
+ end
8
+
9
+ it "re-opens without failure" do
10
+ expect { ActiveRecord::Base.establish_connection :schema_dev }.to_not raise_error
11
+ expect(ActiveRecord::Base.connection).to_not be_nil
12
+ expect(ActiveRecord::Base).to be_connected
13
+ end
14
+
15
+ end
data/spec/rake_spec.rb ADDED
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'rake'
3
+
4
+ describe SchemaMonkey::Rake do
5
+
6
+ context "insertion" do
7
+ Given(:results) { [] }
8
+
9
+ Given {
10
+ allow(SchemaMonkey).to receive(:insert) { results << :schema_monkey }
11
+ }
12
+
13
+ Given {
14
+ Rake.application = Rake::Application.new
15
+ Rake::Task.define_task(:test1) { results << :test1 }
16
+ Rake::Task.define_task(:test2) { results << :test2 }
17
+ Rake::Task.define_task(:test3) { results << :test3 }
18
+ }
19
+
20
+ Given { SchemaMonkey::Rake.insert(:test1, :test2) }
21
+
22
+
23
+ context "enhanced task 1" do
24
+ When { Rake.application.invoke_task :test1 }
25
+ Then { expect(results).to eq [:schema_monkey, :test1] }
26
+ end
27
+
28
+ context "enhanced task 2" do
29
+ When { Rake.application.invoke_task :test2 }
30
+ Then { expect(results).to eq [:schema_monkey, :test2] }
31
+ end
32
+
33
+ context "unenhanced task 3" do
34
+ When { Rake.application.invoke_task :test3 }
35
+ Then { expect(results).to eq [:test3] }
36
+ end
37
+ end
38
+
39
+ end
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
 
8
8
  require 'rspec'
9
+ require 'rspec/given'
9
10
  require 'active_record'
10
11
  require 'schema_monkey'
11
12
  require 'schema_dev/rspec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_monkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-29 00:00:00.000000000 Z
11
+ date: 2015-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -114,28 +114,42 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 3.0.0
117
+ version: '3.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 3.0.0
124
+ version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-given
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.6'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.6'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: schema_dev
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '2.0'
145
+ version: '3.0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '2.0'
152
+ version: '3.0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: simplecov
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -179,10 +193,10 @@ files:
179
193
  - README.md
180
194
  - Rakefile
181
195
  - gemfiles/Gemfile.base
182
- - gemfiles/rails-4.2/Gemfile.base
183
- - gemfiles/rails-4.2/Gemfile.mysql2
184
- - gemfiles/rails-4.2/Gemfile.postgresql
185
- - gemfiles/rails-4.2/Gemfile.sqlite3
196
+ - gemfiles/activerecord-4.2/Gemfile.base
197
+ - gemfiles/activerecord-4.2/Gemfile.mysql2
198
+ - gemfiles/activerecord-4.2/Gemfile.postgresql
199
+ - gemfiles/activerecord-4.2/Gemfile.sqlite3
186
200
  - lib/schema_monkey.rb
187
201
  - lib/schema_monkey/active_record/base.rb
188
202
  - lib/schema_monkey/active_record/connection_adapters/abstract_adapter.rb
@@ -196,11 +210,13 @@ files:
196
210
  - lib/schema_monkey/client.rb
197
211
  - lib/schema_monkey/middleware.rb
198
212
  - lib/schema_monkey/module.rb
199
- - lib/schema_monkey/railtie.rb
213
+ - lib/schema_monkey/rake.rb
214
+ - lib/schema_monkey/tasks/insert.rake
200
215
  - lib/schema_monkey/version.rb
201
216
  - schema_dev.yml
202
217
  - schema_monkey.gemspec
203
- - spec/sanity_spec.rb
218
+ - spec/connection_spec.rb
219
+ - spec/rake_spec.rb
204
220
  - spec/spec_helper.rb
205
221
  homepage: https://github.com/SchemaPlus/schema_monkey
206
222
  licenses:
@@ -228,5 +244,6 @@ specification_version: 4
228
244
  summary: Provides an internal API and module inclusion protocol to facilitate adding
229
245
  features to ActiveRecord
230
246
  test_files:
231
- - spec/sanity_spec.rb
247
+ - spec/connection_spec.rb
248
+ - spec/rake_spec.rb
232
249
  - spec/spec_helper.rb
@@ -1,24 +0,0 @@
1
- module SchemaMonkey
2
- class Railtie < Rails::Railtie #:nodoc:
3
-
4
- initializer 'schema_monkey.insert', :before => "active_record.initialize_database" do
5
- ActiveSupport.on_load(:active_record) do
6
- SchemaMonkey.insert
7
- end
8
- end
9
-
10
- rake_tasks do
11
- namespace :schema_monkey do
12
- task :insert do
13
- SchemaMonkey.insert
14
- end
15
- end
16
- ['db:schema:dump', 'db:schema:load'].each do |name|
17
- if task = Rake.application.tasks.find { |task| task.name == name }
18
- task.enhance(["schema_monkey:insert"])
19
- end
20
- end
21
- end
22
-
23
- end
24
- end
data/spec/sanity_spec.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
-
4
- # A basic sanity check to have as a spec when first starting. Feel free to delete this
5
- # once you've got real content.
6
-
7
- describe "Sanity Check" do
8
-
9
- it "database is connected" do
10
- expect(ActiveRecord::Base).to be_connected
11
- end
12
-
13
- end