Skip to content

Ruby ecosystem development introduction workshop: Tokyo: 2026-08-05: PharaohKJ: ruby/ipaddr: Work log #2086

Closed

Description

@PharaohKJ

This is a work log of a "Ruby ecosystem development introduction workshop".
"Ruby ecosystem development introduction workshop" is an activity to increase Ruby ecosystem developers.
Here's been discussed in Japanese. Thanks.

作業ログ作成時の説明

以下のテンプレートを埋めてタイトルに設定します。埋め方例はスクロールすると見えてきます。

Ruby ecosystem development introduction workshop: Tokyo: #{YEAR}-#{MONTH}-#{DAY}: #{ACCOUNT_NAME}: #{PRODUCT_NAME}: Work log

タイトル例↓:

Ruby ecosystem development introduction workshop: Tokyo: 2026-08-05: kou: Rabbit: Work log

Rubyエコシステム開発入門ワークショップ関連情報

  • スライド:ワークショップの進行に使っているスライドがあります。
  • ruby-jp Slackの#oss_gateチャンネル:Rubyエコシステムの開発に関することならなんでも相談できます。ワークショップが終わった後もオンラインで相談しながら継続的にRubyエコシステムの開発に参加しましょう!
  • 過去のビギナーの作業ログ:他の人の作業ログから学べることがいろいろあるはずです。

Activity

  1. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    issueを眺める

  2. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    ruby/ipaddr#94 → issue起票者が対応しそう

  3. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    なんとなく眺めたので、動かしてみるか。

    git clone [email protected]:ruby/ipaddr.git
    
  4. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    ruby が 4.0.5 で恥ずかしいのであげとくか、、、

    [pharaohkj] $ rbenv global 4.0.6
    ruby-build: using openssl@3 from homebrew
    ==> Downloading ruby-4.0.6.tar.gz...
    -> curl -q -fL -o ruby-4.0.6.tar.gz https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.6.tar.gz
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 22.7M  100 22.7M    0     0  26.0M      0 --:--:-- --:--:-- --:--:-- 26.0M
    ==> Installing ruby-4.0.6...
    ruby-build: using libyaml from homebrew
    ruby-build: using gmp from homebrew
    -> ./configure "--prefix=$HOME/.rbenv/versions/4.0.6" --with-openssl-dir=/opt/homebrew/opt/openssl@3 --enable-shared --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-ext=openssl,psych,+
    -> make -j 12
    -> make install
    ==> Installed ruby-4.0.6 to /Users/pharaohkj/.rbenv/versions/4.0.6
    
    [pharaohkj] $ ruby -v
    ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM [arm64-darwin25]
    
  5. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    README.mdを参考に、とりまtestを実行。動く。

    [pharaohkj] $ bundle install
    Fetching gem metadata from https://rubygems.org/.......
    Resolving dependencies...
    Fetching rake 13.4.2
    Installing rake 13.4.2
    Fetching test-unit 3.7.8
    Fetching test-unit-ruby-core 1.0.14
    Installing test-unit-ruby-core 1.0.14
    Installing test-unit 3.7.8
    Bundle complete! 5 Gemfile dependencies, 5 gems now installed.
    Use `bundle info [gemname]` to see where a bundled gem is installed.
    
    
    ~/Dropbox/m2osx/gitwork/ipaddr
    [pharaohkj] $ be rake
    Loaded suite /Users/pharaohkj/.rbenv/versions/4.0.6/lib/ruby/gems/4.0.0/gems/rake-13.4.2/lib/rake/rake_test_loader
    Started
    Finished in 0.008535 seconds.
    ---------------------------------------------------------------------------------------
    37 tests, 525 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
    100% passed
    ---------------------------------------------------------------------------------------
    4335.09 tests/s, 61511.42 assertions/s
    
  6. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    Rubyの世界に足を踏み入れてから、相変わらずこのライブラリにはどんなインタフェイスがあり、利用者はどれを呼ぶべきなのか、というのがピンとこない。

    issueの内容は「これ仕様?」というようなものがたくさんあり、仕様を明記してもいいのかもしれない。

    そのため、testを元に、仕様を起こしてみる。
    testに載ってないことは、「考慮されていない」「後で考える」ことであると想定できる。

    LLMに頼ってみる。

  7. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    とりあえず愛するRubyMineでcloneしたディレクトリを開く。

  8. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    そもそもどんな挙動が正しいのかドキュメントも眺めてみる。
    このgemのrdocを読むにはどうしたらよいのだろうか?

    教えていただいた結果、以下

    ~/Library/CloudStorage/Dropbox/m2osx/gitwork/ipaddr
    [pharaohkj] $ rdoc
    Parsing sources...
    100% [ 4/ 4]  /Users/pharaohkj/Library/CloudStorage/Dropbox/m2osx/gitwork/ipaddr/lib/ipaddr.rb
    
    Generating Aliki format into /Users/pharaohkj/Library/CloudStorage/Dropbox/m2osx/gitwork/ipaddr/doc...
    
    You can visit the home page at: file:///Users/pharaohkj/Library/CloudStorage/Dropbox/m2osx/gitwork/ipaddr/doc/index.html
    
      Files:       4
    
      Classes:     6 (1 undocumented)
      Modules:     1 (1 undocumented)
      Constants:   8 (0 undocumented)
      Attributes:  1 (0 undocumented)
      Methods:    53 (0 undocumented)
    
      Total:      69 (2 undocumented)
       97.10% documented
    
      Elapsed: 0.2s
    
    ~/Library/CloudStorage/Dropbox/m2osx/gitwork/ipaddr
    [pharaohkj] $ open file:///Users/pharaohkj/Library/CloudStorage/Dropbox/m2osx/gitwork/ipaddr/doc/index.html
    
  9. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    READMD.md を読むと、以下となっていて、「標準が備えているべきのもの」と「そうじゃないもの」のセンスが問われている気がする、、、。

    ## Alternative
    
    The [ipaddress](https://rubygems.org/gems/ipaddress) gem is a popular,
    extensive library for manipulating IP addresses with a layer of
    compatibility with `ipaddr`.  If you need a richer set of features
    than `ipaddr` has, try this library instead.
    
  10. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    ruby/ipaddr#83 を実装してプルリクしてみようと思う。

    実装した。

    テストも追加した。

    しかしながら、その提案通りに実装すると、内部で固定文字列をひたすら持つことになり、計測したところ
    14,0KiBの増加であった。

    ruby -robjspace -Ilib -e 'require "ipaddr"; v4=IPAddr::IPV4_SUBNET_MASKS; v6=IPAddr::IPV6_SUBNET_MASKS; def deep(a) ObjectSpace.memsize_of(a)+a.sum{|s| ObjectSpace.memsize_of(s)} end; puts "ruby=#{RUBY_VERSION}"; puts "v4_count=#{v4.size}"; puts "v6_count=#{v6.size}"; puts "v4_payload_bytes=#{v4.sum(&:bytesize)}"; puts "v6_payload_bytes=#{v6.sum(&:bytesize)}"; puts "v4_memsize=#{deep(v4)}"; puts "v6_memsize=#{deep(v6)}"; puts "total_memsize=#{deep(v4)+deep(v6)}"'

    結果

    v4_count=33
    v4_memsize=2920
    total_memsize=14312
    
  11. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    14KiBはでかすぎないか、、、? netmask? は計算で出した方が優しいのかもしれない。

  12. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    そりゃまぁこういう文字列を内部で定義してるんだからでかいよね。

      # Subnet masks for IPv4 indexed by prefix length (/0 to /32)
      IPV4_SUBNET_MASKS = %w[0.0.0.0 128.0.0.0 192.0.0.0 224.0.0.0 240.0.0.0 248.0.0.0 252.0.0.0 254.0.0.0 255.0.0.0 255.128.0.0 255.192.0.0 255.224.0.0 255.240.0.0 255.248.0.0 255.252.0.0 255.254.0.0 255.255.0.0 255.255.128.0 255.255.192.0 255.255.224.0 255.255.240.0 255.255.248.0 255.255.252.0 255.255.254.0 255.255.255.0 255.255.255.128 255.255.255.192 255.255.255.224 255.255.255.240 255.255.255.248 255.255.255.252 255.255.255.254 255.255.255.255].freeze
      # Subnet masks for IPv6 indexed by prefix length (/0 to /128)
      IPV6_SUBNET_MASKS = %w[0000:0000:0000:0000:0000:0000:0000:0000 8000:0000:0000:0000:0000:0000:0000:0000 c000:0000:0000:0000:0000:0000:0000:0000 e000:0000:0000:0000:0000:0000:0000:0000 f000:0000:0000:0000:0000:0000:0000:0000 f800:0000:0000:0000:0000:0000:0000:0000 fc00:0000:0000:0000:0000:0000:0000:0000 fe00:0000:0000:0000:0000:0000:0000:0000 ff00:0000:0000:0000:0000:0000:0000:0000 ff80:0000:0000:0000:0000:0000:0000:0000 ffc0:0000:0000:0000:0000:0000:0000:0000 ffe0:0000:0000:0000:0000:0000:0000:0000 fff0:0000:0000:0000:0000:0000:0000:0000 fff8:0000:0000:0000:0000:0000:0000:0000 fffc:0000:0000:0000:0000:0000:0000:0000 fffe:0000:0000:0000:0000:0000:0000:0000 ffff:0000:0000:0000:0000:0000:0000:0000 ffff:8000:0000:0000:0000:0000:0000:0000 ffff:c000:0000:0000:0000:0000:0000:0000 ffff:e000:0000:0000:0000:0000:0000:0000 ffff:f000:0000:0000:0000:0000:0000:0000 ffff:f800:0000:0000:0000:0000:0000:0000 ffff:fc00:0000:0000:0000:0000:0000:0000 ffff:fe00:0000:0000:0000:0000:0000:0000 ffff:ff00:0000:0000:0000:0000:0000:0000 ffff:ff80:0000:0000:0000:0000:0000:0000 ffff:ffc0:0000:0000:0000:0000:0000:0000 ffff:ffe0:0000:0000:0000:0000:0000:0000 ffff:fff0:0000:0000:0000:0000:0000:0000 ffff:fff8:0000:0000:0000:0000:0000:0000 ffff:fffc:0000:0000:0000:0000:0000:0000 ffff:fffe:0000:0000:0000:0000:0000:0000 ffff:ffff:0000:0000:0000:0000:0000:0000 ffff:ffff:8000:0000:0000:0000:0000:0000 ffff:ffff:c000:0000:0000:0000:0000:0000 ffff:ffff:e000:0000:0000:0000:0000:0000 ffff:ffff:f000:0000:0000:0000:0000:0000 ffff:ffff:f800:0000:0000:0000:0000:0000 ffff:ffff:fc00:0000:0000:0000:0000:0000 ffff:ffff:fe00:0000:0000:0000:0000:0000 ffff:ffff:ff00:0000:0000:0000:0000:0000 ffff:ffff:ff80:0000:0000:0000:0000:0000 ffff:ffff:ffc0:0000:0000:0000:0000:0000 ffff:ffff:ffe0:0000:0000:0000:0000:0000 ffff:ffff:fff0:0000:0000:0000:0000:0000 ffff:ffff:fff8:0000:0000:0000:0000:0000 ffff:ffff:fffc:0000:0000:0000:0000:0000 ffff:ffff:fffe:0000:0000:0000:0000:0000 ffff:ffff:ffff:0000:0000:0000:0000:0000 ffff:ffff:ffff:8000:0000:0000:0000:0000 ffff:ffff:ffff:c000:0000:0000:0000:0000 ffff:ffff:ffff:e000:0000:0000:0000:0000 ffff:ffff:ffff:f000:0000:0000:0000:0000 ffff:ffff:ffff:f800:0000:0000:0000:0000 ffff:ffff:ffff:fc00:0000:0000:0000:0000 ffff:ffff:ffff:fe00:0000:0000:0000:0000 ffff:ffff:ffff:ff00:0000:0000:0000:0000 ffff:ffff:ffff:ff80:0000:0000:0000:0000 ffff:ffff:ffff:ffc0:0000:0000:0000:0000 ffff:ffff:ffff:ffe0:0000:0000:0000:0000 ffff:ffff:ffff:fff0:0000:0000:0000:0000 ffff:ffff:ffff:fff8:0000:0000:0000:0000 ffff:ffff:ffff:fffc:0000:0000:0000:0000 ffff:ffff:ffff:fffe:0000:0000:0000:0000 ffff:ffff:ffff:ffff:0000:0000:0000:0000 ffff:ffff:ffff:ffff:8000:0000:0000:0000 ffff:ffff:ffff:ffff:c000:0000:0000:0000 ffff:ffff:ffff:ffff:e000:0000:0000:0000 ffff:ffff:ffff:ffff:f000:0000:0000:0000 ffff:ffff:ffff:ffff:f800:0000:0000:0000 ffff:ffff:ffff:ffff:fc00:0000:0000:0000 ffff:ffff:ffff:ffff:fe00:0000:0000:0000 ffff:ffff:ffff:ffff:ff00:0000:0000:0000 ffff:ffff:ffff:ffff:ff80:0000:0000:0000 ffff:ffff:ffff:ffff:ffc0:0000:0000:0000 ffff:ffff:ffff:ffff:ffe0:0000:0000:0000 ffff:ffff:ffff:ffff:fff0:0000:0000:0000 ffff:ffff:ffff:ffff:fff8:0000:0000:0000 ffff:ffff:ffff:ffff:fffc:0000:0000:0000 ffff:ffff:ffff:ffff:fffe:0000:0000:0000 ffff:ffff:ffff:ffff:ffff:0000:0000:0000 ffff:ffff:ffff:ffff:ffff:8000:0000:0000 ffff:ffff:ffff:ffff:ffff:c000:0000:0000 ffff:ffff:ffff:ffff:ffff:e000:0000:0000 ffff:ffff:ffff:ffff:ffff:f000:0000:0000 ffff:ffff:ffff:ffff:ffff:f800:0000:0000 ffff:ffff:ffff:ffff:ffff:fc00:0000:0000 ffff:ffff:ffff:ffff:ffff:fe00:0000:0000 ffff:ffff:ffff:ffff:ffff:ff00:0000:0000 ffff:ffff:ffff:ffff:ffff:ff80:0000:0000 ffff:ffff:ffff:ffff:ffff:ffc0:0000:0000 ffff:ffff:ffff:ffff:ffff:ffe0:0000:0000 ffff:ffff:ffff:ffff:ffff:fff0:0000:0000 ffff:ffff:ffff:ffff:ffff:fff8:0000:0000 ffff:ffff:ffff:ffff:ffff:fffc:0000:0000 ffff:ffff:ffff:ffff:ffff:fffe:0000:0000 ffff:ffff:ffff:ffff:ffff:ffff:0000:0000 ffff:ffff:ffff:ffff:ffff:ffff:8000:0000 ffff:ffff:ffff:ffff:ffff:ffff:c000:0000 ffff:ffff:ffff:ffff:ffff:ffff:e000:0000 ffff:ffff:ffff:ffff:ffff:ffff:f000:0000 ffff:ffff:ffff:ffff:ffff:ffff:f800:0000 ffff:ffff:ffff:ffff:ffff:ffff:fc00:0000 ffff:ffff:ffff:ffff:ffff:ffff:fe00:0000 ffff:ffff:ffff:ffff:ffff:ffff:ff00:0000 ffff:ffff:ffff:ffff:ffff:ffff:ff80:0000 ffff:ffff:ffff:ffff:ffff:ffff:ffc0:0000 ffff:ffff:ffff:ffff:ffff:ffff:ffe0:0000 ffff:ffff:ffff:ffff:ffff:ffff:fff0:0000 ffff:ffff:ffff:ffff:ffff:ffff:fff8:0000 ffff:ffff:ffff:ffff:ffff:ffff:fffc:0000 ffff:ffff:ffff:ffff:ffff:ffff:fffe:0000 ffff:ffff:ffff:ffff:ffff:ffff:ffff:0000 ffff:ffff:ffff:ffff:ffff:ffff:ffff:8000 ffff:ffff:ffff:ffff:ffff:ffff:ffff:c000 ffff:ffff:ffff:ffff:ffff:ffff:ffff:e000 ffff:ffff:ffff:ffff:ffff:ffff:ffff:f000 ffff:ffff:ffff:ffff:ffff:ffff:ffff:f800 ffff:ffff:ffff:ffff:ffff:ffff:ffff:fc00 ffff:ffff:ffff:ffff:ffff:ffff:ffff:fe00 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff80 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffc0 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffe0 ffff:ffff:ffff:ffff:ffff:ffff:ffff:fff0 ffff:ffff:ffff:ffff:ffff:ffff:ffff:fff8 ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffc ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff].freeze
    
  13. PharaohKJ commented on Aug 5, 2026

    @PharaohKJ
    ContributorAuthor

    動的生成にした。forkしてコミットしてプッシュしてプルリクもした!やったぜ。

    ruby/ipaddr#117

  14. github-actions commented on Sep 7, 2026

    @github-actions

    おつかれさまでした!

    ワークショップの終了にともないissueを閉じますが、このまま作業メモとして使っても構いません 👌

    ワークショップの感想を集めています!

    ブログなどに書かれた際は、このページへリンクの追加をお願いします 🙏

    またの参加をお待ちしています!

  15. changed the title [-]Ruby ecosystem development introduction workshop: Tokyo: 2026-8-5: PharaohKJ : ruby/ipaddr : Work log[/-] [+]Ruby ecosystem development introduction workshop: Tokyo: 2026-08-05: PharaohKJ: ruby/ipaddr: Work log[/+] on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rubyRuby relatedwork logワークショップ作業メモ

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions