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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12cc4c93551c150598dd616a1174245760aac19e
4
- data.tar.gz: b108ebf2b5d3b3e4d2d3e70410233773ce09481d
3
+ metadata.gz: e917734f36443e8d261a50f8bcef5c5e65eeebda
4
+ data.tar.gz: d013d537a689625087039b4d6cb2e54a584c73ca
5
5
  SHA512:
6
- metadata.gz: be0ede1893de56e1b53309b4cb8bdb035e9e03b573252390214a448c85a6d8bb6e9cd3b0f85a3b0bb8438442497dd24c29a959e6429e74e7fe9e0a272cefc09d
7
- data.tar.gz: c4753f41f39bb769246e6793e426a63e899bc0873f74b685dd6644755a6fabc4e6ab4edfe996bd1c631e3735d44c4ab5826daa73b73073191a73091a6a2867e0
6
+ metadata.gz: be0c588362c95ab41cf71670954569c6c06e8ff7e7ef5b2a27b23b32eb61dc86ea8e13e3a969c7596ca9d55a86d2f8c9999486ecfdcac025dc70cbca81cddbb7
7
+ data.tar.gz: d1b4171587355aef488df5ebc9d998da4eaa690baf3e8aad2a6ca9ab6db1b11a4bbe1ac07c43c2c9305b5761b43d24298c983cdf1129e795488d1b035cb0daf8
@@ -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.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
- create_file definition.path
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
@@ -6,6 +6,7 @@ module Scenic
6
6
  SELECT viewname, definition
7
7
  FROM pg_views
8
8
  WHERE schemaname = ANY (current_schemas(false))
9
+ AND viewname NOT IN (SELECT extname FROM pg_extension)
9
10
  SQL
10
11
  end
11
12
 
@@ -1,3 +1,3 @@
1
1
  module Scenic
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -18,6 +18,7 @@ module Scenic
18
18
  create_view :#{name}, sql_definition:<<-\SQL
19
19
  #{definition}
20
20
  SQL
21
+
21
22
  DEFINITION
22
23
  end
23
24
  end
@@ -13,14 +13,14 @@ describe Scenic::Generators::ViewGenerator, :generator do
13
13
  end
14
14
 
15
15
  it "updates an existing view" do
16
- migration = file("db/migrate/update_searches_to_version_2.rb")
17
- view_definition = file("db/views/searches_v02.sql")
18
- allow(Dir).to receive(:entries)
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
- run_generator ["search"]
20
+ run_generator ["search"]
22
21
 
23
- expect(migration).to be_a_migration
24
- expect(view_definition).to exist
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
- echo "SELECT '$expectedResult'::text AS results" >> db/views/searches_v$version\.sql
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
- destination File.expand_path("../../../tmp", __FILE__)
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
- File.delete definition.full_path
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.2.1
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-05 00:00:00.000000000 Z
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: