ruby_var_dump 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 93c42ac23cde8bd67f014d707b756c88db26db98bb8329dbf81901fb8ba1ae01
4
+ data.tar.gz: fb827eb23f9833728671d81dc73b8457b0254c5dcc328bef2b051473e2f9cc07
5
+ SHA512:
6
+ metadata.gz: 8a0b06e8c302172ec843e95bb4d302a9249b056219dd256b0124fe59522e5f4cf275cbdb89b7b2061d137b5e06af9a0c381aa37de52072331d14159c9ac6da7e
7
+ data.tar.gz: 7e26fd7f6f70a10be2a310a0dd673ffd993bd0a9c55a5e50ea13657061dcf84693ccd882f69f4a24a1a6b2cbddbeb988ae5d8e7edcddbb3e34b70193e14482a7
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rspec_status ADDED
@@ -0,0 +1,11 @@
1
+ example_id | status | run_time |
2
+ ------------------------------------- | ------ | --------------- |
3
+ ./spec/ruby_var_dump_spec.rb[1:1:1] | passed | 0.00026 seconds |
4
+ ./spec/ruby_var_dump_spec.rb[1:1:2:1] | passed | 0.0002 seconds |
5
+ ./spec/ruby_var_dump_spec.rb[1:1:2:2] | passed | 0.00003 seconds |
6
+ ./spec/ruby_var_dump_spec.rb[1:1:3:1] | passed | 0.00003 seconds |
7
+ ./spec/ruby_var_dump_spec.rb[1:1:3:2] | passed | 0.00004 seconds |
8
+ ./spec/ruby_var_dump_spec.rb[1:1:4:1] | passed | 0.00003 seconds |
9
+ ./spec/ruby_var_dump_spec.rb[1:1:4:2] | passed | 0.00003 seconds |
10
+ ./spec/ruby_var_dump_spec.rb[1:1:5:1] | passed | 0.00004 seconds |
11
+ ./spec/ruby_var_dump_spec.rb[1:1:6:1] | passed | 0.00008 seconds |
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/standardrb/standard
3
+ ruby_version: 3.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-04-14
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 hirokiyam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # RubyVarDump
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruby_var_dump`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby_var_dump.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyVarDump
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ruby_var_dump/version"
4
+
5
+ module RubyVarDump
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+
9
+ def self.dump(obj, level = 0, is_value = false)
10
+ indent = ' ' * level * 2
11
+ if obj.is_a?(Array)
12
+ print "#{is_value ? '' : indent}" + "["
13
+ if obj.empty?
14
+ print "]"
15
+ else
16
+ print "\n"
17
+ obj.each_with_index do |item, index|
18
+ self.dump(item, level + 1, false)
19
+ print "," unless index == obj.size - 1
20
+ print "\n"
21
+ end
22
+ print "#{indent}]"
23
+ end
24
+ elsif obj.is_a?(Hash)
25
+ print "#{is_value ? '' : indent}" + "{"
26
+ if obj.empty?
27
+ print "}"
28
+ else
29
+ print "\n"
30
+ obj.each_with_index do |(key, value), index|
31
+ # キーにインデントを適用し、値にはインデントを適用しない
32
+ print "#{indent} #{key.inspect.chomp} => "
33
+ if value.is_a?(Hash) || value.is_a?(Array)
34
+ self.dump(value, level + 1, true) # ハッシュのバリューの場合には is_value を true に設定
35
+ else
36
+ print value.inspect # プリミティブな値の場合は現在のレベルで出力
37
+ end
38
+ print "," unless index == obj.size - 1
39
+ print "\n"
40
+ end
41
+ print "#{indent}}"
42
+ end
43
+ elsif defined?(ActiveRecord::Relation) && obj.is_a?(ActiveRecord::Relation)
44
+ obj.each_with_index do |record, index|
45
+ self.dump(record, level, false)
46
+ if index < obj.size - 1 # 要素が続く場合
47
+ print ",\n"
48
+ else
49
+ print "\n" # レコードの最後の場合は改行のみ
50
+ end
51
+ end
52
+ elsif obj.respond_to?(:attributes)
53
+ self.dump(obj.attributes, level, false)
54
+ else
55
+ print indent + obj.inspect.chomp
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,4 @@
1
+ module RubyVarDump
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_var_dump
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - hirokiyam
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-04-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Ruby gem for detailed debugging and inspection of objects, mimicking
14
+ PHP's var_dump function.
15
+ email:
16
+ - distant.record@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - ".rspec_status"
23
+ - ".standard.yml"
24
+ - CHANGELOG.md
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - lib/ruby_var_dump.rb
29
+ - lib/ruby_var_dump/version.rb
30
+ - sig/ruby_var_dump.rbs
31
+ homepage: https://github.com/hirokiyam
32
+ licenses:
33
+ - MIT
34
+ metadata:
35
+ allowed_push_host: https://rubygems.org
36
+ homepage_uri: https://github.com/hirokiyam
37
+ source_code_uri: https://github.com/hirokiyam/ruby_var_dump
38
+ changelog_uri: https://github.com/hirokiyam/ruby_var_dump/blob/main/CHANGELOG.md
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.5.9
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: A Ruby gem for detailed debugging and inspection of objects.
58
+ test_files: []