Skip to content

Commit

Permalink
change hash syntax for ruby >= 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyank Gupta committed Jun 3, 2016
1 parent 6f7e4c8 commit 90bdd84
Show file tree
Hide file tree
Showing 555 changed files with 2,533 additions and 2,538 deletions.
2 changes: 1 addition & 1 deletion api/Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))

gem 'spree_core', :path => '../core'
gem 'spree_core', path: '../core'

gemspec
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/v1/addresses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def update
@address = find_address

if @address.update_attributes(address_params)
respond_with(@address, :default_template => :show)
respond_with(@address, default_template: :show)
else
invalid_resource!(@address)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def update
inventory_unit.transaction do
if inventory_unit.update_attributes(inventory_unit_params)
fire
render :show, :status => 200
render :show, status: 200
else
invalid_resource!(inventory_unit)
end
Expand All @@ -35,8 +35,8 @@ def prepare_event

unless inventory_unit.respond_to?(can_event) &&
inventory_unit.send(can_event)
render :text => { :exception => "cannot transition to #{@event}" }.to_json,
:status => 200
render text: { exception: "cannot transition to #{@event}" }.to_json,
status: 200
false
end
end
Expand Down
4 changes: 2 additions & 2 deletions api/app/controllers/spree/api/v1/option_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create
authorize! :create, Spree::OptionType
@option_type = Spree::OptionType.new(option_type_params)
if @option_type.save
render :show, :status => 201
render :show, status: 201
else
invalid_resource!(@option_type)
end
Expand All @@ -41,7 +41,7 @@ def update
def destroy
@option_type = Spree::OptionType.accessible_by(current_ability, :destroy).find(params[:id])
@option_type.destroy
render :text => nil, :status => 204
render text: nil, status: 204
end

private
Expand Down
6 changes: 3 additions & 3 deletions api/app/controllers/spree/api/v1/option_values_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module V1
class OptionValuesController < Spree::Api::BaseController
def index
if params[:ids]
@option_values = scope.where(:id => params[:ids])
@option_values = scope.where(id: params[:ids])
else
@option_values = scope.ransack(params[:q]).result.distinct
end
Expand All @@ -23,7 +23,7 @@ def create
authorize! :create, Spree::OptionValue
@option_value = scope.new(option_value_params)
if @option_value.save
render :show, :status => 201
render :show, status: 201
else
invalid_resource!(@option_value)
end
Expand All @@ -41,7 +41,7 @@ def update
def destroy
@option_value = scope.accessible_by(current_ability, :destroy).find(params[:id])
@option_value.destroy
render :text => nil, :status => 204
render text: nil, status: 204
end

private
Expand Down
10 changes: 5 additions & 5 deletions api/app/controllers/spree/api/v1/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ def index
end

@products = @products.distinct.page(params[:page]).per(params[:per_page])
expires_in 15.minutes, :public => true
expires_in 15.minutes, public: true
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
respond_with(@products)
end

def show
@product = find_product(params[:id])
expires_in 15.minutes, :public => true
expires_in 15.minutes, public: true
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
headers['Surrogate-Key'] = "product_id=1"
respond_with(@product)
Expand Down Expand Up @@ -69,7 +69,7 @@ def create
@product = Core::Importer::Product.new(nil, product_params, options).create

if @product.persisted?
respond_with(@product, :status => 201, :default_template => :show)
respond_with(@product, status: 201, default_template: :show)
else
invalid_resource!(@product)
end
Expand All @@ -83,7 +83,7 @@ def update
@product = Core::Importer::Product.new(@product, product_params, options).update

if @product.errors.empty?
respond_with(@product.reload, :status => 200, :default_template => :show)
respond_with(@product.reload, status: 200, default_template: :show)
else
invalid_resource!(@product)
end
Expand All @@ -93,7 +93,7 @@ def destroy
@product = find_product(params[:id])
authorize! :destroy, @product
@product.destroy
respond_with(@product, :status => 204)
respond_with(@product, status: 204)
end

private
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/v1/stock_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def stock_location
end

def scope
includes = {:variant => [{ :option_values => :option_type }, :product] }
includes = { variant: [{ option_values: :option_type }, :product] }
@stock_location.stock_items.accessible_by(current_ability, :read).includes(includes)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def update
def destroy
authorize! :destroy, stock_location
stock_location.destroy
respond_with(stock_location, :status => 204)
respond_with(stock_location, status: 204)
end

private
Expand Down
8 changes: 4 additions & 4 deletions api/app/controllers/spree/api/v1/taxonomies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create
authorize! :create, Taxonomy
@taxonomy = Taxonomy.new(taxonomy_params)
if @taxonomy.save
respond_with(@taxonomy, :status => 201, :default_template => :show)
respond_with(@taxonomy, status: 201, default_template: :show)
else
invalid_resource!(@taxonomy)
end
Expand All @@ -32,7 +32,7 @@ def create
def update
authorize! :update, taxonomy
if taxonomy.update_attributes(taxonomy_params)
respond_with(taxonomy, :status => 200, :default_template => :show)
respond_with(taxonomy, status: 200, default_template: :show)
else
invalid_resource!(taxonomy)
end
Expand All @@ -41,13 +41,13 @@ def update
def destroy
authorize! :destroy, taxonomy
taxonomy.destroy
respond_with(taxonomy, :status => 204)
respond_with(taxonomy, status: 204)
end

private

def taxonomies
@taxonomies = Taxonomy.accessible_by(current_ability, :read).order('name').includes(:root => :children).
@taxonomies = Taxonomy.accessible_by(current_ability, :read).order('name').includes(root: :children).
ransack(params[:q]).result.
page(params[:page]).per(params[:per_page])
end
Expand Down
6 changes: 3 additions & 3 deletions api/app/controllers/spree/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create
authorize! :create, Spree.user_class
@user = Spree.user_class.new(user_params)
if @user.save
respond_with(@user, :status => 201, :default_template => :show)
respond_with(@user, status: 201, default_template: :show)
else
invalid_resource!(@user)
end
Expand All @@ -30,7 +30,7 @@ def create
def update
authorize! :update, user
if user.update_attributes(user_params)
respond_with(user, :status => 200, :default_template => :show)
respond_with(user, status: 200, default_template: :show)
else
invalid_resource!(user)
end
Expand All @@ -39,7 +39,7 @@ def update
def destroy
authorize! :destroy, user
user.destroy
respond_with(user, :status => 204)
respond_with(user, status: 204)
end

private
Expand Down
6 changes: 3 additions & 3 deletions api/app/controllers/spree/api/v1/zones_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create
authorize! :create, Zone
@zone = Zone.new(map_nested_attributes_keys(Spree::Zone, zone_params))
if @zone.save
respond_with(@zone, :status => 201, :default_template => :show)
respond_with(@zone, status: 201, default_template: :show)
else
invalid_resource!(@zone)
end
Expand All @@ -16,7 +16,7 @@ def create
def destroy
authorize! :destroy, zone
zone.destroy
respond_with(zone, :status => 204)
respond_with(zone, status: 204)
end

def index
Expand All @@ -31,7 +31,7 @@ def show
def update
authorize! :update, zone
if zone.update_attributes(map_nested_attributes_keys(Spree::Zone, zone_params))
respond_with(zone, :status => 200, :default_template => :show)
respond_with(zone, status: 200, default_template: :show)
else
invalid_resource!(zone)
end
Expand Down
2 changes: 1 addition & 1 deletion api/app/models/spree/api_configuration.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Spree
class ApiConfiguration < Preferences::Configuration
preference :requires_authentication, :boolean, :default => true
preference :requires_authentication, :boolean, default: true
end
end
2 changes: 1 addition & 1 deletion api/app/views/spree/api/errors/invalid_api_key.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object false
node(:error) { I18n.t(:invalid_api_key, :key => api_key, :scope => "spree.api") }
node(:error) { I18n.t(:invalid_api_key, key: api_key, scope: "spree.api") }
2 changes: 1 addition & 1 deletion api/app/views/spree/api/errors/invalid_resource.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
object false
node(:error) { I18n.t(:invalid_resource, :scope => "spree.api") }
node(:error) { I18n.t(:invalid_resource, scope: "spree.api") }
node(:errors) { @resource.errors.to_hash }
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object false
node(:error) { I18n.t(:must_specify_api_key, :scope => "spree.api") }
node(:error) { I18n.t(:must_specify_api_key, scope: "spree.api") }
2 changes: 1 addition & 1 deletion api/app/views/spree/api/errors/not_found.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object false
node(:error) { I18n.t(:resource_not_found, :scope => "spree.api") }
node(:error) { I18n.t(:resource_not_found, scope: "spree.api") }
2 changes: 1 addition & 1 deletion api/app/views/spree/api/errors/unauthorized.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object false
node(:error) { I18n.t(:unauthorized, :scope => "spree.api") }
node(:error) { I18n.t(:unauthorized, scope: "spree.api") }
2 changes: 1 addition & 1 deletion api/app/views/spree/api/v1/countries/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object @country
attributes *country_attributes
child :states => :states do
child states: :states do
attributes :id, :name, :abbr, :country_id
end
4 changes: 2 additions & 2 deletions api/app/views/spree/api/v1/line_items/show.v1.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ node(:total) { |li| li.total }
child :variant do
extends "spree/api/v1/variants/small"
attributes :product_id
child(:images => :images) { extends "spree/api/v1/images/show" }
child(images: :images) { extends "spree/api/v1/images/show" }
end

child :adjustments => :adjustments do
child adjustments: :adjustments do
extends "spree/api/v1/adjustments/show"
end
2 changes: 1 addition & 1 deletion api/app/views/spree/api/v1/option_types/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object @option_type
attributes *option_type_attributes
child :option_values => :option_values do
child option_values: :option_values do
attributes *option_value_attributes
end
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object false
node(:errors) { [I18n.t(:invalid_shipping_method, :scope => "spree.api.order")] }
node(:errors) { [I18n.t(:invalid_shipping_method, scope: "spree.api.order")] }
2 changes: 1 addition & 1 deletion api/app/views/spree/api/v1/orders/payment.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
child :available_payment_methods => :payment_methods do
child available_payment_methods: :payment_methods do
attributes :id, :name, :method_type
end
18 changes: 9 additions & 9 deletions api/app/views/spree/api/v1/orders/show.v1.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ if lookup_context.find_all("spree/api/v1/orders/#{root_object.state}").present?
extends "spree/api/v1/orders/#{root_object.state}"
end

child :billing_address => :bill_address do
child billing_address: :bill_address do
extends "spree/api/v1/addresses/show"
end

child :shipping_address => :ship_address do
child shipping_address: :ship_address do
extends "spree/api/v1/addresses/show"
end

child :line_items => :line_items do
child line_items: :line_items do
extends "spree/api/v1/line_items/show"
end

child :payments => :payments do
child payments: :payments do
attributes *payment_attributes

child :payment_method => :payment_method do
child payment_method: :payment_method do
attributes :id, :name
end

child :source => :source do
child source: :source do
if @current_user_roles.include?('admin')
attributes *payment_source_attributes + [:gateway_customer_profile_id, :gateway_payment_profile_id]
else
Expand All @@ -33,11 +33,11 @@ child :payments => :payments do
end
end

child :shipments => :shipments do
child shipments: :shipments do
extends "spree/api/v1/shipments/small"
end

child :adjustments => :adjustments do
child adjustments: :adjustments do
extends "spree/api/v1/adjustments/show"
end

Expand All @@ -46,6 +46,6 @@ node :permissions do
{ can_update: current_ability.can?(:update, root_object) }
end

child :valid_credit_cards => :credit_cards do
child valid_credit_cards: :credit_cards do
extends "spree/api/v1/credit_cards/show"
end
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object false
node(:error) { I18n.t(:credit_over_limit, :limit => @payment.credit_allowed, :scope => 'spree.api.payment') }
node(:error) { I18n.t(:credit_over_limit, limit: @payment.credit_allowed, scope: 'spree.api.payment') }
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object false
node(:error) { I18n.t(:update_forbidden, :state => @payment.state, :scope => 'spree.api.payment') }
node(:error) { I18n.t(:update_forbidden, state: @payment.state, scope: 'spree.api.payment') }
10 changes: 5 additions & 5 deletions api/app/views/spree/api/v1/products/show.v1.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ node(:display_price) { |p| p.display_price.to_s }
node(:has_variants) { |p| p.has_variants? }
node(:taxon_ids) { |p| p.taxon_ids }

child :master => :master do
child master: :master do
extends "spree/api/v1/variants/small"
end

child :variants => :variants do
child variants: :variants do
extends "spree/api/v1/variants/small"
end

child :option_types => :option_types do
child option_types: :option_types do
attributes *option_type_attributes
end

child :product_properties => :product_properties do
child product_properties: :product_properties do
attributes *product_property_attributes
end

child :classifications => :classifications do
child classifications: :classifications do
attributes :taxon_id, :position

child(:taxon) do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object false
node(:error) { I18n.t(:cannot_ready, :scope => "spree.api.shipment") }
node(:error) { I18n.t(:cannot_ready, scope: "spree.api.shipment") }
Loading

0 comments on commit 90bdd84

Please sign in to comment.