2021å¹´ãªã®ã§ãããããã¯æ¬²ããã
- Ruby 2.7.4
- VSCode
- ãã¤ããªgemã確å®ã«ãã«ãã§ãã
- ã³ã¼ããã©ã¼ããã¿
- Lint
- ãããã¬
- ã³ã¼ãè£å®
ããããã¯ç¬ç«ããæ©è½ãªã®ã§å ¨é¨å ¥ããªãã¦ãããã¨æãã¾ãã(å人çã«ã¯ä¸ããé ã«å¿ é 度ãé«ã)
Ruby 2.7.4
Ruby3èªä½ã¯å®å®ãã¦ãããgemå¨ãã®æåãè¥å¹²å®å®ãã¦ããªãã£ãã®ã§ãã¡ããæ¡ç¨ããã (RubyInstallerã2.7ç³»ãã¾ã ãããããã¦ããã)
https://rubyinstaller.org/downloads/
rubyinstaller-devkit-2.7.4-1-x64.exe
ããã¦ã³ãã¼ããã¦ã¤ã³ã¹ãã¼ã«ã
Rubyã®ã¤ã³ã¹ãã¼ã«çµäºå¾ã«msysãªã©ãã¤ã³ã¹ãã¼ã«ãã¦ãããèãã¦ããã®ã§åºæ¬çã«ã¯å ¨ã¦ã¤ã³ã¹ãã¼ã«ã
ãã¤ããªgemã®ã¤ã³ã¹ãã¼ã«
ã¹ã¿ã¼ãã¡ãã¥ã¼ã«ãStart Command Prompt with Rubyããä½ãããã®ã§ããããgem installããã
(ãã«ãã«ããªãè²ã å¿ è¦ãª) popplerãã¡ããã¨ã¤ã³ã¹ãã¼ã«ã§ãã¦æåããã
ã³ã¼ããã©ã¼ããã¿
ã³ã¼ããã©ã¼ããã¿ã«ã¯rufoã使ããã¨ã«ããã
rubocopã¨æ¯ã¹ã¦ããªãé«éã«åä½ããã®ãããã
VSCodeã§ç·¨éä¸ã¯å®æçã«Shift+Alt+F
ããæ´¾ãªã®ã§ããã«æ´å½¢ã§ããæ¹ãããããããprettierã¨éã£ã¦nodeãå¿
è¦ã¨ããªãã®ãããã
> gem install -N rufo
â» æ´å½¢ããã³ã¼ãã¯æåãªprettierã®ãã
Lint
Toolboxã§èª¿ã¹ãã¨ããªãå¢ãã®ããstandardãæ¡ç¨ã é¢åãªè¨å®ç¡ãã§ããã«ä½¿ããã®ããããããã
> gem install -N standard
é©å½ãªRubyããã¸ã§ã¯ãã®ä¸ã«ç§»åãã¦ã以ä¸ã®ã³ãã³ããå®è¡ããã°ããæãã§ã³ã¼ããä¿®æ£ãã¦ãããã
$ cd /path/to/project $ standardrb --fix
ææã¡ã®mrubyããã¸ã§ã¯ãã®ã³ã¼ããåé¡ãªãã³ã¼ãä¿®æ£ã§ããã
ifã®trueç¯ã¨falseç¯ã§åãå¤æ°ã«ä»£å ¥ããå ´åã«å¼ã®æ»ãå¤ã§ä»£å ¥ããããã«å¤æ´ãã¦ããã¦ãªããªããããã(ã¨ãããRubyã®ifãæãããªãã¦å¼ãªãã¨ãç¥ããªãã£ããããããã®ãåæã«æãã¦ãããã®ãLintã®ããã¨ããã ã¨æã)
è¨å®ããã°VSCodeãããåé¡ã®ããã³ã¼ããæãã¦ãããã
ãããã¬
ããã¯è²ã ãªã¨ããã§ããããããã¦ããgemããã®ã¾ã¾ä½¿ã£ãã
> gem install -N debase ruby-debug-ide
ãããã¬ãF5ã§èµ·åããã«ã¯.vscode/launch.json
ã®è¨å®ãå¿
è¦ã(VSCodeã®GUIä¸ã§èªåçæãã¦ãããããæã§æ¸ãã¦ããã)
VSCodeã®è¨å®
ããã¾ã§ã¤ã³ã¹ãã¼ã«ããgemãVSCodeã§ã使ããããã«ããã
ããããRubyãã©ã°ã¤ã³ãã¤ã³ã¹ãã¼ã«ãã¦ã以ä¸ã®è¨å®ãå ããã
https://github.com/testdouble/standard/wiki/IDE:-vscode
- Language Serverãæå¹ã«ãã
- ãããã¯ã®fold, unfoldãªã©ãæå¹ã«ãªã
- ã¤ã³ããªã»ã³ã¹ã«rubyLocate
- F12ã§å®ç¾©ã¸ã£ã³ããã§ããããã«ãªã
- Linterã¯standard
- Formatterã¯rufo
- Debuggerã¯ç¹ã«è¨å®ä¸è¦
settings.jsonã¯ä»¥ä¸ã®ãããªæãã
{ "ruby.lint": { "standard": true, }, "ruby.format": "rufo", "ruby.useLanguageServer": true, "[ruby]": { "editor.tabSize": 2 }, "ruby.languageServer": { "logLevel": "info" }, "ruby.intellisense": "rubyLocate", }
ã³ã¼ãè£å®
ããã¾ã§ã§ãååã«ä¾¿å©ã ããããã«ã³ã¼ãè£å®ã«ã対å¿ãããªãsolargraph gemãå ¥ããã¨ããã
> gem install -N solargraph
solargraphã«ã¯å°ç¨ã®VSCodeãã©ã°ã¤ã³ãç¨æããã¦ããã"Ruby Solargraph"ãã¤ã³ã¹ãã¼ã«ã
https://github.com/castwide/vscode-solargraph
è£å®ã ããããªãã¡ã½ããã®ããã¥ã¡ã³ãããã®å ´ã§è¦ããã®ã便å©ã
ã¾ã¨ã
ã³ã¼ãæ´å½¢ãLintããããã¬ãã³ã¼ãè£å®ã¨ã³ã¼ãã£ã³ã°ã«å¿ è¦ãªæ©è½ãä¸éã使ããããã«ãªã大å便å©ã«ãªã£ãã
ãã®è¾ºãã®ã³ã¼ãã£ã³ã°æ¯æ´æ©è½ãgolangãRustã®ãããªå¾çºã®è¨èªã¨éã£ã¦æ¨æºã§ç¨æããã¦ããªã(ãããã¯é¸æè¢ãå¤ããã¦ã©ãã使ã£ã¦ãããåãããªã)ãããã©ã®gemãå ¥ããã°ããããæ¤è¨¼ããã®ã«ããããæéãããã£ã(æ¢ãã°ä½ãããããã§ããããã¨ã¯åãã£ã¦ããã®ã ã)ã
irbãæè¿ã¯ã³ã¼ãè£å®ãå¼·åã«ãªã£ã¦ããªã使ãããããªã£ããããä¾ãã°ã³ã¼ãæ´å½¢æ©è½ã ãã§ãæ¨æºã§ç¨æããã¦ããã¨ãããå°è±¡ãããããããªãããã ãªãã¨æã£ãã
Rubyã¯æçããè¨èªãªã®ã§ãã®è¾ºãã®å¨è¾ºæ©è½ã®å å®ãããéè¦ãªã®ãããããªã(https://github.com/ruby/debug ãªã©ã®éçºãé²ãã§ããã®ã¯ã¨ã¦ã楽ãã¿ã§ã)ã