ztree 0.0.5 → 0.0.7

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
  SHA1:
3
- metadata.gz: 2ecc8b84bf58c253b43ae10f9f347a29afbf142d
4
- data.tar.gz: 4c5d21f20e35a9cbf0fb7946cec70f0e207b875e
3
+ metadata.gz: 3d94fdf5dd3c4202a47c8308f9ce276c0dec7566
4
+ data.tar.gz: 9f9e2fb6bbb2b3dc3302535a3ab9299ecc03e8a2
5
5
  SHA512:
6
- metadata.gz: 4ba23458c1449c1c9c12d799c10eb0426dae17df06007ece91539b4b1df8254f6cfa5bebcf0b7d0afdd049eae0b5bd2399daab13c101f2d3c60abadcd1439be0
7
- data.tar.gz: 2a12ebad29a8c3e10239861de7ac4d9104577533e69aa1b7f64e991745324a57eb074b8dbd92ded71cf9813115db37dfd97fadcf32543dabc3c2d8dd80f0c655
6
+ metadata.gz: 17a312d3032859f56a2062174d5f103e3e7c4e59e8c09d2244a1f38dc7bc73cc7b623d8da584325b3dd78f4d8d793756967b6e5c39e163b2df92e56bccba367b
7
+ data.tar.gz: c9e3bcf5e5cd0415c6fcf0a58c3db7d710e375d22a373c90b30c34aa4347e06b073fd49dd5c51eea5f4fb135a000d41b69e61983db10b161c8ff0afcb865bed0
data/lib/exts/array.rb CHANGED
@@ -28,6 +28,6 @@ class Array
28
28
  end
29
29
 
30
30
  def to_sorted_nodes
31
- self.group_by(&:parent_id).each {|k,v| v.sort_by! &:order_num}.to_a.flatten.select{|c| !c.is_a?Integer}.compact
31
+ self.group_by(&:parent_id).each {|k,v| v.sort_by! {|a| a.send(a.class.order_column) }}.to_a.flatten.select{|c| !c.is_a?Integer}.compact
32
32
  end
33
33
  end
@@ -21,6 +21,10 @@ module SortTree
21
21
  def order_column
22
22
  :order_num
23
23
  end
24
+
25
+ def to_sorted_nodes(c = '')
26
+ where(c).group_by(&:parent_id).each {|k,v| v.sort_by! &(order_column.to_sym)}.to_a.flatten.select{|c| !c.is_a?Integer}.compact
27
+ end
24
28
  end
25
29
 
26
30
  def sorted_children
data/ztree.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ztree'
5
- s.version = '0.0.5'
5
+ s.version = '0.0.7'
6
6
  s.authors = ['Zhimeng Sun']
7
7
  s.email = ['zhimengSun@gmail.com']
8
8
  s.homepage = 'https://github.com/zhimengSun/ztree'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ztree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhimeng Sun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails