mongoid_seeder 0.0.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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ tags
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mongoid_seeder.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mongoid_seeder (0.0.1)
5
+ mongoid (~> 3.1)
6
+ mongoid-shell (= 0.2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (3.2.14)
12
+ activesupport (= 3.2.14)
13
+ builder (~> 3.0.0)
14
+ activesupport (3.2.14)
15
+ i18n (~> 0.6, >= 0.6.4)
16
+ multi_json (~> 1.0)
17
+ builder (3.0.4)
18
+ i18n (0.6.5)
19
+ mongoid (3.1.5)
20
+ activemodel (~> 3.2)
21
+ moped (~> 1.4)
22
+ origin (~> 1.0)
23
+ tzinfo (~> 0.3.29)
24
+ mongoid-shell (0.2.0)
25
+ i18n
26
+ mongoid
27
+ moped (1.5.1)
28
+ multi_json (1.8.0)
29
+ origin (1.1.0)
30
+ rake (10.1.0)
31
+ tzinfo (0.3.37)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 1.3)
38
+ mongoid_seeder!
39
+ rake (~> 10.1)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Magnet Tester
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # MongoidSeeder
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'mongoid_seeder'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mongoid_seeder
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ module MongoidSeeder
2
+ require 'mixlib/config'
3
+
4
+ class Config
5
+ extend Mixlib::Config
6
+
7
+ before_suite -> { true } # no-op
8
+ before_each -> { true } # no-op
9
+ after_each -> { true } # no-op
10
+ after_suite -> { true } # no-op
11
+ condition_to_drop_collection lambda { |collection| false } # drop nothing
12
+ config_file File.join(Dir.pwd, 'config', 'mongoid_seeder.rb') # app_root/config/mongoid_seeder.rb
13
+ end
14
+
15
+ require Config.config_file if File.exists?(Config.config_file)
16
+ end
@@ -0,0 +1,3 @@
1
+ module MongoidSeeder
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,52 @@
1
+ require 'mongoid-shell'
2
+ require 'mongoid'
3
+ require 'fileutils'
4
+
5
+ require_relative 'mongoid_seeder/config'
6
+
7
+ module MongoidSeeder
8
+ def self.before_suite
9
+ Config.before_suite.call
10
+ seed
11
+ end
12
+
13
+ def self.before_each
14
+ Config.before_each.call
15
+ end
16
+
17
+ def self.after_each
18
+ Config.after_each.call
19
+ after_tests
20
+ end
21
+
22
+ def self.after_suite
23
+ Config.after_suite.call
24
+ drop
25
+ end
26
+
27
+ def self.seed
28
+ options = {
29
+ db: Mongoid.session(:default).options[:database],
30
+ restore: db_path
31
+ }
32
+ mongorestore = Mongoid::Shell::Commands::Mongorestore.new(options)
33
+ system mongorestore.to_s
34
+ end
35
+
36
+ def self.db_path
37
+ File.expand_path("db/seed_data", Dir.pwd)
38
+ end
39
+
40
+ def self.dump
41
+ mongodump = Mongoid::Shell::Commands::Mongodump.new( out: db_path)
42
+ system mongodump.to_s
43
+ end
44
+
45
+ def self.drop
46
+ Mongoid.session(:default).drop
47
+ end
48
+
49
+ def self.after_tests
50
+ Mongoid.session(:default).collections.select{|a| Config.condition_to_drop_collection.call(a) }.each(&:drop)
51
+ end
52
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mongoid_seeder/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mongoid_seeder"
8
+ spec.version = MongoidSeeder::VERSION
9
+ spec.authors = ["Matt Simpson", "Cameron Mauch", "Asynchrony"]
10
+ spec.email = ["matt.simpson3@gmail.com", "cam@douglas-cameron.net"]
11
+ spec.description = "Helps with seeding data with mongoid"
12
+ spec.summary = "Helps with seeding data with mongoid"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake", "~> 10.1"
21
+
22
+ spec.add_dependency 'mongoid', "~> 3.1"
23
+ spec.add_dependency 'mongoid-shell', "0.2.0"
24
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid_seeder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matt Simpson
9
+ - Cameron Mauch
10
+ - Asynchrony
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2013-09-19 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: '1.3'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: '1.3'
32
+ - !ruby/object:Gem::Dependency
33
+ name: rake
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '10.1'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.1'
48
+ - !ruby/object:Gem::Dependency
49
+ name: mongoid
50
+ requirement: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '3.1'
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '3.1'
64
+ - !ruby/object:Gem::Dependency
65
+ name: mongoid-shell
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - '='
70
+ - !ruby/object:Gem::Version
71
+ version: 0.2.0
72
+ type: :runtime
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - '='
78
+ - !ruby/object:Gem::Version
79
+ version: 0.2.0
80
+ description: Helps with seeding data with mongoid
81
+ email:
82
+ - matt.simpson3@gmail.com
83
+ - cam@douglas-cameron.net
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - .gitignore
89
+ - Gemfile
90
+ - Gemfile.lock
91
+ - LICENSE.txt
92
+ - README.md
93
+ - Rakefile
94
+ - lib/mongoid_seeder.rb
95
+ - lib/mongoid_seeder/config.rb
96
+ - lib/mongoid_seeder/version.rb
97
+ - mongoid_seeder.gemspec
98
+ homepage: ''
99
+ licenses:
100
+ - MIT
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
112
+ - 0
113
+ hash: -1532292957854760599
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ segments:
121
+ - 0
122
+ hash: -1532292957854760599
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 1.8.25
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: Helps with seeding data with mongoid
129
+ test_files: []