scenic 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/NEWS.md +6 -0
- data/lib/generators/scenic/view/view_generator.rb +9 -1
- data/lib/scenic/adapters/postgres.rb +1 -0
- data/lib/scenic/version.rb +1 -1
- data/lib/scenic/view.rb +1 -0
- data/spec/generators/scenic/view/view_generator_spec.rb +7 -7
- data/spec/smoke +4 -1
- data/spec/support/generator_spec_setup.rb +4 -1
- data/spec/support/view_definition_helpers.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e917734f36443e8d261a50f8bcef5c5e65eeebda
|
4
|
+
data.tar.gz: d013d537a689625087039b4d6cb2e54a584c73ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be0c588362c95ab41cf71670954569c6c06e8ff7e7ef5b2a27b23b32eb61dc86ea8e13e3a969c7596ca9d55a86d2f8c9999486ecfdcac025dc70cbca81cddbb7
|
7
|
+
data.tar.gz: d1b4171587355aef488df5ebc9d998da4eaa690baf3e8aad2a6ca9ab6db1b11a4bbe1ac07c43c2c9305b5761b43d24298c983cdf1129e795488d1b035cb0daf8
|
data/.travis.yml
CHANGED
@@ -4,16 +4,16 @@ before_install:
|
|
4
4
|
- git config --global user.name 'Travis CI'
|
5
5
|
- git config --global user.email 'travis-ci@example.com'
|
6
6
|
before_script:
|
7
|
-
- pushd spec/dummy && bundle exec rake db:create && popd
|
7
|
+
- pushd spec/dummy && bundle exec rake db:create && mkdir db/views && popd
|
8
8
|
branches:
|
9
9
|
only:
|
10
10
|
- master
|
11
|
-
cache:
|
12
|
-
- bundler
|
13
11
|
language:
|
14
12
|
- ruby
|
15
13
|
notifications:
|
16
14
|
email:
|
17
15
|
- false
|
18
16
|
rvm:
|
19
|
-
- 2.1.
|
17
|
+
- 2.1.5
|
18
|
+
- 2.2.0
|
19
|
+
sudo: false
|
data/NEWS.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
New in 0.3.0 (January 23, 2015)
|
2
|
+
* Previous view definition is copied into new view definition file when updating
|
3
|
+
an existing view.
|
4
|
+
* We avoid dumping views that belong to Postgres extensions
|
5
|
+
* `db/schema.rb` is prettier thanks to a blank line after each view definition.
|
6
|
+
|
1
7
|
New in 0.2.1
|
2
8
|
* View generator will now create `db/views` directory if necessary
|
3
9
|
|
@@ -14,7 +14,11 @@ module Scenic
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_view_definition
|
17
|
-
|
17
|
+
if creating_new_view?
|
18
|
+
create_file definition.path
|
19
|
+
else
|
20
|
+
copy_file previous_definition.full_path, definition.full_path
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def create_migration_file
|
@@ -74,6 +78,10 @@ module Scenic
|
|
74
78
|
Scenic::Definition.new(plural_file_name, version)
|
75
79
|
end
|
76
80
|
|
81
|
+
def previous_definition
|
82
|
+
Scenic::Definition.new(plural_file_name, previous_version)
|
83
|
+
end
|
84
|
+
|
77
85
|
def destroying?
|
78
86
|
behavior == :revoke
|
79
87
|
end
|
data/lib/scenic/version.rb
CHANGED
data/lib/scenic/view.rb
CHANGED
@@ -13,14 +13,14 @@ describe Scenic::Generators::ViewGenerator, :generator do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "updates an existing view" do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
.and_return(["searches_v01.sql"])
|
16
|
+
with_view_definition("searches", 1, "hello") do
|
17
|
+
migration = file("db/migrate/update_searches_to_version_2.rb")
|
18
|
+
view_definition = file("db/views/searches_v02.sql")
|
20
19
|
|
21
|
-
|
20
|
+
run_generator ["search"]
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
expect(migration).to be_a_migration
|
23
|
+
expect(view_definition).to exist
|
24
|
+
end
|
25
25
|
end
|
26
26
|
end
|
data/spec/smoke
CHANGED
@@ -30,7 +30,9 @@ writeToFileAndMigrateAndVerifySearchResults() {
|
|
30
30
|
echo "write search definition and migrate"
|
31
31
|
local version=$1
|
32
32
|
local expectedResult=$2
|
33
|
-
|
33
|
+
local filePath=db/views/searches_v$version\.sql
|
34
|
+
cp /dev/null $filePath
|
35
|
+
echo "SELECT '$expectedResult'::text AS results" >> $filePath
|
34
36
|
rake db:migrate
|
35
37
|
echo "[success]"
|
36
38
|
verifySearchResults $expectedResult
|
@@ -50,6 +52,7 @@ main() {
|
|
50
52
|
echo "rails generate scenic:view search (to get updates search view)"
|
51
53
|
rails generate scenic:view search
|
52
54
|
[[ -f db/views/searches_v02.sql ]] || exit 1
|
55
|
+
cmp db/views/searches_v01.sql db/views/searches_v02.sql || exit 1
|
53
56
|
[[ -n "$(find db/migrate -maxdepth 1 -name "*update_searches_to_version_2.rb" -print -quit)" ]] || exit 1
|
54
57
|
echo "[success]"
|
55
58
|
|
@@ -4,7 +4,10 @@ require "ammeter/init"
|
|
4
4
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
config.before(:example, :generator) do
|
7
|
-
|
7
|
+
fake_rails_root = File.expand_path("../../../tmp", __FILE__)
|
8
|
+
allow(Rails).to receive(:root).and_return(Pathname.new(fake_rails_root))
|
9
|
+
|
10
|
+
destination fake_rails_root
|
8
11
|
prepare_destination
|
9
12
|
end
|
10
13
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module ViewDefinitionHelpers
|
2
2
|
def with_view_definition(name, version, schema)
|
3
3
|
definition = Scenic::Definition.new(name, version)
|
4
|
+
FileUtils.mkdir_p(File.dirname(definition.full_path))
|
4
5
|
File.open(definition.full_path, "w") { |f| f.write(schema) }
|
5
6
|
yield
|
6
7
|
ensure
|
7
|
-
|
8
|
+
FileUtils.rm_f(definition.full_path)
|
8
9
|
end
|
9
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scenic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Prior
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -250,3 +250,4 @@ test_files:
|
|
250
250
|
- spec/spec_helper.rb
|
251
251
|
- spec/support/generator_spec_setup.rb
|
252
252
|
- spec/support/view_definition_helpers.rb
|
253
|
+
has_rdoc:
|