simple_fixture 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +2 -2
- data/bin/simple-fixture +25 -0
- data/lib/simple_fixture/load.rb +3 -0
- data/lib/simple_fixture/version.rb +1 -1
- data/lib/simple_fixture.rb +4 -4
- data/simple_fixture.gemspec +2 -2
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 46051296e22db7db77e82e16ee69ec859d2046dc4a3ed28b0fca3417b589eb6e
|
4
|
+
data.tar.gz: ad62526409460ea32e13b4883c09549d24f63496e86f908e1414c24115b84a5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c20eb6aeea7e592826a6114932492a151dab8c6cca17f7755b8d48251686c581a004f285fb12bbeb5aeaeb0810996f289faae6ff05181ea01b4191c625bc36e3
|
7
|
+
data.tar.gz: 8c0b7fa3e9fb6b0bf6ad848ac5be0b0e7fbb7bc5330f6a247b2c7d9ba1b7b71673239ac3947b28c835d1029f61eb71017338c94753ba6f55d77db3e89a631700
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
You should have directory `test/simple_fixture` in your project, with structure as below.
|
23
|
+
You should have directory `test/simple_fixture` in your project, with structure as below. You can run `simple-fixture` to generate it. Also check file content examples in this gem's test directory.
|
24
24
|
|
25
25
|
```
|
26
26
|
test
|
@@ -35,7 +35,7 @@ test
|
|
35
35
|
└── test_helper.rb
|
36
36
|
```
|
37
37
|
|
38
|
-
Then call `SimpleFixture.new`, fixtures will be loaded into a new sqlite file in directory `tmp/` of your project, and you can use ActiveRecord to find them, such as `Order.where(...)`.
|
38
|
+
Then call `SimpleFixture.new`, or just `require 'simple_fixture/load'`, then fixtures will be loaded into a new sqlite file in directory `tmp/` of your project, and you can use ActiveRecord to find them, such as `Order.where(...)`.
|
39
39
|
|
40
40
|
## Development
|
41
41
|
|
data/bin/simple-fixture
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'simple_fixture'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
if Dir.exists? SimpleFixture::CONFIG_DIR
|
7
|
+
STDERR.puts "#{SimpleFixture::CONFIG_DIR} already exists !"
|
8
|
+
return
|
9
|
+
end
|
10
|
+
|
11
|
+
FileUtils.mkdir_p SimpleFixture::FIXTURES_DIR
|
12
|
+
|
13
|
+
File.write SimpleFixture::MODELS_FILE, <<-EOF
|
14
|
+
class Thing < ActiveRecord::Base
|
15
|
+
end
|
16
|
+
EOF
|
17
|
+
|
18
|
+
File.write SimpleFixture::MIGRATION_FILE, <<-EOF
|
19
|
+
SimpleFixture.migrate do
|
20
|
+
create_table :things do |t|
|
21
|
+
end
|
22
|
+
end
|
23
|
+
EOF
|
24
|
+
|
25
|
+
puts 'simple_fixture structure done !'
|
data/lib/simple_fixture.rb
CHANGED
@@ -8,6 +8,8 @@ class SimpleFixture
|
|
8
8
|
DB_NAME = 'simple_fixture'
|
9
9
|
CONFIG_DIR = File.join('test', 'simple_fixture')
|
10
10
|
FIXTURES_DIR = File.join(CONFIG_DIR, 'fixtures')
|
11
|
+
MIGRATION_FILE = File.join(CONFIG_DIR, 'migration.rb')
|
12
|
+
MODELS_FILE = File.join(CONFIG_DIR, 'models.rb')
|
11
13
|
|
12
14
|
class << self
|
13
15
|
def migrate(&block)
|
@@ -23,12 +25,10 @@ class SimpleFixture
|
|
23
25
|
build_db_file
|
24
26
|
establish_connection
|
25
27
|
|
26
|
-
load File.join(CONFIG_DIR, 'migration.rb')
|
27
|
-
load File.join(CONFIG_DIR, 'models.rb')
|
28
28
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
29
|
+
load MIGRATION_FILE
|
30
|
+
load MODELS_FILE
|
29
31
|
ActiveRecord::FixtureSet.create_fixtures(FIXTURES_DIR, ymls)
|
30
|
-
|
31
|
-
true
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
data/simple_fixture.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
19
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
20
|
end
|
21
|
-
spec.bindir = "
|
22
|
-
spec.executables =
|
21
|
+
spec.bindir = "bin"
|
22
|
+
spec.executables = ["simple-fixture"]
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 2.0"
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_fixture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -97,7 +97,8 @@ dependencies:
|
|
97
97
|
description:
|
98
98
|
email:
|
99
99
|
- block24block@gmail.com
|
100
|
-
executables:
|
100
|
+
executables:
|
101
|
+
- simple-fixture
|
101
102
|
extensions: []
|
102
103
|
extra_rdoc_files: []
|
103
104
|
files:
|
@@ -110,7 +111,9 @@ files:
|
|
110
111
|
- Rakefile
|
111
112
|
- bin/console
|
112
113
|
- bin/setup
|
114
|
+
- bin/simple-fixture
|
113
115
|
- lib/simple_fixture.rb
|
116
|
+
- lib/simple_fixture/load.rb
|
114
117
|
- lib/simple_fixture/version.rb
|
115
118
|
- simple_fixture.gemspec
|
116
119
|
homepage: https://github.com/turnon/simple_fixture
|
@@ -132,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
135
|
- !ruby/object:Gem::Version
|
133
136
|
version: '0'
|
134
137
|
requirements: []
|
135
|
-
|
136
|
-
rubygems_version: 2.5.2.3
|
138
|
+
rubygems_version: 3.0.3
|
137
139
|
signing_key:
|
138
140
|
specification_version: 4
|
139
141
|
summary: help create fixtures off rails project
|