dumped_railers 0.1.4 → 0.1.5

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
  SHA256:
3
- metadata.gz: e4a93dbe684079409978553480483dbd5d2727f1f694470a8b62e89e0715fbe8
4
- data.tar.gz: 266714eaca3eb9311effa69a5a6a1d4d784c758f04ea50574d24a44fcbe6a210
3
+ metadata.gz: 80d7da9c36ba41d750a56d9ee58ed12bfadb816f0f4dde5e915590811344541d
4
+ data.tar.gz: 28376d6a5b35a1e63be22573bb0180dc0d4d765c6064204b6eca49c70bac5748
5
5
  SHA512:
6
- metadata.gz: f858057d3a62e389a01580a42fc926491a6c55e1f351a27a1d631fffba06727ccfecf6109848e1d547897218924398f1dc1176d9733205d8164cb7332987dae3
7
- data.tar.gz: 4ee34e3d764eb00f8b244fdacce154f94cae38a6839c71bd7b640907fea235c84d8eaf83b1519fc6872fe305383d031253a55b5f91b79d39b5c96facb821c4f8
6
+ metadata.gz: c26bb04f7cba72d1f397294133c4bd32ebad630fb62d37ee3649fee40341380040ba271ebdde8410ffd263175eed4e6432a623eb6840016fe7638c21825f1d58
7
+ data.tar.gz: 933f85c32bd8390ff4d7f9827cc8d58742dc5c7ebf629b744fd35db010526ef2d389875c85170f8d939784a52a76d98579e8e8cd2721fa3b5a571c7910bbac8e
@@ -26,3 +26,7 @@
26
26
  ### Changed
27
27
  - Update documents not to eagerload DumpedRailers to prevent accidental data breakage / leakage.
28
28
  To activate, it is preferable to require explicitly where necessary.
29
+
30
+ ## [0.1.5]
31
+ ### Added
32
+ - Supported in-memopry fixtures. Now users can dump into and import from in-memory fixture object without saving files.
data/README.md CHANGED
@@ -67,6 +67,17 @@ DumpedRailers.import!('tmp/fixtures/users.yml', 'tmp/fixtures/items.yml')
67
67
 
68
68
  NOTE: you at least have to provide all the dependent records, so that DumpedRailers can resolve dependencies among the fixtures provided.
69
69
 
70
+ ### Using In-Memory Fixtures
71
+
72
+ DumpedRailers.dump! also returns an object, which can be imported directly as in-memory fixture.
73
+
74
+ ```ruby
75
+ fixtures = DumpedRailers.dump!(User, Item, Tag)
76
+ DumpedRailers.import!(fixtures)
77
+ ```
78
+
79
+ DumpedRailers does not save the fixtures when `base_dir` keyword argument is not specified.
80
+
70
81
  ### Ignored Columns
71
82
 
72
83
  * By default, DumpedRailers ignore three columns - `id`, `created_at`, `updated_at`. You can always update/change this settings as follows.
@@ -170,7 +181,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
170
181
 
171
182
  ## Contributing
172
183
 
173
- Bug reports and pull requests are welcome on GitHub at https://github.com/[fursich]/dumped_railers.
184
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fursich/dumped_railers.
174
185
 
175
186
 
176
187
  ## License
@@ -8,12 +8,14 @@ require 'dumped_railers/import'
8
8
  module DumpedRailers
9
9
  class << self
10
10
 
11
- def dump!(*models, base_dir: './', preprocessors: nil)
11
+ def dump!(*models, base_dir: nil, preprocessors: nil)
12
12
  preprocessors = [Preprocessor::StripIgnorables.new, *preprocessors].compact.uniq
13
13
 
14
14
  fixture_handler = Dump.new(*models, preprocessors: preprocessors)
15
- fixture_handler.build_fixtures!
15
+ fixtures = fixture_handler.build_fixtures!
16
16
  fixture_handler.persist_all!(base_dir)
17
+
18
+ fixtures
17
19
  end
18
20
 
19
21
  def import!(*paths)
@@ -16,8 +16,10 @@ module DumpedRailers
16
16
  end
17
17
 
18
18
  def persist_all!(base_dir)
19
- FileUtils.mkdir_p(base_dir)
20
- FileHelper.write(*@fixtures, base_dir: base_dir)
19
+ if base_dir
20
+ FileUtils.mkdir_p(base_dir)
21
+ FileHelper.write(*@fixtures, base_dir: base_dir)
22
+ end
21
23
  end
22
24
  end
23
25
  end
@@ -7,7 +7,12 @@ module DumpedRailers
7
7
  attr_reader :fixture_set
8
8
 
9
9
  def initialize(*paths)
10
- @raw_fixtures = FileHelper.read_fixtures(*paths)
10
+ if (paths.first.is_a? Hash)
11
+ @raw_fixtures = paths.first.values
12
+ else
13
+ @raw_fixtures = FileHelper.read_fixtures(*paths)
14
+ end
15
+
11
16
  @fixture_set = RecordBuilder::FixtureSet.new(@raw_fixtures)
12
17
  end
13
18
 
@@ -1,3 +1,3 @@
1
1
  module DumpedRailers
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumped_railers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koji Onishi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-11 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler