This works on one machine with Ruby but not another.
Code:
describe 'testing reverse string different ways' do
let :thing {'cba321'}
it 'the system method' do
source = '123abc'
result = source.reverse
expect(result).to eq 'cba321'
end
end
Error:
SyntaxError:
/home/michael/Dropbox/90_2019/work/code/ruby__rails/ruby/reverse_string_tests_timing/test_spec.rb:12: syntax error, une
xpected '{', expecting keyword_end
let :thing {'cba321'}
^
/home/michael/Dropbox/90_2019/work/code/ruby__rails/ruby/reverse_string_tests_timing/test_spec.rb:12: syntax error, une
xpected '}', expecting end-of-input
let :thing {'cba321'}
In Ruby 2.4.1 not having parens in the let was allowed but in Ruby 2.5.1 it is not.
So the fix is to add parens to the let, e.g.
change
let :source {'cba321'}
to
let (:source) {'cba321'}
I'm writing an extension for Redcarpet for a Jekyll-powered website. I want to use {x|y} as a tag in markdown that evaluates to the HTML <ruby> tag (and its associates). I wrote this class as per Jekyll's guide, Redcarpet's guide, and this guide on how to do so:
class Jekyll::Converters::Markdown::HotelDown < Redcarpet::Render::HTML
def preprocess(doc)
s = "<ruby><rb>\\1</rb><rp>(</rp><rt>\\2</rt><rp>)</rp></ruby>"
doc.gsub!(/\[([\s\S]+)\|([\s\S]+)\]/, s)
doc
end
end
But, I seem to be getting a couple errors when I run bundle exec jekyll serve:
Configuration file: C:/Users/Alex/OneDrive/codes/hotelc.me/hotelc.me/_config.yml
plugin_manager.rb:58:in `require': HotelDown.rb:4: syntax error, unexpected tIDENTIFIER, expecting ')' (SyntaxError)
doc.gs-ub!(/\[([\-s\S]+)\|([-\s\S]+)\]/-, s)
^
HotelDown.rb:4: syntax error, unexpected ')', expecting '='
doc.gs-ub!(/\[([\-s\S]+)\|([-\s\S]+)\]/-, s)
^
It seems there's something wrong with my syntax (an extra space, missing parentheses, or something like that). Is there something I've missed?
Your code has some special characters which is causing this error:
syntax error, unexpected ')', expecting '='
doc.gs-ub!(/\[([\-s\S]+)\|([-\s\S]+)\]/-, s)
Replace your current code with this piece of code:
class Jekyll::Converters::Markdown::HotelDown < Redcarpet::Render::HTML
#Overriding the preprocess() function
def preprocess(doc)
s = "<ruby><rb>\\1</rb><rp>(</rp><rt>\\2</rt><rp>)</rp></ruby>"
doc.gsub!(/\[([\s\S]+)\|([\s\S]+)\]/, s)
doc
end
end
markdown = Redcarpet::Markdown.new(HotelDown)
and it should work!
I've followed the steps on the Getting Started with SASS page to install Foundation 5 and the required components.
I am now trying to install Foundation into a project folder, via Terminal (i.e. Foundation new myProject).
Terminal returns a long list of errors that I've pasted in below.
No idea what this issue could be -- any ideas are greatly appreciated.
List of directories inRuby/Gems/1.8/gems/:
chunky_png-1.3.3
compass-1.0.1
compass-core-1.0.1
compass-import-once-1.0.5
ffi-1.9.6
foundation-1.0.4
multi_json-1.10.1
rb-fsevent-0.9.4
rb-inotofy-0.9.5
sass-3.4.9
thor-0.19.1
zurb-foundation-4.3.2
The errors:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': /Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:44: syntax error, unexpected ':', expecting ')' (SyntaxError)
run("gem install compass", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:44: Can't assign to true
run("gem install compass", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:44: syntax error, unexpected ':', expecting '='
run("gem install compass", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:45: syntax error, unexpected ':', expecting ')'
... run("rbenv rehash", capture: true, verbose: false) if whic...
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:45: Can't assign to true
..."rbenv rehash", capture: true, verbose: false) if which("rbe...
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:45: syntax error, unexpected ':', expecting '='
...hash", capture: true, verbose: false) if which("rbenv")
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:94: syntax error, unexpected ':', expecting ')'
run("compass compile", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:94: Can't assign to true
run("compass compile", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:94: syntax error, unexpected ':', expecting '='
run("compass compile", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:97: syntax error, unexpected ':', expecting ')'
run("compass compile", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:97: Can't assign to true
run("compass compile", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:97: syntax error, unexpected ':', expecting '='
run("compass compile", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:114: syntax error, unexpected ':', expecting kEND
option :libsass, type: :boolean, default: false
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:115: syntax error, unexpected ':', expecting kEND
option :version, type: :string
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:127: syntax error, unexpected ':', expecting ')'
...one #{repo} #{name}", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:127: Can't assign to true
...repo} #{name}", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:127: syntax error, unexpected ':', expecting '='
...ame}", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:130: syntax error, unexpected ':', expecting ')'
run("bower install", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:130: Can't assign to true
run("bower install", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:130: syntax error, unexpected ':', expecting '='
run("bower install", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:132: syntax error, unexpected ':', expecting ')'
run("git remote rm origin", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:132: Can't assign to true
run("git remote rm origin", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:132: syntax error, unexpected ':', expecting '='
run("git remote rm origin", capture: true, verbose: false)
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:149: syntax error, unexpected ':', expecting kEND
option :version, type: :string
^
/Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli/generator.rb:159: syntax error, unexpected $end, expecting kEND
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/foundation-1.0.4/lib/foundation/cli.rb:2
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/foundation-1.0.4/bin/foundation:3
from /usr/bin/foundation:19:in `load'
from /usr/bin/foundation:19
The obvious reason that I was overlooking is the Ruby version. The Foundation docs state Ruby 1.9+ is required, and I had only Ruby 1.8 (running OS X 10.8.5).
I'm running into this syntax error with the below code and I can't figure out why ruby is complaining about it.
def user_list
server = Lumberg::Whm::Server.new(
host: "localhost",
hash: IO.read("/root/.accesshash")
)
results = server.account.list
accounts = result[:params][:acct].map {|a| a["user"] }
end
end
Syntax error is as follows:
# bundle exec bin/userscan
bin/userscan:3:in `require': /usr/src/userscan/lib/userscan.rb:131: syntax error, unexpected ':', expecting ')' (SyntaxError)
host: "localhost",
^
/usr/src/userscan/lib/userscan.rb:131: syntax error, unexpected ',', expecting kEND
/usr/src/userscan/lib/userscan.rb:133: syntax error, unexpected ')', expecting kEND
from bin/userscan:3
From what I know, the part it's complaining about -should- be okay. Obviously, the semi-colon is actually supposed to be there and the parenthesis should encompass the entirety of the two lines. I've played around with it a bit, but I just keep making it worse rather than better.
Any assistance with what I'm messing up here would be appreciated.
the syntax host: ".." is new to ruby 1.9. If you are using ruby 1.8, you must use the old syntax:
server = Lumberg::Whm::Server.new(
:host => "localhost",
:hash => IO.read("/root/.accesshash") )
I am trying to deploy a rails 3.2 app where the ruby version is 1.8. I could workaround a few hash syntax troubles I had, but there is still one I can't get over with:
Note I hired a hosting service that won't install ruby 1.9.
The error is
from {app_path}/config/environment.rb:5
[ pid=586526 thr=203092280 file=utils.rb:176 time=2012-05-04 15:32:29.667 ]: *** Exception SyntaxError in PhusionPassenger::Rack::ApplicationSpawner ({app_path}/config/initializers/wrap_parameters.rb:8: syntax error, unexpected tASSOC, expecting '}'
{app_path}/config/initializers/wrap_parameters.rb:8: warning: don't put space before argument parentheses
{app_path}/config/initializers/wrap_parameters.rb:8: warning: don't put space before argument parentheses
from {app_path}/config/environment.rb:5
[ pid=539635 thr=202883380 file=utils.rb:176 time=2012-05-04 14:30:21.570 ]: *** Exception SyntaxError in PhusionPassenger::Rack::ApplicationSpawner ({app_path}/config/initializers/wrap_parameters.rb:8: syntax error, unexpected ':', expecting kEND
from {app_path}/config/environment.rb:5
[ pid=539635 thr=202883380 file=utils.rb:176 time=2012-05-04 14:29:31.744 ]: *** Exception SyntaxError in PhusionPassenger::Rack::ApplicationSpawner ({app_path}/config/initializers/wrap_parameters.rb:8: syntax error, unexpected ':', expecting kEND
The file is config/initializers/wrap_parameters.rb and the content is like follows:
ActiveSupport.on_load(:action_controller) do
# it was originally
# wrap_parameters format: [:json] # ruby 1.9 syntax
# the follow line is line 8
wrap_parameters :format => [:json] # ruby 1.8 syntax
# i already tried
# wrap_parameters {:format => [:json]}
# wrap_parameters({:format => [:json]})
# wrap_parameters(:format => [:json])
end
# Disable root element in JSON by default.
ActiveSupport.on_load(:active_record) do
self.include_root_in_json = false
end
Here is config/enviroment.rb
#config/environment.rb
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Flog::Application.initialize!
I am a few hours trying to get rid of this issue.
Thank you in advace