schema_dev 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +18 -2
- data/bin/schema_dev +12 -5
- data/lib/schema_dev/gemfiles.rb +25 -16
- data/lib/schema_dev/runner.rb +7 -2
- data/lib/schema_dev/version.rb +1 -1
- data/spec/config_spec.rb +8 -0
- data/spec/gemfile_sepector_spec.rb +10 -0
- data/spec/gemfiles_spec.rb +9 -1
- data/spec/runner_spec.rb +2 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9f90059fcb7c1988ac49bab9ce3ef9533d429b8
|
4
|
+
data.tar.gz: cd263a6bf93f7b999995c045b8a37fe55175d43c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daa5d2797c86906c01b25636bfb75c58f06a0aee7056b505f76466a9bff948a43f882142d60ffcfc10ae38f6d4c7abaeff13b9dcb9d57dc1df63769c72880b44
|
7
|
+
data.tar.gz: 24fe7d3ebc7b35a6ba166c9266e3acac6d249b1de647cac6de859c6a7c92df372c549cade7c655f89405722e91128433c117c08f9274e786d6d4a5a402753769
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -25,10 +25,12 @@ The client gem needs a file `schema_dev.yml` in it's root, which specifies the t
|
|
25
25
|
* `db`: A single db adapter, or a list of db adapters.
|
26
26
|
* `quick`: (Optional) Hash listing the version of ruby, rails, and db to use with `--quick` option. If not specified, the default is to use the last entry in each list.
|
27
27
|
|
28
|
+
If you change this file, it's a good idea to run `schema_dev refresh` to update the auto-generated `gemfiles` and `.travis.yml` (see below).
|
29
|
+
|
28
30
|
#### Gemfiles
|
29
31
|
|
30
32
|
The client gem must contain a "gemfiles" directory containing the matrix of
|
31
|
-
possible gemfiles;
|
33
|
+
possible gemfiles; It will be generated/updated automatically by the `schema_dev` script whenever you run a matrix command. You can also generate it explicitly by running
|
32
34
|
|
33
35
|
$ schema_dev gemfiles
|
34
36
|
|
@@ -78,7 +80,7 @@ For PostgreSQL and MySQL you must explicitly create the databases used by the te
|
|
78
80
|
|
79
81
|
In the root directory, you can run, e.g.,
|
80
82
|
|
81
|
-
$ schema_dev bundle install
|
83
|
+
$ schema_dev bundle install # or schema_dev bundle update
|
82
84
|
$ schema_dev rspec
|
83
85
|
|
84
86
|
Which will run those commands over the whole matrix. You can also specify slices, via any combination of `--ruby`, `--rails` and `--db`
|
@@ -90,6 +92,20 @@ For convenience you can also use `--quick` to run just one as specified in `sche
|
|
90
92
|
If you want to pass extra arguments to a command, make sure to use `--` to avoid them being processed by `schema_dev`. e.g.
|
91
93
|
|
92
94
|
$ schema_dev rspec --quick -- -e 'select which spec'
|
95
|
+
|
96
|
+
For interactive debugging you may want to run rspec directly from the shell rather than through`schema_dev` (which doesn't give you an interactive ptty). schema_dev echoes each command being run, preceded by a `*`. E.g.
|
97
|
+
|
98
|
+
$ schema_dev rspec --quick -- -e 'select which spec' -n
|
99
|
+
|
100
|
+
*** ruby 2.1.5 - rails 4.2 - db postgresql [1 of 1]
|
101
|
+
|
102
|
+
* /usr/bin/env BUNDLE_GEMFILE=gemfiles/rails-4.2/Gemfile.postgresql SHELL=`which bash` chruby-exec ruby-2.1.5 -- bundle exec rspec -e select\ which\ spec
|
103
|
+
|
104
|
+
|
105
|
+
There's no hidden environment setup; so you can copy and paste the command line into a shell:
|
106
|
+
|
107
|
+
$ /usr/bin/env BUNDLE_GEMFILE=gemfiles/rails-4.2/Gemfile.postgresql SHELL=`which bash` chruby-exec ruby-2.1.5 -- bundle exec rspec -e select\ which\ spec
|
108
|
+
|
93
109
|
|
94
110
|
For more info, see
|
95
111
|
|
data/bin/schema_dev
CHANGED
@@ -11,6 +11,8 @@ def runner
|
|
11
11
|
$runner ||= SchemaDev::Runner.new($config)
|
12
12
|
end
|
13
13
|
|
14
|
+
$cmd = File.basename $0
|
15
|
+
|
14
16
|
class CLI < Thor
|
15
17
|
|
16
18
|
def self.matrix_options
|
@@ -21,35 +23,40 @@ class CLI < Thor
|
|
21
23
|
method_option :db, type: :string, desc: "Only execute for the specified database"
|
22
24
|
end
|
23
25
|
|
24
|
-
desc "travis", "create .travis.yml based on schema_dev.yml values"
|
26
|
+
desc "travis", "create/update .travis.yml based on schema_dev.yml values"
|
25
27
|
def travis
|
26
28
|
runner.travis
|
27
29
|
end
|
28
30
|
|
29
|
-
desc "gemfiles", "create gemfiles/* hierarchy based on schema_dev.yml values"
|
31
|
+
desc "gemfiles", "create/update gemfiles/* hierarchy based on schema_dev.yml values"
|
30
32
|
def gemfiles
|
31
33
|
runner.gemfiles
|
32
34
|
end
|
33
35
|
|
36
|
+
desc "refresh", "shorthand for runnin both '#{$cmd} travis' and '#{$cmd} gemfiles'"
|
37
|
+
def refresh
|
38
|
+
runner.refresh
|
39
|
+
end
|
40
|
+
|
34
41
|
desc "matrix", "run a command over the matrix"
|
35
42
|
matrix_options
|
36
43
|
def matrix(*args)
|
37
44
|
runner.run(args, **options.to_h.symbolize_keys)
|
38
45
|
end
|
39
46
|
|
40
|
-
desc "bundle", "shorthand for '#{$
|
47
|
+
desc "bundle", "shorthand for '#{$cmd} matrix bundle ...'"
|
41
48
|
matrix_options
|
42
49
|
def bundle(*args)
|
43
50
|
runner.run('bundle', args, **options.to_h.symbolize_keys)
|
44
51
|
end
|
45
52
|
|
46
|
-
desc "rake", "shorthand for '#{$
|
53
|
+
desc "rake", "shorthand for '#{$cmd} matrix bundle exec rake ...'"
|
47
54
|
matrix_options
|
48
55
|
def rake(*args)
|
49
56
|
runner.run('bundle', 'exec', 'rake', args, **options.to_h.symbolize_keys)
|
50
57
|
end
|
51
58
|
|
52
|
-
desc "rspec", "shorthand for '#{$
|
59
|
+
desc "rspec", "shorthand for '#{$cmd} bundle exec rspec ...'"
|
53
60
|
matrix_options
|
54
61
|
def rspec(*args)
|
55
62
|
runner.run('bundle', 'exec', 'rspec', args, **options.to_h.symbolize_keys)
|
data/lib/schema_dev/gemfiles.rb
CHANGED
@@ -8,38 +8,47 @@ module SchemaDev
|
|
8
8
|
TEMPLATES_ROOT = Pathname.new(__FILE__).dirname.parent.parent + "templates"
|
9
9
|
|
10
10
|
def build(config)
|
11
|
-
|
12
|
-
|
11
|
+
Dir.mktmpdir do |tmpdir|
|
12
|
+
@src_root = TEMPLATES_ROOT
|
13
|
+
@dst_root = Pathname.new(tmpdir).realpath
|
13
14
|
|
14
|
-
|
15
|
+
relpath = Pathname.new("gemfiles")
|
16
|
+
abspath = @dst_root + relpath
|
17
|
+
target_abspath = Pathname.new(".").realpath + relpath
|
15
18
|
|
16
|
-
|
19
|
+
_copy(relpath, 'Gemfile.base')
|
17
20
|
|
18
|
-
|
21
|
+
config.rails.each do |rails|
|
19
22
|
|
20
|
-
|
23
|
+
rails_path = relpath + "rails-#{rails}"
|
24
|
+
_copy(rails_path, 'Gemfile.base')
|
21
25
|
|
22
|
-
|
23
|
-
|
26
|
+
config.db.each do |db|
|
27
|
+
_copy(rails_path, "Gemfile.#{db}")
|
28
|
+
end
|
29
|
+
end
|
24
30
|
|
25
|
-
|
26
|
-
|
31
|
+
if `diff -rq #{abspath} gemfiles 2>&1 | grep -v lock`.length == 0
|
32
|
+
return false
|
27
33
|
end
|
34
|
+
|
35
|
+
_blow_away(target_abspath)
|
36
|
+
abspath.rename(target_abspath)
|
37
|
+
return true
|
28
38
|
end
|
29
|
-
return true
|
30
39
|
end
|
31
40
|
|
32
|
-
def _copy(
|
33
|
-
srcfile = @src_root +
|
34
|
-
dstfile = @dst_root +
|
41
|
+
def _copy(relpath, filename)
|
42
|
+
srcfile = @src_root + relpath + filename
|
43
|
+
dstfile = @dst_root + relpath + filename
|
35
44
|
return unless srcfile.exist?
|
36
45
|
|
37
46
|
dstfile.dirname.mkpath
|
38
47
|
FileUtils.copy_file(srcfile, dstfile)
|
39
48
|
end
|
40
49
|
|
41
|
-
def _blow_away(
|
42
|
-
(@dst_root +
|
50
|
+
def _blow_away(relpath)
|
51
|
+
(@dst_root + relpath).rmtree
|
43
52
|
rescue Errno::ENOENT
|
44
53
|
end
|
45
54
|
end
|
data/lib/schema_dev/runner.rb
CHANGED
@@ -15,11 +15,16 @@ module SchemaDev
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def gemfiles
|
18
|
-
Gemfiles.build(@config) and puts "*
|
18
|
+
Gemfiles.build(@config) and puts "* Updated gemfiles"
|
19
|
+
end
|
20
|
+
|
21
|
+
def refresh
|
22
|
+
self.travis
|
23
|
+
self.gemfiles
|
19
24
|
end
|
20
25
|
|
21
26
|
def run(*args, dry_run: false, quick: false, ruby: nil, rails: nil, db: nil, freshen: true)
|
22
|
-
self.
|
27
|
+
self.refresh if freshen
|
23
28
|
|
24
29
|
matrix = MatrixExecutor.new @config.matrix(quick: quick, ruby: ruby, rails: rails, db: db)
|
25
30
|
|
data/lib/schema_dev/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -49,5 +49,13 @@ describe SchemaDev::Config do
|
|
49
49
|
{ ruby: "2.1.5", rails: "4.1", db: "postgresql" },
|
50
50
|
]
|
51
51
|
end
|
52
|
+
|
53
|
+
it "uses last cell for --quick" do
|
54
|
+
config = get_config(ruby: %W[1.9.3 2.1.5], rails: %W[4.0 4.1], db: %W[sqlite3 postgresql])
|
55
|
+
expect(config.matrix quick: true).to match_array [
|
56
|
+
{ ruby: "2.1.5", rails: "4.1", db: "postgresql" },
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
52
60
|
|
53
61
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'schema_dev/gemfile_selector'
|
2
|
+
|
3
|
+
describe SchemaDev::GemfileSelector do
|
4
|
+
|
5
|
+
it "infers db from env" do
|
6
|
+
test_dbname = 'this_is_a_test'
|
7
|
+
ENV['BUNDLE_GEMFILE'] = SchemaDev::GemfileSelector.gemfile(rails: '4.1', db: test_dbname).to_s
|
8
|
+
expect(SchemaDev::GemfileSelector.infer_db).to eq test_dbname
|
9
|
+
end
|
10
|
+
end
|
data/spec/gemfiles_spec.rb
CHANGED
@@ -5,11 +5,19 @@ describe SchemaDev::Gemfiles do
|
|
5
5
|
it "copies listed files" do
|
6
6
|
config = get_config(ruby: %W[1.9.3 2.1.5], rails: %W[4.0 4.1], db: %W[sqlite3 postgresql])
|
7
7
|
in_tmpdir do
|
8
|
-
SchemaDev::Gemfiles.build(config)
|
8
|
+
expect(SchemaDev::Gemfiles.build(config)).to be_truthy
|
9
9
|
expect(relevant_diff(config, "gemfiles")).to be_empty
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
+
it "only copies files once" do
|
14
|
+
config = get_config(ruby: %W[1.9.3 2.1.5], rails: %W[4.0 4.1], db: %W[sqlite3 postgresql])
|
15
|
+
in_tmpdir do
|
16
|
+
expect(SchemaDev::Gemfiles.build(config)).to be_truthy
|
17
|
+
expect(SchemaDev::Gemfiles.build(config)).to be_falsey
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
13
21
|
def relevant_diff(config, dir)
|
14
22
|
src = SchemaDev::Gemfiles::TEMPLATES_ROOT + dir
|
15
23
|
diff = `diff -rq #{src} #{dir} 2>&1`.split("\n")
|
data/spec/runner_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe SchemaDev::Runner do
|
|
6
6
|
config = get_config(ruby: "2.1.3", rails: "4.0", db: "sqlite3")
|
7
7
|
runner = SchemaDev::Runner.new(config)
|
8
8
|
in_tmpdir do
|
9
|
-
expect{ runner.gemfiles }.to output("*
|
9
|
+
expect{ runner.gemfiles }.to output("* Updated gemfiles\n").to_stdout
|
10
10
|
expect(Pathname.new("gemfiles")).to be_directory
|
11
11
|
end
|
12
12
|
end
|
@@ -60,6 +60,7 @@ describe SchemaDev::Runner do
|
|
60
60
|
|
61
61
|
let(:expected_output) { <<ENDOUTPUT.strip }
|
62
62
|
* Updated .travis.yml
|
63
|
+
* Updated gemfiles
|
63
64
|
|
64
65
|
|
65
66
|
*** ruby #{RUBY_VERSION} - rails 4.0 - db sqlite3 [1 of 2]
|
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: 1.
|
4
|
+
version: 1.3.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:
|
11
|
+
date: 2015-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- lib/schema_dev/version.rb
|
198
198
|
- schema_dev.gemspec
|
199
199
|
- spec/config_spec.rb
|
200
|
+
- spec/gemfile_sepector_spec.rb
|
200
201
|
- spec/gemfiles_spec.rb
|
201
202
|
- spec/runner_spec.rb
|
202
203
|
- spec/spec_helper.rb
|
@@ -249,6 +250,7 @@ specification_version: 4
|
|
249
250
|
summary: SchemaPlus development tools
|
250
251
|
test_files:
|
251
252
|
- spec/config_spec.rb
|
253
|
+
- spec/gemfile_sepector_spec.rb
|
252
254
|
- spec/gemfiles_spec.rb
|
253
255
|
- spec/runner_spec.rb
|
254
256
|
- spec/spec_helper.rb
|