OMDb API Rotten Tomatoes - api

I believe this may just be a bug in the OMDb API. But I am hoping that someone can point out the errors in my ways.
I am trying to include the Rotten Tomatoes Ratings in a output. But no matter what options I try I don't get anything.
curl http://www.omdbapi.com/?t=Iron+Man&y=&plot=short&tomatoes=true&r=json
Output:
{
:Title => "Iron Man",
:Year => "2008",
:Rated => "PG-13",
:Released => "02 May 2008",
:Runtime => "126 min",
:Genre => "Action, Adventure, Sci-Fi",
:Director => "Jon Favreau",
:Writer => "Mark Fergus (screenplay), Hawk Ostby (screenplay), Art Marcum (screenplay), Matt Holloway (screenplay), Stan Lee (characters), Don Heck (characters), Larry Lieber (characters), Jack Kirby (characters)",
:Actors => "Robert Downey Jr., Terrence Howard, Jeff Bridges, Gwyneth Paltrow",
:Plot => "After being held captive in an Afghan cave, an industrialist creates a unique weaponized suit of armor to fight evil.",
:Language => "English, Persian, Urdu, Arabic, Hungarian",
:Country => "USA",
:Awards => "Nominated for 2 Oscars. Another 17 wins & 52 nominations.",
:Poster => "http://ia.media-imdb.com/images/M/MV5BMTczNTI2ODUwOF5BMl5BanBnXkFtZTcwMTU0NTIzMw##._V1_SX300.jpg",
:Metascore => "79",
:imdbRating => "7.9",
:imdbVotes => "629,489",
:imdbID => "tt0371746",
:Type => "movie",
:Response => "True"
}
Reference:
http://www.omdbapi.com/
Update
In case anyone runs across this (me) again. Here's the expected output with tomatoes:
{
:Title => "Iron Man",
:Year => "2008",
:Rated => "PG-13",
:Released => "02 May 2008",
:Runtime => "126 min",
:Genre => "Action, Adventure, Sci-Fi",
:Director => "Jon Favreau",
:Writer => "Mark Fergus (screenplay), Hawk Ostby (screenplay), Art Marcum (screenplay), Matt Holloway (screenplay), Stan Lee (characters), Don Heck (characters), Larry Lieber (characters), Jack Kirby (characters)",
:Actors => "Robert Downey Jr., Terrence Howard, Jeff Bridges, Gwyneth Paltrow",
:Plot => "After being held captive in an Afghan cave, an industrialist creates a unique weaponized suit of armor to fight evil.",
:Language => "English, Persian, Urdu, Arabic, Hungarian",
:Country => "USA",
:Awards => "Nominated for 2 Oscars. Another 19 wins & 58 nominations.",
:Poster => "http://ia.media-imdb.com/images/M/MV5BMTczNTI2ODUwOF5BMl5BanBnXkFtZTcwMTU0NTIzMw##._V1_SX300.jpg",
:Metascore => "79",
:imdbRating => "7.9",
:imdbVotes => "635,229",
:imdbID => "tt0371746",
:Type => "movie",
:tomatoMeter => "94",
:tomatoImage => "certified",
:tomatoRating => "7.7",
:tomatoReviews => "266",
:tomatoFresh => "249",
:tomatoRotten => "17",
:tomatoConsensus => "Director Jon Favreau and star Robert Downey Jr. make this smart, high impact superhero movie one that even non-comics fans can enjoy.",
:tomatoUserMeter => "91",
:tomatoUserRating => "4.2",
:tomatoUserReviews => "1072111",
:DVD => "30 Sep 2008",
:BoxOffice => "$318.3M",
:Production => "Paramount Pictures",
:Website => "http://www.ironmanmovie.com/",
:Response => "True"
}

Well, you have to wrap your url inside the quote. Otherwise the & causing you the problem by breaking the command on that position.
curl "http://www.omdbapi.com/?t=Iron+Man&y=&plot=short&tomatoes=true&r=json"

Related

how to make user defined routes in rails

i have one doubt in ruby on rails...i have a problem in routes file.i am working for 1 week.but i am not getting a appropriate result.my problem is. i am working on a project called canvas which is a online tutorial.In that project in the course home page it have a side menu called pages.when clicking that it goes to the url. The canvas version is rails 2
http://localhost:3000/courses/1/wiki/front-page
and its routes file for the page is
concern :wikis do
get 'pages' => 'wiki_pages#pages_index'
get 'pages/:wiki_page_id' => 'wiki_pages#show_page', :wiki_page_id => /[^\/]+/, :as => :named_page
get 'pages/:wiki_page_id/edit' => 'wiki_pages#edit_page', :wiki_page_id => /[^\/]+/, :as => :edit_named_page
resources :wiki_pages, :path => :wiki do
match 'revisions/latest' => 'wiki_page_revisions#latest_version_number', :as => :latest_version_number
resources :wiki_page_revisions, :path => :revisions
end
match 'wiki/:id' => 'wiki_pages#show', :as => :named_wiki_page, :id => /[^\/]+/
end
my task is to add two more links to side menu named as faq and career without controller and view. i have put the routes for faq and career routes as below:
concern :faq do
get 'faq' => 'wiki_pages#pages_index'
get 'faq/:wiki_page_id' => 'wiki_pages#show_page', :wiki_page_id => /[^\/]+/, :as => :named_page
get 'faq/:wiki_page_id/edit' => 'wiki_pages#edit_page', :wiki_page_id => /[^\/]+/, :as => :edit_named_page
resources :wiki_pages, :path => :wiki do
match 'revisions/latest' => 'wiki_page_revisions#latest_version_number', :as => :latest_version_number
resources :wiki_page_revisions, :path => :revisions
end
match 'faq/:id' => 'wiki_pages#show', :as => :named_faq_page, :id => /[^\/]+/
end
the career routes is
concern :career do
get 'career' => 'wiki_pages#pages_index'
get 'career/:wiki_page_id' => 'wiki_pages#show_page', :wiki_page_id => /[^\/]+/, :as => :named_page
get 'career/:wiki_page_id/edit' => 'wiki_pages#edit_page', :wiki_page_id => /[^\/]+/, :as => :edit_named_page
resources :wiki_pages, :path => :wiki do
match 'revisions/latest' => 'wiki_page_revisions#latest_version_number', :as => :latest_version_number
resources :wiki_page_revisions, :path => :revisions
end
match 'career/:id' => 'wiki_pages#show', :as => :named_wiki_page, :id => /[^\/]+/
end
using the above wiki_controller i want to change the url like below
when i clicking the faq the url must like this:
http://localhost:3000/courses/1/faq/front-page
but the actions are wikipages_index and show.
when i clicked the career link it must be.
http://localhost:3000/courses/1/career/front-page
like this the url must come for all index and show,edit and update.plz apologize me that it is not an standard english.can anybody help me.
thanks in advance
with regards
saran

Extending YAML alias anchors

I'm trying to construct dynamic YAML to return strings, I'm wondering if it is possible to do something like this with YAML?
en:
occupation: "Studying #{department} at %{university} %{*speciality}"
speciality: &speciality "specialising in %{subject}"
expected output
I18n.t(:occupation, :department => "Computer Science",
:university => "Staffordshire University",
:subject => "Ruby")
#=> "Studying Computer Science at Staffordshire University specialising in Ruby"
I18n.t(:occupation, :department => "Computer Science",
:university => "Staffordshire University",
:subject => nil)
#=> "Studying Computer Science at Staffordshire University"
Currently the only way I think this may be posible is
subject = "Ruby"
I18n.t(:occupation, :department => "Computer Science",
:university => "Staffordshire University",
:subject => (
I18n.t(:speciality, :subject => subject) if subject
))
#=> "Studying Computer Science at Staffordshire University specialising in Ruby"

Can't create Custom inputs for some (Text, Booleans, ...) types, with SimpleForm

I can't figure out why this is not working as it should - or - I'm missing something important ?
Here's the list of the mapped types from simple_form / lib / simple_form / form_builder.rb:
map_type :text, :to => SimpleForm::Inputs::TextInput
map_type :file, :to => SimpleForm::Inputs::FileInput
map_type :string, :email, :search, :tel, :url, :to => SimpleForm::Inputs::StringInput
map_type :password, :to => SimpleForm::Inputs::PasswordInput
map_type :integer, :decimal, :float, :to => SimpleForm::Inputs::NumericInput
map_type :range, :to => SimpleForm::Inputs::RangeInput
map_type :select, :radio, :check_boxes, :to => SimpleForm::Inputs::CollectionInput
map_type :date, :time, :datetime, :to => SimpleForm::Inputs::DateTimeInput
map_type :country, :time_zone, :to => SimpleForm::Inputs::PriorityInput
map_type :boolean, :to => SimpleForm::Inputs::BooleanInput
First problem, I can extend StringInput class as:
#app/inputs/string_input.rb
class StringInput < SimpleForm::Inputs::StringInput
def input
if #builder.show?
content_tag(:p, #builder.object[attribute_name], :class => :show)
else
super
end
end
end
(I've extended the builder with a show? method to detect the context: action == 'show')
This is working most of the time but not when :as => :string is present :
<%= f.input :estimated_duration_rendered,
:as => :string,
:label => mt(:estimated_duration),
:hint => mt(:estimated_duration_hint),
:error => false,
:required => false,
:input_html => { :class => :digits_11, :placeholder => mt(:estimated_duration_placeholder), :value => format_duration(resource.estimated_duration, true) }
%>
Second problem, I can create custom inputs for StringInput, DateTimeInput, CollectionInput and BooleanInput but all the others are not working. For example:
#app/inputs/text_input.rb
class TextInput < SimpleForm::Inputs::TextInput
def input
if #builder.show?
"I will never show..."
else
super
end
end
end
Even if I have this helper in my form:
<%= f.input :description,
:label => mt(:description),
:hint => mt(:description_hint, :max => MyModel::DESC_MAX_LENGTH),
:input_html => { :class => :large, :rows => 8, :cols => 1, :maxlength => MyModel::DESC_MAX_LENGTH, :placeholder => mt(:description_placeholder) },
:error => false
%>
Of course, description has a text data type.
What Am I doing wrong ?
Thank you.
Fro
Well, to use this functionality you just need the 1.5.1 version of SimpleForm. :-)

How to seed a Rails 3.1 app with scoped mass assignment

How does Rails 3.1 (RC4) and scoped mass assignment expect us to work with seeds.rb when loading a list of data.
For example. I normally have something like:
City.create([
{ :name => 'Chicago' },
{ :name => 'Copenhagen' },
...
])
Which creates over 100+ cities. this doesn't work anymore since the City model has a scoped mass assignment :as => :admin.
As far as I know, the .create() method does not allow us to throw in :as => :admin.
Only .new() and .update_attributes() allows us to do this with :as => :admin.
So doing something like (below) is cumbersome (especially for 100+ records):
city1 = City.new({ :name => 'Chicago' }, :as => :admin)
city1.save
city2 = City.new({ :name => 'Copenhagen' }, :as => :admin)
city2.save
Any thoughts on this?
You can do the following:
City.create([
{ :name => 'Chicago' },
{ :name => 'Copenhagen' },
...
], :without_protection => true)
This completely overrides the mass assignment protection - so be sure to only use this in say the seeds.

Rails 3 Routing question

I have an issue where I have an admin subdomain setup in the routes like so:
constraints :subdomain => 'admin' do
scope :module => "admin" do
match 'articles/:id/', :to => 'articles#show'
resources :articles, :events do
collection do
post :update_attribute_on_the_spot
end
end
root :to => "dashboard#index"
end
end
Then after that on articles for the main site I have:
resources :articles, :events, :george
match '/:year/:month/:day/:slug', :to => 'articles#show', :as => "article", :constraints => {:year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/ }
match '/event/:year/:month/:day/:slug', :to => 'events#show', :as => "event", :constraints => {:year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/ }
I am wondering how I make sure the main site routes are not used when the admin subdomain routes are in effect, as of now when going to the admin section articles show is mapped to the main site route and therefore the admin routes will not function unless that route is removed.
If anyone can show me the best way around this issue it would be great.
Thanks!
I did not realize declaring something with :as would overwrite any other route so simply:
match '/:year/:month/:day/:slug', :to => 'articles#show', :constraints => {:year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/ }
Fixed everything!