added rake command
This commit is contained in:
parent
5a8fd39e6b
commit
f251500aa4
1
Gemfile
1
Gemfile
@ -6,6 +6,7 @@ gem "meta_search", '>= 1.1.0.pre'
|
||||
gem "rails_config"
|
||||
gem "savon", "~> 2.0"
|
||||
gem "gyoku", "~> 1.0"
|
||||
gem "pry"
|
||||
|
||||
group :assets do
|
||||
gem "coffee-rails", "~> 3.2.1"
|
||||
|
@ -39,6 +39,7 @@ GEM
|
||||
railties (>= 3.0)
|
||||
sass-rails (>= 3.2)
|
||||
chunky_png (1.3.0)
|
||||
coderay (1.1.0)
|
||||
coffee-rails (3.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (~> 3.2.0)
|
||||
@ -81,6 +82,7 @@ GEM
|
||||
activerecord (~> 3.1)
|
||||
activesupport (~> 3.1)
|
||||
polyamorous (~> 0.5.0)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.5.2)
|
||||
multi_json (1.8.4)
|
||||
@ -90,6 +92,10 @@ GEM
|
||||
polyamorous (0.5.0)
|
||||
activerecord (~> 3.0)
|
||||
polyglot (0.3.3)
|
||||
pry (0.9.12.6)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
slop (~> 3.4)
|
||||
rack (1.4.5)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
@ -131,6 +137,7 @@ GEM
|
||||
nokogiri (>= 1.4.0)
|
||||
nori (~> 2.3.0)
|
||||
wasabi (~> 3.2.2)
|
||||
slop (3.4.7)
|
||||
sprockets (2.2.2)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
@ -167,6 +174,7 @@ DEPENDENCIES
|
||||
jquery-rails (= 2.3.0)
|
||||
maskedinput-rails
|
||||
meta_search (>= 1.1.0.pre)
|
||||
pry
|
||||
rails (= 3.2.12)
|
||||
rails_config
|
||||
sass-rails (~> 3.2.3)
|
||||
|
@ -15,11 +15,5 @@
|
||||
//= require twitter/bootstrap
|
||||
//= require maskedinput
|
||||
//= require chosen-jquery
|
||||
//= require handlebars
|
||||
//= require ember
|
||||
//= require ember-data
|
||||
//= require_self
|
||||
//= require listpush
|
||||
//= require_tree .
|
||||
|
||||
ListPushApp = Ember.Application.create();
|
||||
|
31
app/assets/stylesheets/rest_api.css
Normal file
31
app/assets/stylesheets/rest_api.css
Normal file
@ -0,0 +1,31 @@
|
||||
body { background-color: #5f7395; color: #333; }
|
||||
|
||||
body, p, ol, ul, td {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
a { color: #000; }
|
||||
a:visited { color: #666; }
|
||||
a:hover { color: #fff; background-color:#000; }
|
||||
|
||||
#main {
|
||||
background-color: #fff;
|
||||
border: solid #000 1px;
|
||||
margin: 5em;
|
||||
height: 30em;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
#notice {
|
||||
background-color: #e1facf;
|
||||
border: solid #97C36d 1px;
|
||||
padding: 0.5em;
|
||||
}
|
@ -1,4 +1,10 @@
|
||||
class LocalezeCategory < ActiveRecord::Base
|
||||
attr_accessible :name
|
||||
has_and_belongs_to_many :list_entries
|
||||
|
||||
def self.find_or_create_by_name(name, &block)
|
||||
obj = self.find_or_create_by_name( name ) || self.new(:name => name)
|
||||
yield obj
|
||||
obj.save
|
||||
end
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ class LocalezeClient
|
||||
def check(listing)
|
||||
value = record_to_xml(listing, true)
|
||||
query = @client.call(:query, message: message(:add, value, :check))
|
||||
result = get_deep_value(query)
|
||||
result = get_deep_value(query)['Response']
|
||||
check_successful?(result['ErrorCode']) ? true : result['ErrorMessage']
|
||||
end
|
||||
|
||||
@ -17,7 +17,7 @@ class LocalezeClient
|
||||
def create(listing)
|
||||
value = record_to_xml(listing, true)
|
||||
query = @client.call(:query, message: message(:add, value, :create))
|
||||
result = get_deep_value(query)
|
||||
result = get_deep_value(query)['Response']
|
||||
status = create_successful?(result)
|
||||
handle_status(status)
|
||||
end
|
||||
@ -32,8 +32,7 @@ class LocalezeClient
|
||||
# make a call to localeze to get a list of all the categories available
|
||||
def categories!
|
||||
query = @client.call(:query, message: message(:query, 'ACTIVEHEADINGS', :category))
|
||||
headings = get_heading(query)
|
||||
headings['ActiveHeadings']['Heading']
|
||||
headings = get_deep_value(query)['ActiveHeadings']['Heading']
|
||||
end
|
||||
|
||||
# Not sure why, but Localeze returns either an ErrorMessage or a Validator with a Resolution if there's an error.
|
||||
@ -49,9 +48,9 @@ class LocalezeClient
|
||||
# The value that localeze gives us is very deep, this method
|
||||
# cleans that up a little in the implementation depending on the element
|
||||
def get_deep_value(query)
|
||||
Hash.from_xml(query.to_hash[:query_response][:response][:result][:element][:value].to_s)['Response']
|
||||
Hash.from_xml(query.to_hash[:query_response][:response][:result][:element][:value].to_s)
|
||||
end
|
||||
|
||||
|
||||
# This is a helper method to generate the giant dictionary you send as a message.
|
||||
# Rather than needing to supply this dictionary every time, all you need to supply is the Action Key,
|
||||
# the value to send, and the ElementId
|
||||
|
16
lib/tasks/localeze_categories.rake
Normal file
16
lib/tasks/localeze_categories.rake
Normal file
@ -0,0 +1,16 @@
|
||||
namespace :localeze do
|
||||
desc "Update and Get new LocalezeCategories"
|
||||
task :import => :environment do
|
||||
before = LocalezeCategory.count
|
||||
categories = LocalezeClient.new.categories
|
||||
ActiveRecord::Base.transaction do
|
||||
categories.each do |cat|
|
||||
category = LocalezeCategory.where(name: cat).first_or_create!
|
||||
end
|
||||
|
||||
if before < LocalezeCategory.count
|
||||
puts "Imported #{LocalezeCategory.count - before} categories."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user