seed_sort_toolkit 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/lib/seed_sort_toolkit/sortable_seed_yaml.rb +23 -21
- data/lib/seed_sort_toolkit/version.rb +1 -1
- data/test/test_sortable_seed_yaml.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff0504ff51ad5de97ecefa7ab17e8f7badec6fff
|
4
|
+
data.tar.gz: af8cedb3db6fa53bebd56a473180d5cefc9db9c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 270febf06becf8d21fcf28763bd9b27736bc6e8f9d94bb202c55780802746376c710ecfe64c5bb70f9c874fe9afab74f9428cbbb84071d6152cf0cbd07366c07
|
7
|
+
data.tar.gz: ee0d1e86141207d94dbd6b174162c7e9fe7388061a08d06e19df7d77fe50d11b025872aef7008293f09a7bacc34686d1c1ffffa150d27fcc384dc7c919588a61
|
data/README.md
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
+
[](http://badge.fury.io/rb/seed_sort_toolkit)
|
1
2
|
[](https://travis-ci.org/Shinya131/seed_sort_toolkit)
|
2
3
|
[](https://coveralls.io/r/Shinya131/seed_sort_toolkit)
|
3
4
|
[](https://codeclimate.com/github/Shinya131/seed_sort_toolkit)
|
5
|
+
[](https://gemnasium.com/Shinya131/seed_sort_toolkit)
|
4
6
|
|
5
7
|
# SeedSortToolkit
|
6
8
|
|
7
9
|
`SeedSortToolkit` is rails seed file sort tool.
|
8
10
|
This tool can without changing the content & format, just replace only order.
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
### note:
|
13
|
+
If you use `YAML.load` and sort and `YAML.dump`.
|
14
|
+
The format of your seed, diff comes out a little.
|
15
|
+
|
16
|
+
For example:
|
17
|
+
- Quotes(`""`,`''`) for string will be disappears.
|
18
|
+
- `nil` column will be blank.
|
16
19
|
|
17
20
|
This tool does not cause the above problem.
|
18
21
|
|
@@ -1,24 +1,26 @@
|
|
1
1
|
require 'accessible_seed_yaml'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module SeedSortToolkit
|
4
|
+
class SortableSeedYaml
|
5
|
+
def initialize(seed)
|
6
|
+
seed = AccessibleSeedYaml::Table.new(seed)
|
7
|
+
@records = seed.records
|
8
|
+
end
|
9
|
+
|
10
|
+
def sort_by(&block)
|
11
|
+
@records.sort_by!(&block)
|
12
|
+
fetch_seed
|
13
|
+
end
|
14
|
+
|
15
|
+
def sort(&block)
|
16
|
+
@records.sort!(&block)
|
17
|
+
fetch_seed
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def fetch_seed
|
23
|
+
@records.map(&:original_seed).join
|
24
|
+
end
|
7
25
|
end
|
8
|
-
|
9
|
-
def sort_by(&block)
|
10
|
-
@records.sort_by!(&block)
|
11
|
-
fetch_seed
|
12
|
-
end
|
13
|
-
|
14
|
-
def sort(&block)
|
15
|
-
@records.sort!(&block)
|
16
|
-
fetch_seed
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def fetch_seed
|
22
|
-
@records.map(&:original_seed).join
|
23
|
-
end
|
24
|
-
end
|
26
|
+
end
|
@@ -4,7 +4,7 @@ MiniTest::Unit.autorun
|
|
4
4
|
|
5
5
|
class TestSortableSeedYaml < MiniTest::Unit::TestCase
|
6
6
|
def setup
|
7
|
-
@sortable_seed = SortableSeedYaml.new(TestData::Seed::RandomOrder)
|
7
|
+
@sortable_seed = SeedSortToolkit::SortableSeedYaml.new(TestData::Seed::RandomOrder)
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_sort_by
|