@ledsun blog

Hのキーがhellで、Sのキーがslaveだ、と彼は思った。そしてYのキーがyouだ。

bundle installせずにrails runnerからgemのコマンドを実行する

  1. GitHub - k0kubun/gem-default: Change a non-default gem to a default gem in your local environment を使ってgemをdefault gem化します
  2. gemをrequireして実行するスクリプトを標準入力で、rails runnerに渡します
~ gem install gem-default
Fetching gem-default-0.0.2.gem
Successfully installed gem-default-0.0.2
Parsing documentation for gem-default-0.0.2
Installing ri documentation for gem-default-0.0.2
Done installing documentation for gem-default after 0 seconds
1 gem installed
~ gem default activerecord_uml
=> Copying files from "/Users/shigerunakajima/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord_uml-0.5.0/lib" to:
/Users/shigerunakajima/.rbenv/versions/3.0.1/lib/ruby/3.0.0/activerecord_uml.rb
/Users/shigerunakajima/.rbenv/versions/3.0.1/lib/ruby/3.0.0/activerecord_uml/diagram_drawer.rb
/Users/shigerunakajima/.rbenv/versions/3.0.1/lib/ruby/3.0.0/activerecord_uml/version.rb

=> Copying files from "/Users/shigerunakajima/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord_uml-0.5.0/exe" to:
/Users/shigerunakajima/.rbenv/versions/3.0.1/bin/activerecord_uml (original => /Users/shigerunakajima/.rbenv/versions/3.0.1/bin/activerecord_uml.old)
~ echo 'require "activerecord_uml"; ActiverecordUml.draw' | bin/rails runner -
Running via Spring preloader in process 66164
<html>
  <body>
    <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
    <script>mermaid.initialize({startOnLoad:true});</script>

    <div class="mermaid">

classDiagram

    </div>
  </body>
</html>

ruby-jpのslackでid:Pockeさんにgem-defaultを教えてもらいました。

requireの仕方を、もうちょっと工夫したいです。