schema_dev 3.0.1 → 3.1.0
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 +4 -4
- data/lib/schema_dev/gem.rb +4 -3
- data/lib/schema_dev/readme.rb +35 -12
- data/lib/schema_dev/rspec/db.rb +9 -4
- data/lib/schema_dev/version.rb +1 -1
- data/templates/README/installation.md +14 -0
- data/templates/README/uses.schema_dev.md +15 -0
- data/templates/README/uses.schema_monkey.md +5 -0
- data/templates/README/uses.schema_plus_core.md +6 -0
- data/templates/gem/GEM_NAME.gemspec +21 -21
- data/templates/gem/Gemfile.local +10 -0
- data/templates/gem/README.md +8 -21
- data/templates/gem/{.gitignore → gitignore} +0 -0
- data/templates/gem/schema_dev.yml +0 -1
- data/templates/gemfiles/Gemfile.base +0 -4
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5bfa06af8b9f00fffcb689a75ca9660c956241c
|
4
|
+
data.tar.gz: d09915f7524f4e4a3dafcb2a0501c47d54185c08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99bf2a55254c90452aefa89e0afab3c40affdb320c957e92dd46eba4867d16de386780b96a00630eebd1b6edacdb5889a8a654bed750831282549f810d30c58a
|
7
|
+
data.tar.gz: 062cdcfbf0f1e41cbead8ca3b7b1983248cbdc04e936eb11cecd3bbbd315db3dfd22b5fffe8dbbaff7cda692317ebe8ae66b64005401037cd4a9c3ef1d141c6b
|
data/lib/schema_dev/gem.rb
CHANGED
@@ -15,14 +15,14 @@ module SchemaDev
|
|
15
15
|
|
16
16
|
def initialize(name)
|
17
17
|
self.gem_name = name.underscore
|
18
|
-
self.gem_module = gem_name.camelize
|
18
|
+
self.gem_module = gem_name.camelize.sub(/^SchemaPlus(?=\w+)/, 'SchemaPlus::')
|
19
19
|
self.gem_root = Pathname.new(gem_name)
|
20
|
+
get_fullname_and_email
|
20
21
|
end
|
21
22
|
|
22
23
|
def build
|
23
24
|
ensure_not_in_git
|
24
25
|
ensure_doesnt_exist
|
25
|
-
get_fullname_and_email
|
26
26
|
copy_template
|
27
27
|
self.gem_root = self.gem_root.realpath
|
28
28
|
rename_files
|
@@ -66,6 +66,7 @@ module SchemaDev
|
|
66
66
|
|
67
67
|
def copy_template
|
68
68
|
FileUtils.cp_r Templates.root + "gem", gem_root
|
69
|
+
(gem_root + "gitignore").rename gem_root + ".gitignore"
|
69
70
|
end
|
70
71
|
|
71
72
|
def rename_files
|
@@ -114,7 +115,7 @@ module SchemaDev
|
|
114
115
|
def git_init
|
115
116
|
Dir.chdir gem_name do
|
116
117
|
system "git init"
|
117
|
-
system "git add #{gem_root.find.select(&:exist?).join(' ')}"
|
118
|
+
system "git add #{gem_root.find.select(&:exist?).reject(&it.basename.to_s == 'Gemfile.local').join(' ')}"
|
118
119
|
system "git commit -m 'Initial skeleton generated by `schema_dev gem #{gem_name}`'"
|
119
120
|
end
|
120
121
|
end
|
data/lib/schema_dev/readme.rb
CHANGED
@@ -17,30 +17,53 @@ module SchemaDev
|
|
17
17
|
return false unless readme.exist?
|
18
18
|
lines = readme.readlines
|
19
19
|
newlines = sub_matrix(lines)
|
20
|
+
newlines = sub_templates(newlines)
|
20
21
|
if lines != newlines
|
21
|
-
readme.write newlines.join
|
22
|
+
readme.write Gem.new(Pathname.pwd.basename.to_s).subs(newlines.join)
|
22
23
|
return true
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
def sub_matrix(lines)
|
27
|
-
|
28
|
-
|
28
|
+
replace_block(lines, %r{^\s*<!-- SCHEMA_DEV: MATRIX}) do |contents|
|
29
|
+
contents << "<!-- SCHEMA_DEV: MATRIX - begin -->\n"
|
30
|
+
contents << "<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->\n"
|
31
|
+
self.matrix.group_by(&it.slice(:ruby, :activerecord)).each do |pair, items|
|
32
|
+
contents << "* ruby **#{pair[:ruby]}** with activerecord **#{pair[:activerecord]}**, using #{items.map{|item| "**#{item[:db]}**"}.to_sentence(last_word_connector: ' or ')}\n"
|
33
|
+
end
|
34
|
+
contents << "\n"
|
35
|
+
contents << "<!-- SCHEMA_DEV: MATRIX - end -->\n"
|
36
|
+
end
|
37
|
+
end
|
29
38
|
|
30
|
-
|
39
|
+
def sub_templates(lines)
|
40
|
+
Pathname.glob(SchemaDev::Templates.root + "README" + "*.md").each do |template|
|
41
|
+
lines = sub_template(template, lines)
|
42
|
+
end
|
43
|
+
lines
|
44
|
+
end
|
31
45
|
|
32
|
-
|
46
|
+
def sub_template(template, lines)
|
47
|
+
key = template.basename.sub_ext('').to_s.upcase.tr('.', ' ')
|
33
48
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
contents << "
|
49
|
+
replace_block(lines, %r{^\s*<!-- SCHEMA_DEV: TEMPLATE #{key}}) do |contents|
|
50
|
+
contents << "<!-- SCHEMA_DEV: TEMPLATE #{key} - begin -->\n"
|
51
|
+
contents << "<!-- These lines are auto-inserted from a schema_dev template -->\n"
|
52
|
+
contents << template.readlines
|
53
|
+
contents << "\n"
|
54
|
+
contents << "<!-- SCHEMA_DEV: TEMPLATE #{key} - end -->\n"
|
39
55
|
end
|
40
|
-
|
41
|
-
contents << "<!-- SCHEMA_DEV: MATRIX - end -->\n"
|
56
|
+
end
|
42
57
|
|
58
|
+
def replace_block(lines, pattern)
|
59
|
+
before = lines.take_while(&it !~ pattern)
|
60
|
+
return lines if before == lines
|
61
|
+
after = lines.reverse.take_while(&it !~ pattern).reverse
|
62
|
+
contents = []
|
63
|
+
yield contents
|
43
64
|
before + contents + after
|
44
65
|
end
|
66
|
+
|
67
|
+
|
45
68
|
end
|
46
69
|
end
|
data/lib/schema_dev/rspec/db.rb
CHANGED
@@ -30,12 +30,17 @@ module SchemaDev
|
|
30
30
|
@logroot ||= Pathname.new('log').tap { |path| path.mkpath }
|
31
31
|
end
|
32
32
|
|
33
|
+
def database
|
34
|
+
@database ||= "schema_plus_test"
|
35
|
+
# @database ||= (Dir["*.gemspec"].first || "schema_dev_test").sub(/\.gemspec$/, '') + "_test"
|
36
|
+
end
|
37
|
+
|
33
38
|
def configuration
|
34
39
|
case @db
|
35
40
|
when 'mysql'
|
36
41
|
{
|
37
42
|
:adapter => 'mysql',
|
38
|
-
:database =>
|
43
|
+
:database => database,
|
39
44
|
:username => ENV.fetch('MYSQL_DB_USER', 'schema_plus'),
|
40
45
|
:encoding => 'utf8',
|
41
46
|
:min_messages => 'warning'
|
@@ -43,7 +48,7 @@ module SchemaDev
|
|
43
48
|
when 'mysql2'
|
44
49
|
{
|
45
50
|
:adapter => 'mysql2',
|
46
|
-
:database =>
|
51
|
+
:database => database,
|
47
52
|
:username => ENV.fetch('MYSQL_DB_USER', 'schema_plus'),
|
48
53
|
:encoding => 'utf8',
|
49
54
|
:min_messages => 'warning'
|
@@ -52,13 +57,13 @@ module SchemaDev
|
|
52
57
|
{
|
53
58
|
:adapter => 'postgresql',
|
54
59
|
:username => ENV['POSTGRESQL_DB_USER'],
|
55
|
-
:database =>
|
60
|
+
:database => database,
|
56
61
|
:min_messages => 'warning'
|
57
62
|
}
|
58
63
|
when 'sqlite3'
|
59
64
|
{
|
60
65
|
:adapter => 'sqlite3',
|
61
|
-
:database => tmproot.join(
|
66
|
+
:database => tmproot.join("#{database}.sqlite3").to_s
|
62
67
|
}
|
63
68
|
else
|
64
69
|
raise "Unknown db adapter #{@db.inspect}"
|
data/lib/schema_dev/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
As usual:
|
2
|
+
|
3
|
+
```ruby
|
4
|
+
gem "%GEM_NAME%" # in a Gemfile
|
5
|
+
gem.add_dependency "%GEM_NAME%" # in a .gemspec
|
6
|
+
```
|
7
|
+
|
8
|
+
To use with a rails app, also include
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "schema_monkey_rails"
|
12
|
+
```
|
13
|
+
|
14
|
+
which creates a Railtie to that will insert %GEM_MODULE% appropriately into the rails stack. To use with Padrino, see [schema_monkey_padrino](https://github.com/SchemaPlus/schema_monkey_padrino).
|
@@ -0,0 +1,15 @@
|
|
1
|
+
* **schema_dev**: %GEM_MODULE% uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
|
2
|
+
facilitate running rspec tests on the matrix of ruby, activerecord, and database
|
3
|
+
versions that the gem supports, both locally and on
|
4
|
+
[travis-ci](http://travis-ci.org/SchemaPlus/%GEM_NAME%)
|
5
|
+
|
6
|
+
To to run rspec locally on the full matrix, do:
|
7
|
+
|
8
|
+
$ schema_dev bundle install
|
9
|
+
$ schema_dev rspec
|
10
|
+
|
11
|
+
You can also run on just one configuration at a time; For info, see `schema_dev --help` or the [schema_dev](https://github.com/SchemaPlus/schema_dev) README.
|
12
|
+
|
13
|
+
The matrix of configurations is specified in `schema_dev.yml` in
|
14
|
+
the project root.
|
15
|
+
|
@@ -0,0 +1,5 @@
|
|
1
|
+
* **schema_monkey**: %GEM_MODULE% is implemented as a
|
2
|
+
[schema_monkey](https://github.com/SchemaPlus/schema_monkey) client,
|
3
|
+
using [schema_monkey](https://github.com/SchemaPlus/schema_monkey)'s
|
4
|
+
convention-based protocols for extending ActiveRecord and using middleware stacks.
|
5
|
+
For more information see [schema_monkey](https://github.com/SchemaPlus/schema_monkey)'s README.
|
@@ -0,0 +1,6 @@
|
|
1
|
+
* **schema_plus_core**: %GEM_MODULE% uses the SchemaPlus::Core API that
|
2
|
+
provides middleware callback stacks to make it easy to extend
|
3
|
+
ActiveRecord's behavior. If that API is missing something you need for
|
4
|
+
your contribution, please head over to
|
5
|
+
[schema_plus_core](https://github/SchemaPlus/schema_plus_core) and open
|
6
|
+
an issue or pull request.
|
@@ -3,28 +3,28 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require '%GEM_NAME%/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "%GEM_NAME%"
|
8
|
+
gem.version = %GEM_MODULE%::VERSION
|
9
|
+
gem.authors = ["%FULLNAME%"]
|
10
|
+
gem.email = ["%EMAIL%"]
|
11
|
+
gem.summary = %q{TODO: Write a short summary. Required.}
|
12
|
+
gem.description = %q{TODO: Write a longer description. Optional.}
|
13
|
+
gem.homepage = "https://github.com/SchemaPlus/%GEM_NAME%"
|
14
|
+
gem.license = "MIT"
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
gem.files = `git ls-files -z`.split("\x0")
|
17
|
+
gem.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
gem.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
gem.add_dependency "activerecord", "~> 4.2"
|
22
|
+
gem.add_dependency "schema_monkey", %SCHEMA_MONKEY_DEPENDENCY%
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
gem.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
26
|
+
gem.add_development_dependency "rspec", "~> 3.0.0"
|
27
|
+
gem.add_development_dependency "schema_dev", %SCHEMA_DEV_DEPENDENCY%
|
28
|
+
gem.add_development_dependency "simplecov"
|
29
|
+
gem.add_development_dependency "simplecov-gem-profile"
|
30
30
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Gemfile.local
|
2
|
+
#
|
3
|
+
# Gems for local development, .gitignore'd to not include in released gem
|
4
|
+
#
|
5
|
+
|
6
|
+
# For path-relative gems (because Gemfile.local gets included from Gemfiles
|
7
|
+
# in subdirectories, the actual system cwd may be elsewhere)
|
8
|
+
cwd = Pathname.new(__FILE__).dirname
|
9
|
+
|
10
|
+
gem "byebug"
|
data/templates/gem/README.md
CHANGED
@@ -11,11 +11,8 @@ TODO: Write a gem description
|
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
14
|
-
|
14
|
+
<!-- SCHEMA_DEV: TEMPLATE INSTALLATION -->
|
15
15
|
|
16
|
-
```ruby
|
17
|
-
gem "%GEM_NAME%"
|
18
|
-
```
|
19
16
|
## Compatibility
|
20
17
|
|
21
18
|
%GEM_MODULE% is tested on:
|
@@ -28,28 +25,18 @@ TODO: Write usage instructions here
|
|
28
25
|
|
29
26
|
## History
|
30
27
|
|
31
|
-
*
|
28
|
+
* 0.1.0 - Initial release
|
32
29
|
|
33
30
|
## Development & Testing
|
34
31
|
|
35
|
-
Are you interested in contributing to %GEM_MODULE%? Thanks! Please follow
|
32
|
+
Are you interested in contributing to %GEM_MODULE%? Thanks! Please follow
|
33
|
+
the standard protocol: fork, feature branch, develop, push, and issue pull
|
34
|
+
request.
|
36
35
|
|
37
36
|
Some things to know about to help you develop and test:
|
38
37
|
|
39
|
-
|
40
|
-
facilitate running rspec tests on the matrix of ruby, activerecord, and database
|
41
|
-
versions that the gem supports, both locally and on
|
42
|
-
[travis-ci](http://travis-ci.org/SchemaPlus/%GEM_NAME%)
|
38
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV -->
|
43
39
|
|
44
|
-
|
40
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SHEMA_PLUS_CORE -->
|
45
41
|
|
46
|
-
|
47
|
-
$ schema_dev rspec
|
48
|
-
|
49
|
-
You can also run on just one configuration at a time; For info, see `schema_dev --help` or the [schema_dev](https://github.com/SchemaPlus/schema_dev) README.
|
50
|
-
|
51
|
-
The matrix of configurations is specified in `schema_dev.yml` in
|
52
|
-
the project root.
|
53
|
-
|
54
|
-
* **schema_monkey**: %GEM_MODULE% extends ActiveRecord using
|
55
|
-
[schema_monkey](https://github.com/SchemaPlus/schema_monkey)'s extension API and protocols -- see its README for details. If your contribution needs any additional monkey patching that isn't already supported by [schema_monkey](https://github.com/SchemaPlus/schema_monkey), please head over there and submit a PR.
|
42
|
+
<!-- SCHEMA_DEV: TEMPLATE USES SHEMA_MONKEY -->
|
File without changes
|
@@ -1,8 +1,4 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec :path => File.expand_path('..', __FILE__)
|
3
3
|
|
4
|
-
platform :ruby do
|
5
|
-
gem "byebug" if RUBY_VERSION > "2"
|
6
|
-
end
|
7
|
-
|
8
4
|
File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_dev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
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-02-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -234,12 +234,17 @@ files:
|
|
234
234
|
- spec/runner_spec.rb
|
235
235
|
- spec/spec_helper.rb
|
236
236
|
- spec/travis_spec.rb
|
237
|
-
- templates/
|
237
|
+
- templates/README/installation.md
|
238
|
+
- templates/README/uses.schema_dev.md
|
239
|
+
- templates/README/uses.schema_monkey.md
|
240
|
+
- templates/README/uses.schema_plus_core.md
|
238
241
|
- templates/gem/GEM_NAME.gemspec
|
239
242
|
- templates/gem/Gemfile
|
243
|
+
- templates/gem/Gemfile.local
|
240
244
|
- templates/gem/LICENSE.txt
|
241
245
|
- templates/gem/README.md
|
242
246
|
- templates/gem/Rakefile
|
247
|
+
- templates/gem/gitignore
|
243
248
|
- templates/gem/lib/GEM_NAME.rb
|
244
249
|
- templates/gem/lib/GEM_NAME/version.rb
|
245
250
|
- templates/gem/schema_dev.yml
|