fix-db-schema-conflicts 1.2.0 → 1.2.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -0
  3. data/.rubocop_schema.yml +6 -0
  4. data/README.md +7 -0
  5. data/fix-db-schema-conflicts.gemspec +4 -1
  6. data/lib/fix_db_schema_conflicts/schema_dumper.rb +22 -7
  7. data/lib/fix_db_schema_conflicts/version.rb +1 -1
  8. data/spec/integration/integration_spec.rb +62 -0
  9. data/spec/spec_helper.rb +96 -0
  10. data/spec/test-app/.gitignore +17 -0
  11. data/spec/test-app/Gemfile +8 -0
  12. data/spec/test-app/Gemfile.lock +125 -0
  13. data/spec/test-app/README.rdoc +28 -0
  14. data/spec/test-app/Rakefile +6 -0
  15. data/spec/test-app/app/assets/images/.keep +0 -0
  16. data/spec/test-app/app/assets/javascripts/application.js +16 -0
  17. data/spec/test-app/app/assets/stylesheets/application.css +15 -0
  18. data/spec/test-app/app/controllers/application_controller.rb +5 -0
  19. data/spec/test-app/app/controllers/concerns/.keep +0 -0
  20. data/spec/test-app/app/helpers/application_helper.rb +2 -0
  21. data/spec/test-app/app/mailers/.keep +0 -0
  22. data/spec/test-app/app/models/.keep +0 -0
  23. data/spec/test-app/app/models/company.rb +2 -0
  24. data/spec/test-app/app/models/concerns/.keep +0 -0
  25. data/spec/test-app/app/models/person.rb +2 -0
  26. data/spec/test-app/app/views/layouts/application.html.erb +14 -0
  27. data/spec/test-app/bin/bundle +3 -0
  28. data/spec/test-app/bin/rails +9 -0
  29. data/spec/test-app/bin/rake +9 -0
  30. data/spec/test-app/bin/setup +29 -0
  31. data/spec/test-app/bin/spring +15 -0
  32. data/spec/test-app/config.ru +4 -0
  33. data/spec/test-app/config/application.rb +26 -0
  34. data/spec/test-app/config/boot.rb +3 -0
  35. data/spec/test-app/config/database.yml +25 -0
  36. data/spec/test-app/config/environment.rb +5 -0
  37. data/spec/test-app/config/environments/development.rb +41 -0
  38. data/spec/test-app/config/environments/production.rb +79 -0
  39. data/spec/test-app/config/environments/test.rb +42 -0
  40. data/spec/test-app/config/initializers/assets.rb +11 -0
  41. data/spec/test-app/config/initializers/backtrace_silencers.rb +7 -0
  42. data/spec/test-app/config/initializers/cookies_serializer.rb +3 -0
  43. data/spec/test-app/config/initializers/filter_parameter_logging.rb +4 -0
  44. data/spec/test-app/config/initializers/inflections.rb +16 -0
  45. data/spec/test-app/config/initializers/mime_types.rb +4 -0
  46. data/spec/test-app/config/initializers/session_store.rb +3 -0
  47. data/spec/test-app/config/initializers/wrap_parameters.rb +14 -0
  48. data/spec/test-app/config/locales/en.yml +23 -0
  49. data/spec/test-app/config/routes.rb +56 -0
  50. data/spec/test-app/config/secrets.yml +22 -0
  51. data/spec/test-app/db/migrate/20160322223225_create_people.rb +12 -0
  52. data/spec/test-app/db/migrate/20160322223258_create_companies.rb +19 -0
  53. data/spec/test-app/db/schema.rb +39 -0
  54. data/spec/test-app/db/seeds.rb +7 -0
  55. data/spec/test-app/lib/assets/.keep +0 -0
  56. data/spec/test-app/lib/tasks/.keep +0 -0
  57. data/spec/test-app/log/.keep +0 -0
  58. data/spec/test-app/public/404.html +67 -0
  59. data/spec/test-app/public/422.html +67 -0
  60. data/spec/test-app/public/500.html +66 -0
  61. data/spec/test-app/public/favicon.ico +0 -0
  62. data/spec/test-app/public/robots.txt +5 -0
  63. data/spec/test-app/test/controllers/.keep +0 -0
  64. data/spec/test-app/test/fixtures/.keep +0 -0
  65. data/spec/test-app/test/fixtures/companies.yml +19 -0
  66. data/spec/test-app/test/fixtures/people.yml +13 -0
  67. data/spec/test-app/test/helpers/.keep +0 -0
  68. data/spec/test-app/test/integration/.keep +0 -0
  69. data/spec/test-app/test/mailers/.keep +0 -0
  70. data/spec/test-app/test/models/.keep +0 -0
  71. data/spec/test-app/test/models/company_test.rb +7 -0
  72. data/spec/test-app/test/models/person_test.rb +7 -0
  73. data/spec/test-app/test/test_helper.rb +10 -0
  74. data/spec/test-app/vendor/assets/javascripts/.keep +0 -0
  75. data/spec/test-app/vendor/assets/stylesheets/.keep +0 -0
  76. metadata +184 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b31f634488c200cf35a222e6d9757df89f01c7be
4
- data.tar.gz: cd3109362b2eb0be6f147c0bd9d0489756da20b4
3
+ metadata.gz: 91f9ae814e0c6eb43a7a00649383e87d2d576907
4
+ data.tar.gz: 79c2473824d3e891a67c857c0d91aaa87177bc6b
5
5
  SHA512:
6
- metadata.gz: 0ab89a8b80be45878ca5c3d4463ef74d1402f9c23a41be6a45149452e0f8c3487d9ae63546a2a5e38c86a06d72d530b40044f162a0c044c26d325ab32389059d
7
- data.tar.gz: e715a73705e63559e15c2c0cc2682a94bf8470e160e3a4973b6b4e9310a5054c4e71f8f82a8a7749188ddea2aafec7535b80fc584dda245e236366f3f5c870a6
6
+ metadata.gz: 5a6d5a9220171c134f35fd03af0d3f4a4e225ad153c0a88f05171570a26a5f21166890bb0b1d23aeb4f47b1e6791aa0476d2ad70708ac99d0000bffb5ffd13df
7
+ data.tar.gz: 73c5b1adc970434b882fcff25744e3ca14447889cb7ef5267ff74d41632c5a334333d4a14fb50da93b1c3be0e5de52730224e755f5989424c84c43b4a6bae933
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -1,3 +1,9 @@
1
+ Style/ExtraSpacing:
2
+ # When true, allows most uses of extra spacing if the intent is to align
3
+ # things with the previous or next line, not counting empty lines or comment
4
+ # lines.
5
+ AllowForAlignment: false
6
+
1
7
  Style/NumericLiterals:
2
8
  Exclude:
3
9
  - 'db/schema.rb'
data/README.md CHANGED
@@ -58,3 +58,10 @@ If you wish to use a version of Rubocop `< 0.36.0` or below, use `gem 'fix-db-sc
58
58
  - @TCampaigne
59
59
  - @Lordnibbler
60
60
  - @jakeonrails
61
+
62
+ ## Releases
63
+ - 1.2.1
64
+ - Upgrade Rubocop to get major performance boost
65
+ - Add support for sorting of extensions
66
+ - Fix spacing regression introduced by Rubocop upgrade
67
+ - Add test suite and an integration test
@@ -20,6 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency 'rails'
25
+ spec.add_development_dependency 'sqlite3'
23
26
 
24
- spec.add_dependency "rubocop", ">= 0.36.0"
27
+ spec.add_dependency "rubocop", ">= 0.38.0"
25
28
  end
@@ -8,7 +8,11 @@ module ActiveRecord
8
8
  class SchemaDumper
9
9
 
10
10
  private
11
- class TableSorter < SimpleDelegator
11
+ class ConnectionWithSorting < SimpleDelegator
12
+ def extensions
13
+ __getobj__.extensions.sort
14
+ end
15
+
12
16
  def columns(table)
13
17
  __getobj__.columns(table).sort_by(&:name)
14
18
  end
@@ -22,14 +26,25 @@ module ActiveRecord
22
26
  end
23
27
  end
24
28
 
25
- def table_with_sorting(table, stream)
26
- old_connection = @connection
27
- @connection = TableSorter.new(old_connection)
28
- result = table_without_sorting(table, stream)
29
- @connection = old_connection
30
- result
29
+ def extensions_with_sorting(*args)
30
+ with_sorting do
31
+ extensions_without_sorting(*args)
32
+ end
33
+ end
34
+ alias_method_chain :extensions, :sorting
35
+
36
+ def table_with_sorting(*args)
37
+ with_sorting do
38
+ table_without_sorting(*args)
39
+ end
31
40
  end
32
41
  alias_method_chain :table, :sorting
33
42
 
43
+ def with_sorting(&block)
44
+ old, @connection = @connection, ConnectionWithSorting.new(@connection)
45
+ result = yield
46
+ @connection = old
47
+ result
48
+ end
34
49
  end
35
50
  end
@@ -1,3 +1,3 @@
1
1
  module FixDBSchemaConflicts
2
- VERSION='1.2.0'
2
+ VERSION='1.2.1'
3
3
  end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Fix DB Schema Conflicts' do
4
+
5
+ let(:expected_lines) { reference_db_schema.lines }
6
+
7
+ it 'generates a sorted schema with no extra spacing' do
8
+
9
+ `cd spec/test-app && rm db/schema.rb && rake db:migrate`
10
+
11
+ generated_lines = File.readlines('spec/test-app/db/schema.rb')
12
+
13
+ generated_lines.zip(expected_lines).each do |generated, expected|
14
+ next if expected.nil?
15
+ next if expected.start_with?('ActiveRecord::Schema.define')
16
+ expect(generated).to eq(expected)
17
+ end
18
+ end
19
+ end
20
+
21
+ def reference_db_schema
22
+ <<-RUBY
23
+ # encoding: UTF-8
24
+ # This file is auto-generated from the current state of the database. Instead
25
+ # of editing this file, please use the migrations feature of Active Record to
26
+ # incrementally modify your database, and then regenerate this schema definition.
27
+ #
28
+ # Note that this schema.rb definition is the authoritative source for your
29
+ # database schema. If you need to create the application database on another
30
+ # system, you should be using db:schema:load, not running all the migrations
31
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
32
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
33
+ #
34
+ # It's strongly recommended that you check this file into your version control system.
35
+
36
+ ActiveRecord::Schema.define(version: 20160322223258) do
37
+ create_table "companies", force: :cascade do |t|
38
+ t.string "addr1"
39
+ t.string "addr2"
40
+ t.string "city"
41
+ t.datetime "created_at", null: false
42
+ t.string "name"
43
+ t.string "phone"
44
+ t.string "state"
45
+ t.datetime "updated_at", null: false
46
+ t.string "zip"
47
+ end
48
+
49
+ add_index "companies", ["city"], name: "index_companies_on_city"
50
+ add_index "companies", ["name"], name: "index_companies_on_name"
51
+ add_index "companies", ["state"], name: "index_companies_on_state"
52
+
53
+ create_table "people", force: :cascade do |t|
54
+ t.integer "age"
55
+ t.date "birthdate"
56
+ t.datetime "created_at", null: false
57
+ t.string "first_name"
58
+ t.string "last_name"
59
+ t.datetime "updated_at", null: false
60
+ end
61
+ RUBY
62
+ end
@@ -0,0 +1,96 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Allows RSpec to persist some state between runs in order to support
54
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
55
+ # you configure your source control system to ignore this file.
56
+ config.example_status_persistence_file_path = "spec/examples.txt"
57
+
58
+ # Limits the available syntax to the non-monkey patched syntax that is
59
+ # recommended. For more details, see:
60
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
61
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
62
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
63
+ config.disable_monkey_patching!
64
+
65
+ # This setting enables warnings. It's recommended, but in some cases may
66
+ # be too noisy due to issues in dependencies.
67
+ config.warnings = true
68
+
69
+ # Many RSpec users commonly either run the entire suite or an individual
70
+ # file, and it's useful to allow more verbose output when running an
71
+ # individual spec file.
72
+ if config.files_to_run.one?
73
+ # Use the documentation formatter for detailed output,
74
+ # unless a formatter has already been configured
75
+ # (e.g. via a command-line flag).
76
+ config.default_formatter = 'doc'
77
+ end
78
+
79
+ # Print the 10 slowest examples and example groups at the
80
+ # end of the spec run, to help surface which specs are running
81
+ # particularly slow.
82
+ config.profile_examples = 10
83
+
84
+ # Run specs in random order to surface order dependencies. If you find an
85
+ # order dependency and want to debug it, you can fix the order by providing
86
+ # the seed, which is printed after each run.
87
+ # --seed 1234
88
+ config.order = :random
89
+
90
+ # Seed global randomization in this process using the `--seed` CLI option.
91
+ # Setting this allows you to use `--seed` to deterministically reproduce
92
+ # test failures related to randomization by passing the same `--seed` value
93
+ # as the one that triggered the failure.
94
+ Kernel.srand config.seed
95
+ =end
96
+ end
@@ -0,0 +1,17 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*
16
+ !/log/.keep
17
+ /tmp
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.2.5.2'
5
+ # Use sqlite3 as the database for Active Record
6
+ gem 'sqlite3'
7
+
8
+ gem 'fix-db-schema-conflicts', path: '../..'
@@ -0,0 +1,125 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ fix-db-schema-conflicts (1.2.0)
5
+ rubocop (>= 0.36.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.2.5.2)
11
+ actionpack (= 4.2.5.2)
12
+ actionview (= 4.2.5.2)
13
+ activejob (= 4.2.5.2)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.5.2)
17
+ actionview (= 4.2.5.2)
18
+ activesupport (= 4.2.5.2)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (4.2.5.2)
24
+ activesupport (= 4.2.5.2)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ activejob (4.2.5.2)
30
+ activesupport (= 4.2.5.2)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.5.2)
33
+ activesupport (= 4.2.5.2)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.5.2)
36
+ activemodel (= 4.2.5.2)
37
+ activesupport (= 4.2.5.2)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.5.2)
40
+ i18n (~> 0.7)
41
+ json (~> 1.7, >= 1.7.7)
42
+ minitest (~> 5.1)
43
+ thread_safe (~> 0.3, >= 0.3.4)
44
+ tzinfo (~> 1.1)
45
+ arel (6.0.3)
46
+ ast (2.2.0)
47
+ builder (3.2.2)
48
+ concurrent-ruby (1.0.1)
49
+ erubis (2.7.0)
50
+ globalid (0.3.6)
51
+ activesupport (>= 4.1.0)
52
+ i18n (0.7.0)
53
+ json (1.8.3)
54
+ loofah (2.0.3)
55
+ nokogiri (>= 1.5.9)
56
+ mail (2.6.3)
57
+ mime-types (>= 1.16, < 3)
58
+ mime-types (2.99.1)
59
+ mini_portile2 (2.0.0)
60
+ minitest (5.8.4)
61
+ nokogiri (1.6.7.2)
62
+ mini_portile2 (~> 2.0.0.rc2)
63
+ parser (2.3.0.6)
64
+ ast (~> 2.2)
65
+ powerpack (0.1.1)
66
+ rack (1.6.4)
67
+ rack-test (0.6.3)
68
+ rack (>= 1.0)
69
+ rails (4.2.5.2)
70
+ actionmailer (= 4.2.5.2)
71
+ actionpack (= 4.2.5.2)
72
+ actionview (= 4.2.5.2)
73
+ activejob (= 4.2.5.2)
74
+ activemodel (= 4.2.5.2)
75
+ activerecord (= 4.2.5.2)
76
+ activesupport (= 4.2.5.2)
77
+ bundler (>= 1.3.0, < 2.0)
78
+ railties (= 4.2.5.2)
79
+ sprockets-rails
80
+ rails-deprecated_sanitizer (1.0.3)
81
+ activesupport (>= 4.2.0.alpha)
82
+ rails-dom-testing (1.0.7)
83
+ activesupport (>= 4.2.0.beta, < 5.0)
84
+ nokogiri (~> 1.6.0)
85
+ rails-deprecated_sanitizer (>= 1.0.1)
86
+ rails-html-sanitizer (1.0.3)
87
+ loofah (~> 2.0)
88
+ railties (4.2.5.2)
89
+ actionpack (= 4.2.5.2)
90
+ activesupport (= 4.2.5.2)
91
+ rake (>= 0.8.7)
92
+ thor (>= 0.18.1, < 2.0)
93
+ rainbow (2.1.0)
94
+ rake (11.1.1)
95
+ rubocop (0.38.0)
96
+ parser (>= 2.3.0.6, < 3.0)
97
+ powerpack (~> 0.1)
98
+ rainbow (>= 1.99.1, < 3.0)
99
+ ruby-progressbar (~> 1.7)
100
+ unicode-display_width (~> 1.0, >= 1.0.1)
101
+ ruby-progressbar (1.7.5)
102
+ sprockets (3.5.2)
103
+ concurrent-ruby (~> 1.0)
104
+ rack (> 1, < 3)
105
+ sprockets-rails (3.0.4)
106
+ actionpack (>= 4.0)
107
+ activesupport (>= 4.0)
108
+ sprockets (>= 3.0.0)
109
+ sqlite3 (1.3.11)
110
+ thor (0.19.1)
111
+ thread_safe (0.3.5)
112
+ tzinfo (1.2.2)
113
+ thread_safe (~> 0.1)
114
+ unicode-display_width (1.0.2)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ fix-db-schema-conflicts!
121
+ rails (= 4.2.5.2)
122
+ sqlite3
123
+
124
+ BUNDLED WITH
125
+ 1.10.6
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks