Sha256: a063c1aef6f53269e42de606ef6f6d654b8962ddea8a0ab7d6471a06aed4b7d1
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
[![Build Status](https://travis-ci.org/Shinya131/seed_sort_toolkit.svg?branch=master)](https://travis-ci.org/Shinya131/seed_sort_toolkit) [![Coverage Status](https://coveralls.io/repos/Shinya131/seed_sort_toolkit/badge.png)](https://coveralls.io/r/Shinya131/seed_sort_toolkit) [![Code Climate](https://codeclimate.com/github/Shinya131/seed_sort_toolkit/badges/gpa.svg)](https://codeclimate.com/github/Shinya131/seed_sort_toolkit) # SeedSortToolkit `SeedSortToolkit` is rails seed file sort tool. This tool can without changing the content & format, just replace only order. note: If you use `YAML.load` and sort and `YAML.dump`. The format of your seed, diff comes out a little. For example: - Quotes for string will be disappears. - nil column will be blank. This tool does not cause the above problem. ## Installation Add this line to your application's Gemfile: ```ruby gem 'seed_sort_toolkit' ``` And then execute: $ bundle Or install it yourself as: $ gem install seed_sort_toolkit ## Usage ```yaml # numbers.yml data3: id: 3 name: "three" data1: id: 1 name: "one" data2: id: 2 name: 'two' ``` ```ruby require 'seed_sort_toolkit' seed = File.read('numbers.yml') sortable_seed = SeedSortToolkit::SortableSeedYaml.new(seed) sortable_seed.sort_by{|record| record.attributes["id"] } # => # data1: # id: 1 # name: "one" # data2: # id: 2 # name: 'two' # data3: # id: 3 # name: "three" # You can use space spice operand sortable_seed.sort{|a, b| a.attributes["id"] <=> b.attributes["id"]} # => # data1: # id: 1 # name: "one" # data2: # id: 2 # name: 'two' # data3: # id: 3 # name: "three" ```
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
seed_sort_toolkit-0.0.1 | README.md |