unschema 0.0.5 → 0.1.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: 4243d394a3ed056790202261451bc521418c20aa
4
- data.tar.gz: ad8f5409d7b724f00c0d9aead913859260cbdc10
3
+ metadata.gz: 2686bd6b60b612e83c1fe9cb918cdf590b9dcfe2
4
+ data.tar.gz: 62b58128cf9cf22570d5d9b3ed06b06577289cf7
5
5
  SHA512:
6
- metadata.gz: 7e27fa30ad4f8a21f290ff0214b50dccb8c6cdb6751db48317a6e7410016365fcf27fee5110eda9c448af5ec2217b2eaec8a3c6b2c83aacf73cab37fcf28531b
7
- data.tar.gz: 657a908a1433219e1e1b30f4cdd73be2f90c7780e897234d0a723922dc7851dbb5dff5bac5ebc39507b12369b7774c8c1760439b49cab77c59f5bfb9865d91a3
6
+ metadata.gz: ce6fa5ae2759ba765ca70bc7d215581031bb7db0177ce7bb29266dc17251923d42c3f2e1f9f434be844bf2a24fcab2dd5cede14f0bf7a594ffb4e231e93c60b9
7
+ data.tar.gz: b23aeb38e84fe1681ad5cc533ede0e7a4154b30632a4f89a8480f295f6402b901aaa36011d5fccd751002f739918275c91afe6b56486d8654c2befeaa8211b76
data/.travis.yml CHANGED
@@ -1,12 +1,24 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  rvm:
3
- - "1.9.3"
4
- - "2.0"
5
- - "2.1"
6
- - jruby-19mode
5
+ - ruby-head
6
+ - 2.2
7
+ - 2.1
8
+ - 2.0
9
+ - 1.9.3
10
+ env:
11
+ global:
12
+ - CODECLIMATE_REPO_TOKEN=5149a81a58ceefa61850827c29b5fecc303d15c038b7ad4fb12e8279d2be47ab
7
13
  matrix:
8
14
  fast_finish: true
9
15
  allow_failures:
10
- - jruby-head
11
16
  - ruby-head
12
- - rbx-head
17
+
18
+ notifications:
19
+ webhooks:
20
+ urls:
21
+ - https://webhooks.gitter.im/e/d347d6c0296c3caf01ad
22
+ on_success: change # options: [always|never|change] default: always
23
+ on_failure: always # options: [always|never|change] default: always
24
+ on_start: false # default: false
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in unschema.gemspec
4
4
  gemspec
5
+
6
+ if ENV['CODECLIMATE_REPO_TOKEN']
7
+ gem "codeclimate-test-reporter", :group => :test, :require => nil
8
+ end
data/README.md CHANGED
@@ -1,9 +1,24 @@
1
- # Unschema - rebase your schema.rb
1
+ [github]: https://github.com/neopoly/unschema
2
+ [doc]: http://rubydoc.info/github/neopoly/unschema/master/file/README.md
3
+ [gem]: https://rubygems.org/gems/unschema
4
+ [travis]: https://travis-ci.org/neopoly/unschema
5
+ [codeclimate]: https://codeclimate.com/github/neopoly/unschema
6
+ [inchpages]: https://inch-ci.org/github/neopoly/unschema
2
7
 
3
- [![Build Status](http://img.shields.io/travis/neopoly/unschema.svg?branch=master)](https://travis-ci.org/neopoly/unschema) [![Gem Version](http://img.shields.io/gem/v/unschema.svg)](https://rubygems.org/gems/unschema) [![Code Climate](http://img.shields.io/codeclimate/github/neopoly/unschema.svg)](https://codeclimate.com/github/neopoly/unschema) [![Inline docs](http://inch-ci.org/github/neopoly/unschema.svg?branch=master)](http://inch-ci.org/github/neopoly/unschema)
8
+ # Unschema - rebase your schema.rb
4
9
 
5
10
  Splits your schema.rb into separate migrations per table.
6
11
 
12
+ [![Travis](https://img.shields.io/travis/neopoly/unschema.svg?branch=master)][travis]
13
+ [![Gem Version](https://img.shields.io/gem/v/unschema.svg)][gem]
14
+ [![Code Climate](https://img.shields.io/codeclimate/github/neopoly/unschema.svg)][codeclimate]
15
+ [![Test Coverage](https://codeclimate.com/github/neopoly/unschema/badges/coverage.svg)][codeclimate]
16
+ [![Inline docs](https://inch-ci.org/github/neopoly/unschema.svg?branch=master&style=flat)][inchpages]
17
+
18
+ [Gem][gem] |
19
+ [Source][github] |
20
+ [Documentation][doc]
21
+
7
22
  Every table migration contains a create_table and additional add_index calls.
8
23
 
9
24
  We use it to cleanup older projects, that gets reused as codebase for new projects.
data/lib/unschema/base.rb CHANGED
@@ -10,29 +10,44 @@ module Unschema
10
10
 
11
11
  def process
12
12
  load schema_file
13
+ preset_version
13
14
 
14
- @version = ActiveRecord::Schema.intermediator.version
15
-
16
- calls_for_tables = Hash.new{|hash, key| hash[key] = []}
17
-
18
- ActiveRecord::Schema.intermediator.calls.each do |call|
19
- table_name = call.args.first.to_s if [:create_table, :add_index].include?(call.name)
20
- raise "Don't now how to process #{call.name.inspect}" unless table_name
21
-
22
- calls_for_tables[table_name] << call
23
- end
24
-
25
- puts "Found #{calls_for_tables.keys.size} tables" if verbose?
15
+ calls_for_tables = collect_calls(intermediator.calls)
16
+ log "Found #{calls_for_tables.size} tables"
26
17
 
27
18
  calls_for_tables.sort.each do |table_name, calls|
28
- puts " Dumping #{table_name.inspect}" if verbose?
19
+ log " Dumping #{table_name.inspect}"
29
20
  dump_table_calls table_name, calls
30
21
  end
31
- puts "Done" if verbose?
22
+
23
+ log "Done"
32
24
  end
33
25
 
34
26
  private
35
27
 
28
+ def log(string)
29
+ puts string if verbose?
30
+ end
31
+
32
+ def preset_version
33
+ @version = intermediator.version
34
+ end
35
+
36
+ def intermediator
37
+ ActiveRecord::Schema.intermediator
38
+ end
39
+
40
+ def collect_calls(calls)
41
+ calls_for_tables = Hash.new { |hash, key| hash[key] = [] }
42
+
43
+ calls.each do |call|
44
+ table_name = call.first_arg
45
+ calls_for_tables[table_name] << call
46
+ end
47
+
48
+ calls_for_tables
49
+ end
50
+
36
51
  def dump_table_calls(table_name, calls)
37
52
  file = File.join(migrations_path, "#{next_migration}_create_#{table_name}.rb")
38
53
  File.open(file, "w") do |f|
@@ -14,7 +14,7 @@ module Unschema
14
14
  end
15
15
 
16
16
  f << " end\n"
17
- f << "end"
17
+ f << "end\n"
18
18
  end
19
19
 
20
20
  private
@@ -24,6 +24,10 @@ module Unschema
24
24
  process_block!(block) if block
25
25
  end
26
26
 
27
+ def first_arg
28
+ args.first
29
+ end
30
+
27
31
  def method_missing(name, *args, &block)
28
32
  @calls << Call.new(name, *args, &block)
29
33
  end
@@ -1,3 +1,3 @@
1
1
  module Unschema
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
data/test/helper.rb CHANGED
@@ -1,10 +1,15 @@
1
+ if ENV['CODECLIMATE_REPO_TOKEN']
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ end
5
+
1
6
  require 'minitest/autorun'
2
7
 
3
8
  require 'unschema'
4
9
 
5
10
  class TestCase < Minitest::Test
6
11
  def assert_string(actual, expect)
7
- assert_equal expect.unindent.chomp, actual.unindent
12
+ assert_equal expect.unindent, actual.unindent
8
13
  end
9
14
  end
10
15
 
data/unschema.gemspec CHANGED
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_development_dependency 'rake'
21
- gem.add_development_dependency 'minitest', '~> 5.3.5'
21
+ gem.add_development_dependency 'minitest', '~> 5.5'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unschema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Holderbaum
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.3.5
33
+ version: '5.5'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 5.3.5
40
+ version: '5.5'
41
41
  description: Splits your current schema.rb into per-table migrations. Think of it
42
42
  as >rebase< for your migrations.
43
43
  email: