I am new to Ruby. I am using Visual Studio Code and was wondering if there is a formatter (like the extension Prettier) for Ruby. I would like to use it to indent properly, etc.
Thank you!
Prettier does support Ruby with the plugin-ruby [1] installed but the installation is a little bit tricky. You have to install the Prettier-Ruby-Plugin inside the vscode prettier extensions directory:
cd ~/.vscode/extensions/esbenp.prettier-vscode-1.8.1/
npm install #prettier/plugin-ruby
[1] https://github.com/prettier/plugin-ruby
I think rubocop is good option for it, I use this and is good https://github.com/rubocop-hq/rubocop
With Visual Code, you can use most feature exension of this. Some extensions i think with rails developer must to install are: Ruby, Ruby onrails, Simple Ruby Erb, ruby-linter.. And i think you need install Gitlens to control your project git version.
And i have some config to indent, theme, fonts.... in my github. Hope it can helpful to you.
https://github.com/Hungnv950/dotfiles/blob/master/visualcode/Setting
Related
I'm opening ruby file via RubyMine. IDE suggests installing RuboCop. I accept it, but after a few seconds it shows:
Following gems were not installed: rubocop (1.0.0): Cancelled
Documentation says its problem with interpreter path. Problem is its already set. Even when i try to add it like documentation says, it won't let me, because its already set.
Any ideas what i can do? I have been using VisualStudio Code without issues before it, but Ruby support is pretty poor, i had to use terminal, while for example python has full support and you can just run program with one button.
I've installed Solargraph (which uses Rubocop) for my IDE (Neovim - using the CoC extension). Rubocop warnings are showing, but NameErrors are not detected until I run my ruby files. Is this the default behaviour, or do I need to do something more for configuration?
I'm using Ruby 2.7.2 (with rbenv).
Thanks in advance if you know the answer - I can provide more details if needed.
Simple answer: No. Because rubocop does not run your ruby code, it just parses the files.
So, its your duty to make your code work first, then fix styles with Rubocop :)
Small hint: you can create a github action to run both rubocop and your code on push/deploy
Cheers!
I have no knowledge in Ruby, but I need to run some tests in it. The code is in Ruby and Cucumber. I use intellij on Mac. When I first open intellij cucumber step definition where not recognised from feature file. In terminal I got:
Required ruby-2.1.2 is not installed.
To install do: 'rvm install "ruby-2.1.2"'
but
$ which ruby
/Users/myuser/.rvm/rubies/ruby-2.4.1/bin/ruby
so I run the install command as suggested and now I get
$ which ruby
/Users/myuser/.rvm/rubies/ruby-2.1.2/bin/ruby
Now my feature files connected to step definition as well. I will appreciate if anyone could explain me what happened. What prompted me to downgrade the version of Ruby and how it fixed cucumber.
Make sure you have ruby 2.1.2 set in File -> Settings -> Languages & Frameworks -> Ruby SDK and Gems
What I suspect is happening is you have run rvm use 2.1.2 in the terminal but when your IDE runs something it is using the ruby version set in the settings.
You probably have a .ruby_version file in the project root directory. This will enforce a specific version of Ruby. So the person who put it there is who to ask why the version was restricted like that. There may have been a good reason, such as that's what is being used by all your users.
It has nothing to do with Cucumber. rvm has some kind of operating system hook, I think, that runs whenever you cd into a directory. It looks for its special control fiels such as .ruby_version and .rvmrc file. This page describes this in more detail: https://rvm.io/workflow/projects.
I tried to follow the installation process defined at: http://asciidoctor.org/docs/install-asciidoctor-macosx/#rvm-procedure-recommended but it failed with the error message
Error running 'requirements_osx_brew_update_system ruby-2.3.0',
showing last 15 lines of
/Users/richardcoffre/.rvm/log/1466510618_ruby-2.3.0/update_system.log
Because I am a newbie, but want to use asciidoc format, I need an updated and detailed installation process to install asciidoctor.
Best regards
Richard
Install Homebrew
brew install ruby
Open new terminal tab/window
which gem, it should print /usr/local/bin/gem
gem install asciidoctor
We should probably create a Homebrew package for Asciidoctor, it's unnecessary complicated now.
I am aware this does not exactly answer your question...
An alternative to this installation approach is to use an Application like AsciidoctorFX:
Or even simpler the preview extension for chrome:
If you are a developer, there is a good integration with several build system (maven, gradle, rake, gulp, grunt...). In that case the package manager will download Asciidoctor and the dependencies for you.
I wanted to use SASS on our company's web app but I can't install any programs on production machines. Everything I searched about SASS required you to run an installation program like gem and also required HAML.
I was hoping to find just a script that processes scss files without needing to install anything else.
Well... if you have Ruby available, you could checkout the Git repository of Sass (https://github.com/nex3/sass). Do so by either typing git clone https://github.com/nex3/sass.git or just downloading it.
Then you could use the interactive Ruby console by typing irb. Try to require 'sass/lib/sass' (this one here) and run Sass.compile_file 'my_styles.css'.
Otherwise... why are you trying to do that? You can also install sass locally, run sass --watch on your sass folder and it compiles your scss files automatically into css files - which you can deploy on your production environment.
If you can run java program in your build system, you could use JRuby for compiling sass. See this answer for more details
Here's a solution for using Sass without using the command line or installing dependencies. It works with Windows, OS X, and Linux. It has a graphical interface, and no installer, just unzip and double-click.
http://scout-app.io
You can also use the java library https://github.com/scireum/server-sass which can be embedded into any java based web-app. It will compile sass on the fly and return the resulting css. This is especially useful if the Sass sources change (i.e. for customizing reasons) and an ahead of time compilation is not possible. (Note: I'm the author of the project - and it is also not yet a complete implementation of the Sass standard).
Alternatively, what you could do is:
Install Ruby
Download the Sass Gem
Navigate to download location
Run: gem install sass-3.3.4.gem
Voila! Sass is installed.
Use the online Sass compiler SassMeister. You just have to paste your sass code on the left panel and get the css code on the right.