mercredi 13 juillet 2016

ruby syntax error :

I have a ruby block that seems to work independently but as I put it in a ruby code sample it fails with syntax error :

code :

9 def get_version(name, user, pass, type, organization, art_module, repos, version)
10  puts case
11  when type.match(/snapshot$/i)
12    p version
13    when version.match(/latest$/i)
14         string_object = open("http://ift.tt/2aaXKk0}", :http_basic_authentication=>["#{user}", "#{pass}"])
15         json_file = JSON.parse(string_object.read)
16         version_array = Array.new
17         json_file["results"].each do |version|
18           version_array.push(version["version"].sub /-.*$/, '')
19         end
20         #p unique_versions=(version_array.uniq).max
21    else
22         p "here"
23         string_object = open("http://ift.tt/2aaXKk0}", :http_basic_authentication=>["#{user}", "#{pass}"])
24         json_file = JSON.parse(string_object.read)
25         version_array = Array.new
26         json_file["results"].each do |version|
27           version_array.push(version["version"].sub /-.*$/, '')
28         end
29         p unique_versions=(version_array.uniq).min
30    end
31  when type.match(/release$/i)
32  ...


SyntaxError
==> default: -----------
==> default: C:\vagrant-chef\a2c27477ebffe71b9594bbbb58557887\cookbooks\dj_productivity_any\providers\dj_artifactory_version.rb:26: syntax error, unexpected keyword_do_block, expecting keyword_end
==> default:          json_file["results"].each do |version|
==> default:                                      ^
==> default: C:\vagrant-chef\a2c27477ebffe71b9594bbbb58557887\cookbooks\dj_productivity_any\providers\dj_artifactory_version.rb:30: syntax error, unexpected keyword_end, expecting end-of-input

Edited to include line numbers

Aucun commentaire:

Enregistrer un commentaire