db_reference 0.0.8 → 0.1.0
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 +17 -0
- data/Gemfile +4 -0
- data/{MIT-LICENSE → LICENSE} +4 -2
- data/README.md +52 -0
- data/Rakefile +2 -85
- data/db_reference.gemspec +20 -0
- data/lib/db_reference.rb +1 -0
- data/lib/db_reference/version.rb +3 -0
- metadata +72 -67
- data/README +0 -38
- data/init.rb +0 -1
- data/install.rb +0 -1
- data/uninstall.rb +0 -1
data/.gitignore
ADDED
data/Gemfile
ADDED
data/{MIT-LICENSE → LICENSE}
RENAMED
@@ -1,4 +1,6 @@
|
|
1
|
-
Copyright (c) 2010
|
1
|
+
Copyright (c) 2010 Able Technology
|
2
|
+
|
3
|
+
MIT License
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
6
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# DB Reference
|
2
|
+
|
3
|
+
Used for creating a predefined set of model instances, similar to db:seed, but will not repopulate if entries already exist.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'db_reference'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install db_reference
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Place references in 'db/reference/'
|
22
|
+
References will be loaded in ascending order, so if an order is desired, prepend 000, 001, 002... etc to the filename.
|
23
|
+
|
24
|
+
Run with:
|
25
|
+
rake reference:load
|
26
|
+
|
27
|
+
## Example
|
28
|
+
|
29
|
+
The below example ensures that there are 6 locations existing in the database after running the 'rake reference:load'
|
30
|
+
|
31
|
+
|
32
|
+
### db/schema.rb
|
33
|
+
create_table 'locations', :force => true do |t|
|
34
|
+
t.string 'name', :null => false
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
### db/reference/000_locations.rb
|
39
|
+
Location.update_or_create :id => 1, :name => 'Wellington City'
|
40
|
+
Location.update_or_create :id => 2, :name => 'Lower Hutt'
|
41
|
+
Location.update_or_create :id => 3, :name => 'Kapiti Coast'
|
42
|
+
Location.update_or_create :id => 4, :name => 'Porirua'
|
43
|
+
Location.update_or_create :id => 5, :name => 'Upper Hutt'
|
44
|
+
Location.update_or_create :id => 6, :name => 'Wairarapa'
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,85 +1,2 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
require 'rake/gempackagetask'
|
5
|
-
|
6
|
-
desc 'Default: run unit tests.'
|
7
|
-
task :default => :test
|
8
|
-
|
9
|
-
desc 'Test the reference plugin.'
|
10
|
-
Rake::TestTask.new(:test) do |t|
|
11
|
-
t.libs << 'lib'
|
12
|
-
t.libs << 'test'
|
13
|
-
t.pattern = 'test/**/*_test.rb'
|
14
|
-
t.verbose = true
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'Generate documentation for the reference plugin.'
|
18
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
19
|
-
rdoc.rdoc_dir = 'rdoc'
|
20
|
-
rdoc.title = 'Reference'
|
21
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
22
|
-
rdoc.rdoc_files.include('README')
|
23
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
PKG_FILES = FileList[
|
28
|
-
'[a-zA-Z]*',
|
29
|
-
'generators/**/*',
|
30
|
-
'lib/**/*',
|
31
|
-
'tasks/**/*',
|
32
|
-
'rails/**/*',
|
33
|
-
'test/**/*'
|
34
|
-
]
|
35
|
-
|
36
|
-
spec = Gem::Specification.new do |s|
|
37
|
-
s.name = "db_reference"
|
38
|
-
s.version = "0.0.8"
|
39
|
-
s.author = "Cam Fowler"
|
40
|
-
s.email = "cameron.fowler@abletech.co.nz"
|
41
|
-
s.homepage = "http://www.abletech.co.nz/"
|
42
|
-
s.platform = Gem::Platform::RUBY
|
43
|
-
s.summary = "Loads files from db/reference/"
|
44
|
-
s.description = """
|
45
|
-
|
46
|
-
Used for creating a predefined set of models, similar to db:seed, but will not repopulate if entries already exist.
|
47
|
-
|
48
|
-
Place references in 'db/reference/'
|
49
|
-
References will be loaded in ascending order, so if an order is desired, prepend 000, 001, 002... etc to the filename.
|
50
|
-
|
51
|
-
Run with:
|
52
|
-
rake reference:load
|
53
|
-
|
54
|
-
Example
|
55
|
-
=======
|
56
|
-
|
57
|
-
The below example ensures that there are 6 locations existing in the database after running the 'rake reference:load'
|
58
|
-
|
59
|
-
|
60
|
-
# db/schema.rb
|
61
|
-
create_table 'locations', :force => true do |t|
|
62
|
-
t.string 'name', :null => false
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
# db/reference/000_locations.rb
|
67
|
-
Location.update_or_create :id => 1, :name => 'Wellington City'
|
68
|
-
Location.update_or_create :id => 2, :name => 'Lower Hutt'
|
69
|
-
Location.update_or_create :id => 3, :name => 'Kapiti Coast'
|
70
|
-
Location.update_or_create :id => 4, :name => 'Porirua'
|
71
|
-
Location.update_or_create :id => 5, :name => 'Upper Hutt'
|
72
|
-
Location.update_or_create :id => 6, :name => 'Wairarapa'
|
73
|
-
|
74
|
-
"""
|
75
|
-
s.files = PKG_FILES.to_a
|
76
|
-
s.require_path = "lib"
|
77
|
-
s.has_rdoc = false
|
78
|
-
s.extra_rdoc_files = ["README"]
|
79
|
-
end
|
80
|
-
|
81
|
-
desc 'Turn this plugin into a gem.'
|
82
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
83
|
-
pkg.gem_spec = spec
|
84
|
-
end
|
85
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/db_reference/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Cameron Fowler"]
|
6
|
+
gem.email = ["cameron.fowler@abletech.co.nz"]
|
7
|
+
gem.description = %q{Used to create a predefined set of model instances}
|
8
|
+
gem.summary = %q{Loads files from db/reference/*.rb}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "db_reference"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = DbReference::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'rake'
|
19
|
+
gem.add_runtime_dependency 'rails', '~> 3.0'
|
20
|
+
end
|
data/lib/db_reference.rb
CHANGED
metadata
CHANGED
@@ -1,93 +1,98 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_reference
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 8
|
10
|
-
version: 0.0.8
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
7
|
+
authors:
|
8
|
+
- Cameron Fowler
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
12
|
+
date: 2012-05-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.0'
|
46
|
+
description: Used to create a predefined set of model instances
|
47
|
+
email:
|
48
|
+
- cameron.fowler@abletech.co.nz
|
40
49
|
executables: []
|
41
|
-
|
42
50
|
extensions: []
|
43
|
-
|
44
|
-
|
45
|
-
-
|
46
|
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
- MIT-LICENSE
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
50
57
|
- Rakefile
|
51
|
-
-
|
52
|
-
-
|
58
|
+
- db_reference.gemspec
|
59
|
+
- lib/db_reference.rb
|
53
60
|
- lib/db_reference/active_record_ext.rb
|
54
61
|
- lib/db_reference/railtie.rb
|
55
|
-
- lib/db_reference.rb
|
62
|
+
- lib/db_reference/version.rb
|
56
63
|
- lib/tasks/db_reference_tasks.rake
|
57
64
|
- test/reference_test.rb
|
58
65
|
- test/test_helper.rb
|
59
|
-
homepage:
|
66
|
+
homepage: ''
|
60
67
|
licenses: []
|
61
|
-
|
62
68
|
post_install_message:
|
63
69
|
rdoc_options: []
|
64
|
-
|
65
|
-
require_paths:
|
70
|
+
require_paths:
|
66
71
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
73
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
segments:
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
segments:
|
74
79
|
- 0
|
75
|
-
|
76
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
hash: -2635922066652001072
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
82
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
segments:
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
segments:
|
83
88
|
- 0
|
84
|
-
|
89
|
+
hash: -2635922066652001072
|
85
90
|
requirements: []
|
86
|
-
|
87
91
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
92
|
+
rubygems_version: 1.8.24
|
89
93
|
signing_key:
|
90
94
|
specification_version: 3
|
91
|
-
summary: Loads files from db/reference
|
92
|
-
test_files:
|
93
|
-
|
95
|
+
summary: Loads files from db/reference/*.rb
|
96
|
+
test_files:
|
97
|
+
- test/reference_test.rb
|
98
|
+
- test/test_helper.rb
|
data/README
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
Reference
|
2
|
-
=========
|
3
|
-
|
4
|
-
Used for creating a predefined set of models, similar to db:seed, but will not repopulate if entries already exist.
|
5
|
-
|
6
|
-
Place references in 'db/reference/'
|
7
|
-
References will be loaded in ascending order, so if an order is desired, prepend 000, 001, 002... etc to the filename.
|
8
|
-
|
9
|
-
Run with:
|
10
|
-
rake reference:load
|
11
|
-
|
12
|
-
Example
|
13
|
-
=======
|
14
|
-
|
15
|
-
The below example ensures that there are 6 locations existing in the database after running the 'rake reference:load'
|
16
|
-
|
17
|
-
|
18
|
-
# db/schema.rb
|
19
|
-
create_table "locations", :force => true do |t|
|
20
|
-
t.string "name", :null => false
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
# db/reference/000_locations.rb
|
25
|
-
Location.update_or_create :id => 1, :name => 'Wellington City'
|
26
|
-
Location.update_or_create :id => 2, :name => 'Lower Hutt'
|
27
|
-
Location.update_or_create :id => 3, :name => 'Kapiti Coast'
|
28
|
-
Location.update_or_create :id => 4, :name => 'Porirua'
|
29
|
-
Location.update_or_create :id => 5, :name => 'Upper Hutt'
|
30
|
-
Location.update_or_create :id => 6, :name => 'Wairarapa'
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
Copyright (c) 2010 Able Technology, released under the MIT license
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'reference'
|
data/install.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Install hook code here
|
data/uninstall.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Uninstall hook code here
|