leifcr-mongrations 0.1.6 → 0.1.7

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: 5a4fa8cb3eb9e92370130c33f6bdddf8aa86b1d9
4
- data.tar.gz: d642e0451b8b3eb30a26b9e34c2da68de89e2a88
3
+ metadata.gz: 0115914345266895ae8292f7275f93ec366d935c
4
+ data.tar.gz: 84e23605b4f882ffd86aaa5499c1d712c4f15d47
5
5
  SHA512:
6
- metadata.gz: fb5a97d2bc8e07b825ae18f53505dc87f620d11df432810fc1d4b1e6abba83886481b9cf0fbc0986b8e2e7a13144fb3278be9bea142cec2b267bf09ab931fd63
7
- data.tar.gz: 846b26b38da1d03427cd373a7868693dc4514dd413f9643fba4969eb6afc0d3288302ace59718925faeb57e94a8083c1c986fd3c710498e3bc972856f321646a
6
+ metadata.gz: b8f8df12e4c1845f766a67ba7eeaa3de33fc661fab595e26a8f86b2bc0833624b4bbdf162b59f22aaaa8fad50e09ed963cfce7d6b35029ae363ef32be229b23d
7
+ data.tar.gz: f9cdaa4188888aceb766227b0e084401820aa02d7e48dca62f85d8b135190f5b8ee9eff944613c428b210c0bbaec699e5d870d3bbe2f6714ac3e1ae5d078e01d
@@ -0,0 +1,6 @@
1
+ *.swp
2
+ *~
3
+ pkg/
4
+ *.sublime-workspace
5
+
6
+
@@ -0,0 +1,2 @@
1
+ rails_32_gem_devel
2
+
@@ -0,0 +1,2 @@
1
+ 2.1.2
2
+
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 2.0.0
3
+ - 2.1.2
4
+ notifications:
5
+ email: false
6
+ services:
7
+ - mongodb
data/Gemfile CHANGED
@@ -1,8 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem "mongo_mapper", ">= 0.12.0"
4
-
5
- group :development do
6
- gem "bundler", ">= 1.3.5"
7
- gem "jeweler", "~> 1.8.8"
8
- end
3
+ gemspec
@@ -1,69 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ leifcr-mongrations (0.1.7)
5
+ activemodel (~> 3.2.0)
6
+ activesupport (~> 3.2.0)
7
+ mongo_mapper (~> 0.13.0)
8
+
1
9
  GEM
2
10
  remote: http://rubygems.org/
3
11
  specs:
4
- activemodel (3.2.15)
5
- activesupport (= 3.2.15)
12
+ activemodel (3.2.19)
13
+ activesupport (= 3.2.19)
6
14
  builder (~> 3.0.0)
7
- activesupport (3.2.15)
15
+ activesupport (3.2.19)
8
16
  i18n (~> 0.6, >= 0.6.4)
9
17
  multi_json (~> 1.0)
10
- addressable (2.3.5)
11
- bson (1.9.2)
18
+ bson (1.10.2)
12
19
  builder (3.0.4)
13
- faraday (0.8.8)
14
- multipart-post (~> 1.2.0)
15
- git (1.2.6)
16
- github_api (0.10.1)
17
- addressable
18
- faraday (~> 0.8.1)
19
- hashie (>= 1.2)
20
- multi_json (~> 1.4)
21
- nokogiri (~> 1.5.2)
22
- oauth2
23
- hashie (2.0.5)
24
- highline (1.6.20)
25
- httpauth (0.2.0)
26
- i18n (0.6.5)
27
- jeweler (1.8.8)
28
- builder
29
- bundler (~> 1.0)
30
- git (>= 1.2.5)
31
- github_api (= 0.10.1)
32
- highline (>= 1.6.15)
33
- nokogiri (= 1.5.10)
34
- rake
35
- rdoc
36
- json (1.8.1)
37
- jwt (0.1.8)
38
- multi_json (>= 1.5)
39
- mongo (1.9.2)
40
- bson (~> 1.9.2)
41
- mongo_mapper (0.12.0)
42
- activemodel (~> 3.0)
43
- activesupport (~> 3.0)
44
- plucky (~> 0.5.2)
20
+ i18n (0.6.11)
21
+ mcmire-matchy (0.5.2)
22
+ mongo (1.10.2)
23
+ bson (= 1.10.2)
24
+ mongo_mapper (0.13.0)
25
+ activemodel (>= 3.0.0)
26
+ activesupport (>= 3.0)
27
+ mongo (~> 1.8)
28
+ plucky (~> 0.6.5)
45
29
  multi_json (1.8.2)
46
- multi_xml (0.5.5)
47
- multipart-post (1.2.0)
48
- nokogiri (1.5.10)
49
- oauth2 (0.9.2)
50
- faraday (~> 0.8)
51
- httpauth (~> 0.2)
52
- jwt (~> 0.1.4)
53
- multi_json (~> 1.0)
54
- multi_xml (~> 0.5)
55
- rack (~> 1.2)
56
- plucky (0.5.2)
30
+ plucky (0.6.6)
57
31
  mongo (~> 1.5)
58
- rack (1.5.2)
59
- rake (10.1.0)
60
- rdoc (4.0.1)
61
- json (~> 1.4)
32
+ rake (10.3.2)
33
+ shoulda (3.5.0)
34
+ shoulda-context (~> 1.0, >= 1.0.1)
35
+ shoulda-matchers (>= 1.4.1, < 3.0)
36
+ shoulda-context (1.2.1)
37
+ shoulda-matchers (2.6.2)
38
+ activesupport (>= 3.0.0)
62
39
 
63
40
  PLATFORMS
64
41
  ruby
65
42
 
66
43
  DEPENDENCIES
67
- bundler (>= 1.3.5)
68
- jeweler (~> 1.8.8)
69
- mongo_mapper (>= 0.12.0)
44
+ bundler (~> 1.6)
45
+ leifcr-mongrations!
46
+ mcmire-matchy (~> 0.5.2)
47
+ rake
48
+ shoulda
@@ -1,56 +1,24 @@
1
- Mongrations
2
- ===========
1
+ [![Build Status](https://travis-ci.org/leifcr/mongrations.svg)](https://travis-ci.org/leifcr/mongrations)
2
+
3
+ # Mongrations
3
4
 
4
5
  Mongrations aims to be similar to ActiveRecord's data migrations, except
5
6
  instead of worrying about schema changes, offering a way to change data when
6
- necessary.
7
-
8
- Example: You decide after a few weeks of running an application that you want
9
- to add timestamps, and want to display the created_at time for an application.
10
-
11
- You could put a default timestamp into the model (and in this case that might
12
- be appropriate), but you might also just want to say, "everything needs to get
13
- a new timestamp that doesn't already have one, let's say when the US beat
14
- Canada in hockey in the Olympics."
7
+ necessary.
15
8
 
9
+ ## Example
16
10
 
17
- Example
18
- =======
11
+ To generate a mongration:
19
12
 
20
- To generate a mongration, just do:
13
+ `rails g mongration whatever_you_want_your_mongration_to_be`
21
14
 
22
- `script/generate mongration whatever_you_want_your_mongration_to_be`
23
-
24
- To run it, do
15
+ Perform migrations
25
16
 
26
17
  `rake mongo:mongrate`
27
18
 
28
- Other rake tasks added have been `mongo:mongrate:redo`, `mongo:mongrate:up`, `mongo:mongrate:down`, `mongo:mongrate:rollback`.
29
-
30
-
31
- Dependencies
32
- ============
33
-
34
- You need Mongo and MongoMapper for this to be of any use.
35
-
36
- Also, this has only been tested on Rails 3.2.3.
37
-
38
- Disclaimer
39
- ==========
40
-
41
- *This is not ready for production*
42
-
43
- I just adapted this, at 10:30PM, half watching the Olympics. I'm not responsible
44
- for any damage to your data, your mongodb, your bongos, your cat, your wife, or
45
- your kids as a result of installing this plugin.
19
+ Other rake tasks `mongo:mongrate:redo`, `mongo:mongrate:up`, `mongo:mongrate:down`, `mongo:mongrate:rollback`, `mongo:mongrate:version`.
46
20
 
47
- Give it a few days. Please report bugs.
48
21
 
49
- Credit
50
- ======
51
- Original code is from Rails 2.3.5 and ActiveRecord 2.3.5, now adapted to work
52
- with MongoMapper.
22
+ ## License
53
23
 
54
- License
55
- =======
56
24
  Released under the MIT license
data/Rakefile CHANGED
@@ -1,20 +1,25 @@
1
- require 'rubygems'
2
1
  require 'rake'
2
+ require "bundler/gem_tasks"
3
+
3
4
  require 'rake/testtask'
5
+ # require 'rake/rdoctask'
6
+
7
+ desc 'Default: run unit tests.'
8
+ task :default => :test
4
9
 
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "leifcr-mongrations"
9
- gem.summary = %Q{Data migrating for MongoMapper}
10
- gem.description = %Q{Mongrations aims to be similar to ActiveRecord's data migrations, except
11
- instead of worrying about schema changes, offering a way to change data when
12
- necessary}
13
- gem.email = "leifcr@gmail.com"
14
- gem.homepage = "http://github.com/leifcr/mongrations"
15
- gem.authors = ["jonbell", "leifcr"]
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
10
+ desc 'Test the mongrations plugin.'
11
+ Rake::TestTask.new(:test) do |t|
12
+ t.libs << 'lib'
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = true
20
16
  end
17
+
18
+ # desc 'Generate documentation for the mongrations plugin.'
19
+ # Rake::RDocTask.new(:rdoc) do |rdoc|
20
+ # rdoc.rdoc_dir = 'rdoc'
21
+ # rdoc.title = 'Mongrations'
22
+ # rdoc.options << '--line-numbers' << '--inline-source'
23
+ # rdoc.rdoc_files.include('README')
24
+ # rdoc.rdoc_files.include('lib/**/*.rb')
25
+ # end
@@ -1,66 +1,28 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: leifcr-mongrations 0.1.6 ruby lib
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mongrations/version'
6
5
 
7
- Gem::Specification.new do |s|
8
- s.name = "leifcr-mongrations"
9
- s.version = "0.1.6"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "leifcr-mongrations"
8
+ spec.version = Mongrations::VERSION
9
+ spec.authors = ["jonbell", "Leif Ringstad"]
10
+ spec.email = ["leifcr@gmail.com"]
11
+ spec.summary = "Data migrating for MongoMapper"
12
+ spec.description = "Mongrations aims to be similar to ActiveRecord's data migrations, except\ninstead of worrying about schema changes, offering a way to change data when\nnecessary"
13
+ spec.homepage = "http://github.com/leifcr/mongrations"
14
+ spec.license = "MIT"
10
15
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.authors = ["jonbell", "leifcr"]
13
- s.date = "2013-10-28"
14
- s.description = "Mongrations aims to be similar to ActiveRecord's data migrations, except\ninstead of worrying about schema changes, offering a way to change data when\nnecessary"
15
- s.email = "leifcr@gmail.com"
16
- s.extra_rdoc_files = [
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- "Gemfile",
21
- "Gemfile.lock",
22
- "MIT-LICENSE",
23
- "README.markdown",
24
- "Rakefile",
25
- "VERSION",
26
- "generators/mongrations/templates/mongration.rb",
27
- "generators/mongrations_generator.rb",
28
- "init.rb",
29
- "install.rb",
30
- "leifcr-mongrations.gemspec",
31
- "lib/mongrations.rb",
32
- "lib/mongrations/exceptions.rb",
33
- "lib/mongrations/migration_proxy.rb",
34
- "lib/mongrations/migrator.rb",
35
- "lib/mongrations/mongration.rb",
36
- "lib/mongrations/railtie.rb",
37
- "lib/mongrations/schema_migration.rb",
38
- "tasks/mongo.rake",
39
- "test/mongrations_test.rb",
40
- "test/test_helper.rb",
41
- "uninstall.rb"
42
- ]
43
- s.homepage = "http://github.com/leifcr/mongrations"
44
- s.require_paths = ["lib"]
45
- s.rubygems_version = "2.1.4"
46
- s.summary = "Data migrating for MongoMapper"
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
47
20
 
48
- if s.respond_to? :specification_version then
49
- s.specification_version = 4
50
-
51
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_runtime_dependency(%q<mongo_mapper>, [">= 0.12.0"])
53
- s.add_development_dependency(%q<bundler>, [">= 1.3.5"])
54
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.8"])
55
- else
56
- s.add_dependency(%q<mongo_mapper>, [">= 0.12.0"])
57
- s.add_dependency(%q<bundler>, [">= 1.3.5"])
58
- s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
59
- end
60
- else
61
- s.add_dependency(%q<mongo_mapper>, [">= 0.12.0"])
62
- s.add_dependency(%q<bundler>, [">= 1.3.5"])
63
- s.add_dependency(%q<jeweler>, ["~> 1.8.8"])
64
- end
21
+ spec.add_runtime_dependency "mongo_mapper", "~> 0.13.0"
22
+ spec.add_runtime_dependency "activemodel", "~> 3.2.0"
23
+ spec.add_runtime_dependency "activesupport", "~> 3.2.0"
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "shoulda"
27
+ spec.add_development_dependency 'mcmire-matchy', '~> 0.5.2'
65
28
  end
66
-
@@ -3,18 +3,21 @@ module Mongrations
3
3
  class << self
4
4
  def migrate(migrations_path, target_version = nil)
5
5
  case
6
- when target_version.nil? then up(migrations_path, target_version)
7
- when current_version > target_version then down(migrations_path, target_version)
8
- else up(migrations_path, target_version)
6
+ when target_version.nil? then
7
+ up(migrations_path, target_version)
8
+ when current_version > target_version then
9
+ down(migrations_path, target_version)
10
+ else
11
+ up(migrations_path, target_version)
9
12
  end
10
13
  end
11
14
 
12
15
  def rollback(migrations_path, steps=1)
13
- migrator = self.new(:down, migrations_path)
16
+ migrator = self.new(:down, migrations_path)
14
17
  start_index = migrator.migrations.index(migrator.current_migration)
15
-
18
+
16
19
  return unless start_index
17
-
20
+
18
21
  finish = migrator.migrations[start_index + steps]
19
22
  down(migrations_path, finish ? finish.version : 0)
20
23
  end
@@ -26,7 +29,7 @@ module Mongrations
26
29
  def down(migrations_path, target_version = nil)
27
30
  self.new(:down, migrations_path, target_version).migrate
28
31
  end
29
-
32
+
30
33
  def run(direction, migrations_path, target_version)
31
34
  self.new(direction, migrations_path, target_version).run
32
35
  end
@@ -41,22 +44,23 @@ module Mongrations
41
44
 
42
45
  def proper_table_name(name)
43
46
  # Use the Active Record objects own table_name, or pre/suffix from MongoMapper::Base if name is a symbol/string
44
- name.table_name rescue "#{MongoMapper::Base.table_name_prefix}#{name}#{MongoMapper::Base.table_name_suffix}"
47
+ name.table_name rescue name.to_s
45
48
  end
46
49
  end
47
50
 
48
51
  def initialize(direction, migrations_path, target_version = nil)
49
- @direction, @migrations_path, @target_version = direction, migrations_path, target_version
52
+ target_version = target_version.to_i unless target_version.nil?
53
+ @direction, @migrations_path, @target_version = direction, migrations_path, target_version
50
54
  end
51
55
 
52
56
  def current_version
53
57
  migrated.last || 0
54
58
  end
55
-
59
+
56
60
  def current_migration
57
61
  migrations.detect { |m| m.version == current_version }
58
62
  end
59
-
63
+
60
64
  def run
61
65
  target = migrations.detect { |m| m.version == @target_version }
62
66
  raise UnknownMigrationVersionError.new(@target_version) if target.nil?
@@ -68,19 +72,19 @@ module Mongrations
68
72
 
69
73
  def migrate
70
74
  current = migrations.detect { |m| m.version == current_version }
71
- target = migrations.detect { |m| m.version == @target_version }
75
+ target = migrations.detect { |m| m.version == @target_version }
72
76
 
73
77
  if target.nil? && !@target_version.nil? && @target_version > 0
74
78
  raise UnknownMigrationVersionError.new(@target_version)
75
79
  end
76
-
77
- start = up? ? 0 : (migrations.index(current) || 0)
78
- finish = migrations.index(target) || migrations.size - 1
80
+
81
+ start = up? ? 0 : (migrations.index(current) || 0)
82
+ finish = migrations.index(target) || migrations.size - 1
79
83
  runnable = migrations[start..finish]
80
-
84
+
81
85
  # skip the last migration if we're headed down, but not ALL the way down
82
86
  runnable.pop if down? && !target.nil?
83
-
87
+
84
88
  runnable.each do |migration|
85
89
  # On our way up, we skip migrating the ones we've already migrated
86
90
  next if up? && migrated.include?(migration.version.to_i)
@@ -98,29 +102,29 @@ module Mongrations
98
102
 
99
103
  def migrations
100
104
  @migrations ||= begin
101
- files = Dir["#{@migrations_path}/[0-9]*_*.rb"]
102
-
105
+ files = Dir["#{@migrations_path}/[0-9]*_*.rb"]
106
+
103
107
  migrations = files.inject([]) do |klasses, file|
104
108
  version, name = file.scan(/([0-9]+)_([_a-z0-9]*).rb/).first
105
-
109
+
106
110
  raise IllegalMigrationNameError.new(file) unless version
107
111
  version = version.to_i
108
-
112
+
109
113
  if klasses.detect { |m| m.version == version }
110
- raise DuplicateMigrationVersionError.new(version)
114
+ raise DuplicateMigrationVersionError.new(version)
111
115
  end
112
116
 
113
117
  if klasses.detect { |m| m.name == name.camelize }
114
- raise DuplicateMigrationNameError.new(name.camelize)
118
+ raise DuplicateMigrationNameError.new(name.camelize)
115
119
  end
116
-
120
+
117
121
  migration = MigrationProxy.new
118
122
  migration.name = name.camelize
119
123
  migration.version = version
120
124
  migration.filename = file
121
125
  klasses << migration
122
126
  end
123
-
127
+
124
128
  migrations = migrations.sort_by(&:version)
125
129
  down? ? migrations.reverse : migrations
126
130
  end
@@ -157,13 +161,10 @@ module Mongrations
157
161
  end
158
162
 
159
163
  # Wrap the migration in a transaction only if supported by the adapter.
164
+ # (It's not.)
160
165
  def ddl_transaction(&block)
161
- if Base.connection.supports_ddl_transactions?
162
- Base.transaction { block.call }
163
- else
164
- block.call
165
- end
166
+ block.call
166
167
  end
167
168
  end
168
-
169
+
169
170
  end
@@ -0,0 +1,3 @@
1
+ module Mongrations
2
+ VERSION = '0.1.7'
3
+ end
@@ -0,0 +1,9 @@
1
+ {
2
+ "folders":
3
+ [
4
+ {
5
+ "follow_symlinks": true,
6
+ "path": "."
7
+ }
8
+ ]
9
+ }
@@ -1,9 +1,10 @@
1
1
  namespace :mongo do
2
+ @path = File.join(Rails.root, "db", "mongrations")
2
3
  desc "Migrate the database through scripts in db/mongrations. Target specific version with VERSION=x."
3
4
  task :mongrate => :environment do
4
- Mongrations::Migrator.migrate("db/mongrations/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
5
+ Mongrations::Migrator.migrate(@path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
5
6
  end
6
-
7
+
7
8
  namespace :mongrate do
8
9
  desc 'Rollbacks the database one mongration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
9
10
  task :redo => :environment do
@@ -20,20 +21,25 @@ namespace :mongo do
20
21
  task :up => :environment do
21
22
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
22
23
  raise "VERSION is required" unless version
23
- Mongrations::Migrator.run(:up, "db/mongrations/", version)
24
+ Mongrations::Migrator.run(:up, @path, version)
24
25
  end
25
26
 
26
27
  desc 'Runs the "down" for a given mongration VERSION.'
27
28
  task :down => :environment do
28
29
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
29
30
  raise "VERSION is required" unless version
30
- Mongrations::Migrator.run(:down, "db/mongrations/", version)
31
+ Mongrations::Migrator.run(:down, @path, version)
32
+ end
33
+
34
+ desc 'Show the current version of the mongrations'
35
+ task :version => :environment do
36
+ puts MongoMapper::Migrator.current_version
31
37
  end
32
38
  end
33
-
39
+
34
40
  desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
35
41
  task :mongo_rollback => :environment do
36
42
  step = ENV['STEP'] ? ENV['STEP'].to_i : 1
37
- Mongrations::Migrator.rollback('db/mongrations/', step)
43
+ Mongrations::Migrator.rollback(@path, step)
38
44
  end
39
45
  end
@@ -0,0 +1,6 @@
1
+ class Widget
2
+ include MongoMapper::Document
3
+
4
+ key :price, Integer, :default => 0
5
+ key :name, String
6
+ end
@@ -0,0 +1,15 @@
1
+ class FixGroupableKeys < Mongrations::Mongration
2
+ def self.up
3
+ Widget.find_each do |w|
4
+ w.price += 100
5
+ w.save
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ Widget.find_each do |w|
11
+ w.price -= 100
12
+ w.save
13
+ end
14
+ end
15
+ end
@@ -1,8 +1,61 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class MongrationsTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
4
+ context "A valid MongoMapper connection" do
5
+ setup do
6
+ @path = File.join("test", "mongrations")
7
+ @version = "20101125020919"
8
+ end
9
+
10
+ context "with a valid database" do
11
+ context "with a pending migration" do
12
+ should "migrate up to a given version" do
13
+ Widget.create(:name => "Sparkling Wizzles", :price => 100)
14
+ Widget.first.price.should == 100
15
+ Mongrations::Migrator.run(:up, @path, @version)
16
+ Widget.first.price.should == 200
17
+ end
18
+
19
+ should "run all pending migrations" do
20
+
21
+ Widget.create(:name => "Sparkling Wizzles", :price => 100)
22
+ Widget.first.price.should == 100
23
+ Mongrations::Migrator.migrate(@path, nil)
24
+ Widget.first.price.should == 200
25
+ end
26
+ end
27
+
28
+ should "run a migration:down" do
29
+ Widget.create(:name => "Sparkling Wizzles", :price => 100)
30
+ Widget.first.price.should == 100
31
+ Mongrations::Migrator.migrate(@path, nil)
32
+ Widget.first.price.should == 200
33
+ Mongrations::Migrator.run(:down, @path, @version)
34
+ Widget.first.price.should == 100
35
+ end
36
+
37
+ should "run a migration rollback" do
38
+ Widget.create(:name => "Sparkling Wizzles", :price => 100)
39
+ Widget.first.price.should == 100
40
+ Mongrations::Migrator.migrate(@path, nil)
41
+ Widget.first.price.should == 200
42
+ Mongrations::Migrator.rollback(@path, 1)
43
+ Widget.first.price.should == 100
44
+ end
45
+
46
+ should "not run a migration more than once" do
47
+ Widget.create(:name => "Sparkling Wizzles", :price => 100)
48
+ Widget.first.price.should == 100
49
+ Mongrations::Migrator.migrate(@path, nil)
50
+ Widget.first.price.should == 200
51
+ Mongrations::Migrator.migrate(@path, nil)
52
+ Widget.first.price.should == 200
53
+ end
54
+ end
55
+
56
+ teardown do
57
+ # Not gonna remove it. For now.
58
+ # MongoMapper.connection.drop_database "mongrations_test"
59
+ end
7
60
  end
8
- end
61
+ end
@@ -1,3 +1,26 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
1
4
  require 'rubygems'
2
5
  require 'active_support'
3
- require 'active_support/test_case'
6
+ require 'active_support/test_case'
7
+ require 'shoulda'
8
+ require 'matchy'
9
+ require 'mongo_mapper'
10
+ require 'models/widget'
11
+ require 'mongrations'
12
+
13
+ MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
14
+ MongoMapper.database = "mongrations-test"
15
+
16
+ class ActiveSupport::TestCase
17
+ def teardown
18
+ MongoMapper.connection.drop_database "mongrations-test"
19
+ end
20
+
21
+ def inherited(base)
22
+ base.define_method teardown do
23
+ super
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,74 +1,133 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leifcr-mongrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jonbell
8
- - leifcr
8
+ - Leif Ringstad
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-28 00:00:00.000000000 Z
12
+ date: 2014-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongo_mapper
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.12.0
20
+ version: 0.13.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.12.0
27
+ version: 0.13.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: activemodel
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 3.2.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 3.2.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: activesupport
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 3.2.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 3.2.0
28
56
  - !ruby/object:Gem::Dependency
29
57
  name: bundler
30
58
  requirement: !ruby/object:Gem::Requirement
31
59
  requirements:
32
- - - '>='
60
+ - - "~>"
33
61
  - !ruby/object:Gem::Version
34
- version: 1.3.5
62
+ version: '1.6'
35
63
  type: :development
36
64
  prerelease: false
37
65
  version_requirements: !ruby/object:Gem::Requirement
38
66
  requirements:
39
- - - '>='
67
+ - - "~>"
40
68
  - !ruby/object:Gem::Version
41
- version: 1.3.5
69
+ version: '1.6'
42
70
  - !ruby/object:Gem::Dependency
43
- name: jeweler
71
+ name: rake
44
72
  requirement: !ruby/object:Gem::Requirement
45
73
  requirements:
46
- - - ~>
74
+ - - ">="
47
75
  - !ruby/object:Gem::Version
48
- version: 1.8.8
76
+ version: '0'
49
77
  type: :development
50
78
  prerelease: false
51
79
  version_requirements: !ruby/object:Gem::Requirement
52
80
  requirements:
53
- - - ~>
81
+ - - ">="
54
82
  - !ruby/object:Gem::Version
55
- version: 1.8.8
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: shoulda
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: mcmire-matchy
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: 0.5.2
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 0.5.2
56
112
  description: |-
57
113
  Mongrations aims to be similar to ActiveRecord's data migrations, except
58
114
  instead of worrying about schema changes, offering a way to change data when
59
115
  necessary
60
- email: leifcr@gmail.com
116
+ email:
117
+ - leifcr@gmail.com
61
118
  executables: []
62
119
  extensions: []
63
- extra_rdoc_files:
64
- - README.markdown
120
+ extra_rdoc_files: []
65
121
  files:
122
+ - ".gitignore"
123
+ - ".ruby-gemset"
124
+ - ".ruby-version"
125
+ - ".travis.yml"
66
126
  - Gemfile
67
127
  - Gemfile.lock
68
128
  - MIT-LICENSE
69
129
  - README.markdown
70
130
  - Rakefile
71
- - VERSION
72
131
  - generators/mongrations/templates/mongration.rb
73
132
  - generators/mongrations_generator.rb
74
133
  - init.rb
@@ -81,12 +140,17 @@ files:
81
140
  - lib/mongrations/mongration.rb
82
141
  - lib/mongrations/railtie.rb
83
142
  - lib/mongrations/schema_migration.rb
143
+ - lib/mongrations/version.rb
144
+ - mongrations.sublime-project
84
145
  - tasks/mongo.rake
146
+ - test/models/widget.rb
147
+ - test/mongrations/20101125020919_fix_groupable_keys.rb
85
148
  - test/mongrations_test.rb
86
149
  - test/test_helper.rb
87
150
  - uninstall.rb
88
151
  homepage: http://github.com/leifcr/mongrations
89
- licenses: []
152
+ licenses:
153
+ - MIT
90
154
  metadata: {}
91
155
  post_install_message:
92
156
  rdoc_options: []
@@ -94,18 +158,22 @@ require_paths:
94
158
  - lib
95
159
  required_ruby_version: !ruby/object:Gem::Requirement
96
160
  requirements:
97
- - - '>='
161
+ - - ">="
98
162
  - !ruby/object:Gem::Version
99
163
  version: '0'
100
164
  required_rubygems_version: !ruby/object:Gem::Requirement
101
165
  requirements:
102
- - - '>='
166
+ - - ">="
103
167
  - !ruby/object:Gem::Version
104
168
  version: '0'
105
169
  requirements: []
106
170
  rubyforge_project:
107
- rubygems_version: 2.1.4
171
+ rubygems_version: 2.2.2
108
172
  signing_key:
109
173
  specification_version: 4
110
174
  summary: Data migrating for MongoMapper
111
- test_files: []
175
+ test_files:
176
+ - test/models/widget.rb
177
+ - test/mongrations/20101125020919_fix_groupable_keys.rb
178
+ - test/mongrations_test.rb
179
+ - test/test_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.6