L
Laran Evans
I have this text:
<request>
<post>
<category-id><%= params['post']['category_id'] %></category-id>
<title><%= params['post']['title'] %></title>
<body><%= params['post']['body'] %></body>
<extended-body><%= params['post']['extended_body'] %></extended-
body>
<private><%= params['post']['private'] %></private>
</post>
<% if params['notify'] then %>
<% params['notify'].each do |person_id| %>
<notify><%= person_id %></notify>
<% end %>
<% end %>
<% if params['attachments'] then %>
<% params['attachments'].each do |attachment| %>
<attachments>
<name><%= attachment['name'] %></name>
<file>
<file><%= attachment['file']['temp_id'] %></file>
<content-type><%= attachment['file']['content_type'] %></
content-type>
<original_filename><%= attachment['file']
['original_filename'] %></original-filename>
</file>
</attachments>
<% end %>
<% end %>
</request>
What I need to do is extract all of the variables used in order to
learn the variables, and their structure (array/hash vs. simple value)
used to render the view.
So, using the snippet above, I would learn that there is:
- a "post" variable which is a hash, expected to have the keys
"category_id", "title", "body", "extended_body" and "private".
- a "notify" variable which is an array (indicated by the fact that
it's iterated over with the .each) of simple values (i.e. it's not a
multi-dimensional array, or an array of hashes)
- a "attachments" variable which is an array (again indicated by the
fact that it's iterated over with the .each) of hashes (indicated by
the fact that each element of the "attachments" array is referenced
with hash syntax, i.e. "attachment['name']) and that the value
corresponding to the key "file" is also a hash expected to have the
keys "temp_id", "content_type" and "original_filename".
Is there a tool available to allow me to do this? I haven't been able to
find anything.
<request>
<post>
<category-id><%= params['post']['category_id'] %></category-id>
<title><%= params['post']['title'] %></title>
<body><%= params['post']['body'] %></body>
<extended-body><%= params['post']['extended_body'] %></extended-
body>
<private><%= params['post']['private'] %></private>
</post>
<% if params['notify'] then %>
<% params['notify'].each do |person_id| %>
<notify><%= person_id %></notify>
<% end %>
<% end %>
<% if params['attachments'] then %>
<% params['attachments'].each do |attachment| %>
<attachments>
<name><%= attachment['name'] %></name>
<file>
<file><%= attachment['file']['temp_id'] %></file>
<content-type><%= attachment['file']['content_type'] %></
content-type>
<original_filename><%= attachment['file']
['original_filename'] %></original-filename>
</file>
</attachments>
<% end %>
<% end %>
</request>
What I need to do is extract all of the variables used in order to
learn the variables, and their structure (array/hash vs. simple value)
used to render the view.
So, using the snippet above, I would learn that there is:
- a "post" variable which is a hash, expected to have the keys
"category_id", "title", "body", "extended_body" and "private".
- a "notify" variable which is an array (indicated by the fact that
it's iterated over with the .each) of simple values (i.e. it's not a
multi-dimensional array, or an array of hashes)
- a "attachments" variable which is an array (again indicated by the
fact that it's iterated over with the .each) of hashes (indicated by
the fact that each element of the "attachments" array is referenced
with hash syntax, i.e. "attachment['name']) and that the value
corresponding to the key "file" is also a hash expected to have the
keys "temp_id", "content_type" and "original_filename".
Is there a tool available to allow me to do this? I haven't been able to
find anything.