nested_array 2.4.0 → 3.0.1
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-ru.md +448 -178
- data/README.md +510 -30
- data/lib/nested_array/engine.rb +11 -0
- data/lib/nested_array/nested.rb +214 -187
- data/lib/nested_array/version.rb +1 -1
- data/lib/nested_array.rb +3 -4
- data/nested_array.gemspec +13 -3
- data/vendor/assets/stylesheets/nested_array.scss +92 -0
- metadata +5 -27
- data/.gitignore +0 -10
- data/.rspec +0 -1
- data/.ruby-version +0 -1
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -54
- data/Rakefile +0 -2
- data/TODO.md +0 -29
- data/bash/build/gem.sh +0 -9
- data/bash/push/gem.sh +0 -15
- data/bash/test/gem.sh +0 -11
- data/bin/bundle +0 -105
- data/bin/byebug +0 -29
- data/bin/console +0 -14
- data/bin/htmldiff +0 -29
- data/bin/ldiff +0 -29
- data/bin/rake +0 -29
- data/bin/rspec +0 -29
- data/bin/setup +0 -8
- data/dev/nested_options.rb +0 -25
- data/test.old/Gemfile +0 -5
- data/test.old/Gemfile.lock +0 -34
- data/test.old/bash/run/bundle.sh +0 -9
- data/test.old/bash/run/test.sh +0 -9
- data/test.old/test.rb +0 -42
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested_array
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zlatov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,37 +87,15 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- ".gitignore"
|
91
|
-
- ".rspec"
|
92
|
-
- ".ruby-version"
|
93
|
-
- Gemfile
|
94
|
-
- Gemfile.lock
|
95
90
|
- LICENSE.txt
|
96
91
|
- README-ru.md
|
97
92
|
- README.md
|
98
|
-
- Rakefile
|
99
|
-
- TODO.md
|
100
|
-
- bash/build/gem.sh
|
101
|
-
- bash/push/gem.sh
|
102
|
-
- bash/test/gem.sh
|
103
|
-
- bin/bundle
|
104
|
-
- bin/byebug
|
105
|
-
- bin/console
|
106
|
-
- bin/htmldiff
|
107
|
-
- bin/ldiff
|
108
|
-
- bin/rake
|
109
|
-
- bin/rspec
|
110
|
-
- bin/setup
|
111
|
-
- dev/nested_options.rb
|
112
93
|
- lib/nested_array.rb
|
94
|
+
- lib/nested_array/engine.rb
|
113
95
|
- lib/nested_array/nested.rb
|
114
96
|
- lib/nested_array/version.rb
|
115
97
|
- nested_array.gemspec
|
116
|
-
-
|
117
|
-
- test.old/Gemfile.lock
|
118
|
-
- test.old/bash/run/bundle.sh
|
119
|
-
- test.old/bash/run/test.sh
|
120
|
-
- test.old/test.rb
|
98
|
+
- vendor/assets/stylesheets/nested_array.scss
|
121
99
|
homepage: https://github.com/Zlatov/nested_array
|
122
100
|
licenses:
|
123
101
|
- MIT
|
@@ -140,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
118
|
- !ruby/object:Gem::Version
|
141
119
|
version: '0'
|
142
120
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
121
|
+
rubygems_version: 3.1.6
|
144
122
|
signing_key:
|
145
123
|
specification_version: 4
|
146
124
|
summary: Convert a flat array into a nested one in 1 pass and another…
|
data/.gitignore
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--require spec_helper
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.3
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
nested_array (2.2.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (6.0.3.2)
|
10
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
-
i18n (>= 0.7, < 2)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
tzinfo (~> 1.1)
|
14
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
15
|
-
awesome_print (1.8.0)
|
16
|
-
byebug (11.0.1)
|
17
|
-
concurrent-ruby (1.1.6)
|
18
|
-
diff-lcs (1.3)
|
19
|
-
i18n (1.8.3)
|
20
|
-
concurrent-ruby (~> 1.0)
|
21
|
-
minitest (5.14.1)
|
22
|
-
rake (10.5.0)
|
23
|
-
rspec (3.9.0)
|
24
|
-
rspec-core (~> 3.9.0)
|
25
|
-
rspec-expectations (~> 3.9.0)
|
26
|
-
rspec-mocks (~> 3.9.0)
|
27
|
-
rspec-core (3.9.0)
|
28
|
-
rspec-support (~> 3.9.0)
|
29
|
-
rspec-expectations (3.9.0)
|
30
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.9.0)
|
32
|
-
rspec-mocks (3.9.0)
|
33
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.9.0)
|
35
|
-
rspec-support (3.9.0)
|
36
|
-
thread_safe (0.3.6)
|
37
|
-
tzinfo (1.2.7)
|
38
|
-
thread_safe (~> 0.1)
|
39
|
-
zeitwerk (2.3.0)
|
40
|
-
|
41
|
-
PLATFORMS
|
42
|
-
ruby
|
43
|
-
|
44
|
-
DEPENDENCIES
|
45
|
-
activesupport (~> 6.0)
|
46
|
-
awesome_print (~> 1.8)
|
47
|
-
bundler (~> 2.0)
|
48
|
-
byebug (~> 11.0)
|
49
|
-
nested_array!
|
50
|
-
rake (~> 10.0)
|
51
|
-
rspec (~> 3.9)
|
52
|
-
|
53
|
-
BUNDLED WITH
|
54
|
-
2.1.4
|
data/Rakefile
DELETED
data/TODO.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Что реализовано, необходимо реализовать и почему
|
2
|
-
|
3
|
-
## Почему
|
4
|
-
|
5
|
-
### Почему возвращаем массив Hash
|
6
|
-
|
7
|
-
Когда хотим из плоской структуры получить древовидную, то на руках мы можем
|
8
|
-
иметь данные различного типа, например, массив Hash или массив ActiveRecord,
|
9
|
-
результатом обработки должен быть массив объектов у которых должно быть поле
|
10
|
-
children содержащее потомков. Именно поэтому мы не можем оставлять в результате
|
11
|
-
массив ActiveRecord, так как поле children будет конфликтовать с уже
|
12
|
-
существующим методом, например при использовании гема closure_tree. С другой
|
13
|
-
стороны мы моглибы внедрить поле nested_children во все объекты ActiveRecord,
|
14
|
-
но такой подход, мне кажется, похож на «Monkey patch».
|
15
|
-
|
16
|
-
|
17
|
-
## TODO
|
18
|
-
|
19
|
-
+ Хочу возвращать массив OpenStruct вместо массива Hash.
|
20
|
-
|
21
|
-
При возврате массива OpenStruct (всегда) пропадает смысл метода `each_nested!`
|
22
|
-
который должен отдавать в переменной node исходные данные (ну они не исходые
|
23
|
-
уже). Поэтому необходимо выпустить версию 3.0.0 с удалением метода
|
24
|
-
`each_nested!`.
|
25
|
-
|
26
|
-
Добавлен метод nested_to_collection_select, нужно пересмотреть метод
|
27
|
-
nested_to_options (возможно удалить в следующей версии).
|
28
|
-
|
29
|
-
Переработать README-ru и на английский доперевести в конце концов.
|
data/bash/build/gem.sh
DELETED
data/bash/push/gem.sh
DELETED
data/bash/test/gem.sh
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
set -eu
|
4
|
-
|
5
|
-
cd "$(dirname "${0}")"
|
6
|
-
|
7
|
-
cd ../..
|
8
|
-
|
9
|
-
# rspec управляет загружаемыми гемами, поэтому сам rspec запускается НЕ `bundle exec rspec`, а просто `rspec`
|
10
|
-
./bin/rspec --format doc ./spec/array_spec.rb
|
11
|
-
./bin/rspec --format doc ./spec/nested_array_array_spec.rb
|
data/bin/bundle
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'bundle' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "rubygems"
|
12
|
-
|
13
|
-
m = Module.new do
|
14
|
-
module_function
|
15
|
-
|
16
|
-
def invoked_as_script?
|
17
|
-
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
-
end
|
19
|
-
|
20
|
-
def env_var_version
|
21
|
-
ENV["BUNDLER_VERSION"]
|
22
|
-
end
|
23
|
-
|
24
|
-
def cli_arg_version
|
25
|
-
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
-
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
-
bundler_version = nil
|
28
|
-
update_index = nil
|
29
|
-
ARGV.each_with_index do |a, i|
|
30
|
-
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
-
bundler_version = a
|
32
|
-
end
|
33
|
-
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
-
bundler_version = $1 || ">= 0.a"
|
35
|
-
update_index = i
|
36
|
-
end
|
37
|
-
bundler_version
|
38
|
-
end
|
39
|
-
|
40
|
-
def gemfile
|
41
|
-
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
-
return gemfile if gemfile && !gemfile.empty?
|
43
|
-
|
44
|
-
File.expand_path("../../Gemfile", __FILE__)
|
45
|
-
end
|
46
|
-
|
47
|
-
def lockfile
|
48
|
-
lockfile =
|
49
|
-
case File.basename(gemfile)
|
50
|
-
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
-
else "#{gemfile}.lock"
|
52
|
-
end
|
53
|
-
File.expand_path(lockfile)
|
54
|
-
end
|
55
|
-
|
56
|
-
def lockfile_version
|
57
|
-
return unless File.file?(lockfile)
|
58
|
-
lockfile_contents = File.read(lockfile)
|
59
|
-
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
-
Regexp.last_match(1)
|
61
|
-
end
|
62
|
-
|
63
|
-
def bundler_version
|
64
|
-
@bundler_version ||= begin
|
65
|
-
env_var_version || cli_arg_version ||
|
66
|
-
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def load_bundler!
|
71
|
-
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
-
|
73
|
-
# must dup string for RG < 1.8 compatibility
|
74
|
-
activate_bundler(bundler_version.dup)
|
75
|
-
end
|
76
|
-
|
77
|
-
def activate_bundler(bundler_version)
|
78
|
-
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
-
bundler_version = "< 2"
|
80
|
-
end
|
81
|
-
gem_error = activation_error_handling do
|
82
|
-
gem "bundler", bundler_version
|
83
|
-
end
|
84
|
-
return if gem_error.nil?
|
85
|
-
require_error = activation_error_handling do
|
86
|
-
require "bundler/version"
|
87
|
-
end
|
88
|
-
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
-
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
-
exit 42
|
91
|
-
end
|
92
|
-
|
93
|
-
def activation_error_handling
|
94
|
-
yield
|
95
|
-
nil
|
96
|
-
rescue StandardError, LoadError => e
|
97
|
-
e
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
m.load_bundler!
|
102
|
-
|
103
|
-
if m.invoked_as_script?
|
104
|
-
load Gem.bin_path("bundler", "bundle")
|
105
|
-
end
|
data/bin/byebug
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'byebug' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("byebug", "byebug")
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "nested_array"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/htmldiff
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'ldiff' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rake' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rspec' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/setup
DELETED
data/dev/nested_options.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require_relative '../lib/nested_array.rb'
|
2
|
-
require 'awesome_print'
|
3
|
-
|
4
|
-
a = [
|
5
|
-
{'id' => 1, 'parent_id' => nil, 'name' => 'category 1'},
|
6
|
-
{'id' => 2, 'parent_id' => nil, 'name' => 'category 2'},
|
7
|
-
{'id' => 3, 'parent_id' => 2, 'name' => 'category 3'},
|
8
|
-
{'id' => 4, 'parent_id' => nil, 'name' => 'category 4'},
|
9
|
-
{'id' => 5, 'parent_id' => 4, 'name' => 'category 5'},
|
10
|
-
{'id' => 6, 'parent_id' => 5, 'name' => 'category 6'},
|
11
|
-
{'id' => 7, 'parent_id' => nil, 'name' => 'category 7'},
|
12
|
-
{'id' => 8, 'parent_id' => 7, 'name' => 'category 8'},
|
13
|
-
{'id' => 9, 'parent_id' => 7, 'name' => 'category 9'},
|
14
|
-
{'id' => 10, 'parent_id' => 9, 'name' => 'category 10'},
|
15
|
-
{'id' => 11, 'parent_id' => 9, 'name' => 'category 11'}
|
16
|
-
]
|
17
|
-
|
18
|
-
b = a.shuffle
|
19
|
-
|
20
|
-
array = b.to_nested.nested_to_options
|
21
|
-
print 'array: '.red; p array
|
22
|
-
|
23
|
-
array.each do |v|
|
24
|
-
puts v[0]
|
25
|
-
end
|
data/test.old/Gemfile
DELETED
data/test.old/Gemfile.lock
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
nested_array (1.0.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (6.0.2.1)
|
10
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
-
i18n (>= 0.7, < 2)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
tzinfo (~> 1.1)
|
14
|
-
zeitwerk (~> 2.2)
|
15
|
-
awesome_print (1.8.0)
|
16
|
-
concurrent-ruby (1.1.6)
|
17
|
-
i18n (1.8.2)
|
18
|
-
concurrent-ruby (~> 1.0)
|
19
|
-
minitest (5.14.0)
|
20
|
-
thread_safe (0.3.6)
|
21
|
-
tzinfo (1.2.6)
|
22
|
-
thread_safe (~> 0.1)
|
23
|
-
zeitwerk (2.2.2)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
activesupport
|
30
|
-
awesome_print
|
31
|
-
nested_array!
|
32
|
-
|
33
|
-
BUNDLED WITH
|
34
|
-
2.0.1
|
data/test.old/bash/run/bundle.sh
DELETED
data/test.old/bash/run/test.sh
DELETED
data/test.old/test.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'active_support/all'
|
2
|
-
require 'awesome_print'
|
3
|
-
require 'nested_array'
|
4
|
-
|
5
|
-
puts 'Начато тестирование.'.blue
|
6
|
-
puts "Версия руби: #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
7
|
-
|
8
|
-
def to_nested_1
|
9
|
-
puts "Тестирование #{__method__}".blue
|
10
|
-
a = [
|
11
|
-
{'id' => 1, 'parent_id' => nil, 'name' => 'first'},
|
12
|
-
{'id' => 2, 'parent_id' => 1, 'name' => 'second'},
|
13
|
-
{'id' => 3, 'parent_id' => 1, 'name' => 'third'}
|
14
|
-
]
|
15
|
-
a = NestedArray::Array.new a
|
16
|
-
b = a.to_nested
|
17
|
-
return false if b != [
|
18
|
-
{'id' => 1, 'parent_id' => nil, 'name' => 'first', 'children' => [
|
19
|
-
{'id' => 2, 'parent_id' => 1, 'name' => 'second'},
|
20
|
-
{'id' => 3, 'parent_id' => 1, 'name' => 'third'}
|
21
|
-
]},
|
22
|
-
]
|
23
|
-
b = a.to_nested add_level: true
|
24
|
-
return false if b != [
|
25
|
-
{'id' => 1, 'parent_id' => nil, 'name' => 'first', 'level' => 0, 'children' => [
|
26
|
-
{'id' => 2, 'parent_id' => 1, 'name' => 'second', 'level' => 1},
|
27
|
-
{'id' => 3, 'parent_id' => 1, 'name' => 'third', 'level' => 1}
|
28
|
-
]},
|
29
|
-
]
|
30
|
-
return true
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
begin
|
37
|
-
raise if !to_nested_1
|
38
|
-
rescue => e
|
39
|
-
puts 'Тестирование не пройдено.'.red
|
40
|
-
exit 1
|
41
|
-
end
|
42
|
-
puts 'Тестирование пройдено.'.green
|