spree_google_merchant 0.60.0.RC1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Redistribution and use in source and binary forms, with or without modification,
2
+ are permitted provided that the following conditions are met:
3
+
4
+ * Redistributions of source code must retain the above copyright notice,
5
+ this list of conditions and the following disclaimer.
6
+ * Redistributions in binary form must reproduce the above copyright notice,
7
+ this list of conditions and the following disclaimer in the documentation
8
+ and/or other materials provided with the distribution.
9
+ * Neither the name of the Rails Dog LLC nor the names of its
10
+ contributors may be used to endorse or promote products derived from this
11
+ software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
16
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ Summary
2
+ =======
3
+
4
+ Provides a live product feed for Google Merchant rather a file that you have to upload. This is a very basic extension so feel free to help improve it!
5
+
6
+ To access the feed visit:
7
+
8
+ http://yoursite.com/products/google_merchant.rss
9
+
10
+ Installation
11
+ ------------
12
+
13
+ To start with you'll need a Google Merchant account. Then:
14
+
15
+ gem "spree_google_merchant", :git => 'git://github.com/sebastyuiop/spree_google_merchant.git'
16
+
17
+ bundle install
18
+
19
+ rake spree_google_merchant:install
20
+
21
+ To configure the feed title, description and site URL go to the Google Merchant settings page in Admin -> Configuration
22
+
23
+ Copyright (c) 2011 sebastyuiop, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/Versionfile ADDED
@@ -0,0 +1,9 @@
1
+ # This file is used to designate compatibilty with different versions of Spree
2
+ # Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
3
+
4
+ # Examples
5
+ #
6
+ # "0.50.x" => { :branch => "master" }
7
+ # "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
8
+
9
+
@@ -0,0 +1,13 @@
1
+ class Spree::Admin::GoogleMerchantsController < Spree::Admin::BaseController
2
+
3
+ def update
4
+ Spree::GoogleMerchant::Config.set(params[:preferences])
5
+
6
+ respond_to do |format|
7
+ format.html {
8
+ redirect_to admin_google_merchants_path
9
+ }
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,5 @@
1
+ Spree::ProductsController.class_eval do
2
+ def google_merchant
3
+ @products = Product.active
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(
2
+ :virtual_path => "spree/admin/configurations/index",
3
+ :name => "insert_google_merchant_into_admin_config_menu",
4
+ :insert_after => "tbody[data-hook='admin_configurations_menu']",
5
+ :text => %(<%= configurations_menu_item(t("google_merchant"), admin_google_merchants_path, t("google_merchants_description")) %>)
6
+ )
@@ -0,0 +1,24 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <h1><%= t('edit_google_merchant_settings') %></h1>
4
+
5
+ <%= form_tag(admin_google_merchants_path, :method => :put) do %>
6
+ <p>
7
+ <label><%= t("google_merchant_title") %></label>
8
+ <%= text_field_tag('preferences[google_merchant_title]', Spree::GoogleMerchant::Config[:google_merchant_title]) %>
9
+ </p>
10
+ <p>
11
+ <label><%= t("google_merchant_description") %></label>
12
+ <%= text_field_tag('preferences[google_merchant_description]', Spree::GoogleMerchant::Config[:google_merchant_description]) %>
13
+ </p>
14
+ <p>
15
+ <label><%= t('production_domain') %></label>
16
+ <%= text_field_tag('preferences[production_domain]', Spree::GoogleMerchant::Config[:production_domain])%>
17
+ </p>
18
+
19
+
20
+ <p class="form-buttons">
21
+ <%= button t('update') %>
22
+ <%= t("or") %> <%= link_to t("cancel"), admin_google_merchants_url %>
23
+ </p>
24
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <%= render :partial => '/spree/admin/shared/configuration_menu' %>
2
+
3
+ <h1><%= t("google_merchant_settings") %></h1>
4
+
5
+ <table>
6
+ <tr>
7
+ <th scope="row"><%= t("google_merchant_title") %>:</th>
8
+ <td><%= Spree::GoogleMerchant::Config[:google_merchant_title] %></td>
9
+ </tr>
10
+ <tr>
11
+ <th scope="row"><%= t("google_merchant_description") %>:</th>
12
+ <td><%= Spree::GoogleMerchant::Config[:google_merchant_description] %></td>
13
+ </tr>
14
+ <tr>
15
+ <th scope="row"><%= t("production_domain") %>:</th>
16
+ <td><%= Spree::GoogleMerchant::Config[:production_domain] %></td>
17
+ </tr>
18
+ </table>
19
+
20
+ <p><%= link_to_with_icon 'edit', t("edit"), edit_admin_google_merchants_path, :id => 'admin_google_merchants_link' %></p>
@@ -0,0 +1,25 @@
1
+ xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
2
+
3
+ xml.rss "version" => "2.0", "xmlns:g" => "http://base.google.com/ns/1.0" do
4
+ xml.channel do
5
+ xml.title Spree::GoogleMerchant::Config[:google_merchant_title]
6
+ xml.description Spree::GoogleMerchant::Config[:google_merchant_description]
7
+
8
+ production_domain = Spree::GoogleMerchant::Config[:production_domain]
9
+ xml.link production_domain
10
+
11
+ @products.each do |product|
12
+ xml.item do
13
+ xml.id product.id.to_s
14
+ xml.title product.name
15
+ xml.description CGI.escapeHTML(product.description)
16
+ xml.link production_domain + 'products/' + product.permalink
17
+ xml.tag! "g:mpn", product.sku.to_s
18
+ xml.tag! "g:id", product.id.to_s
19
+ xml.tag! "g:price", product_price(product, {:format_as_currency => false})
20
+ xml.tag! "g:condition", "new"
21
+ xml.tag! "g:image_link", production_domain.sub(/\/$/, '') + product.images.first.attachment.url(:product) unless product.images.empty?
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ ---
2
+ en:
3
+ edit_google_merchant_settings: "Edit Google Merchant settings"
4
+ google_merchant_title: "Google Merchant title"
5
+ google_merchant_description: "Google Merchant description"
6
+ production_domain: "Production domain"
7
+ google_merchant: "Google Merchant"
8
+ google_merchants_description: "Provides a live feed of active products for Google Merchant" #Not to be confused with the above
data/config/routes.rb ADDED
@@ -0,0 +1,11 @@
1
+ Spree::Core::Engine.routes.append do
2
+ resources :products do
3
+ collection do
4
+ get :google_merchant
5
+ end
6
+ end
7
+
8
+ namespace :admin do
9
+ resource :google_merchants
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ module GoogleMerchant
3
+ class Config
4
+ include Singleton
5
+
6
+ class << self
7
+ def instance
8
+ return nil unless ActiveRecord::Base.connection.tables.include?('spree_configurations')
9
+ Spree::GoogleMerchantConfiguration.find_or_create_by_name("Google merchant configuration")
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class Spree::GoogleMerchantConfiguration < Spree::Preferences::Configuration
2
+ preference :google_merchant_title, :string, :default => 'My Spree Shop'
3
+ preference :google_merchant_description, :string, :default => 'List of our products'
4
+ preference :production_domain, :string, :default => 'http://www.myspreeshop.com/'
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'spree_core'
2
+
3
+ module SpreeGoogleMerchant
4
+ class Engine < Rails::Engine
5
+
6
+ config.autoload_paths += %W(#{config.root}/lib)
7
+
8
+ def self.activate
9
+ Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
10
+ Rails.env.production? ? require(c) : load(c)
11
+ end
12
+ end
13
+
14
+ config.to_prepare &method(:activate).to_proc
15
+
16
+ # instantiate the configuration object
17
+ initializer "spree.google_merchant.preferences", :after => "spree.environment" do |app|
18
+ Spree::GoogleMerchant::Config = Spree::GoogleMerchantConfiguration.new
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ namespace :spree_google_merchant do
2
+ desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
3
+ task :install do
4
+ Rake::Task['spree_google_merchant:install:migrations'].invoke
5
+ Rake::Task['spree_google_merchant:install:assets'].invoke
6
+ end
7
+
8
+ namespace :install do
9
+ desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
10
+ task :migrations do
11
+ source = File.join(File.dirname(__FILE__), '..', '..', 'db')
12
+ destination = File.join(Rails.root, 'db')
13
+ Spree::Core::FileUtilz.mirror_files(source, destination)
14
+ end
15
+
16
+ desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
17
+ task :assets do
18
+ source = File.join(File.dirname(__FILE__), '..', '..', 'public')
19
+ destination = File.join(Rails.root, 'public')
20
+ puts "INFO: Mirroring assets from #{source} to #{destination}"
21
+ Spree::Core::FileUtilz.mirror_files(source, destination)
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1 @@
1
+ # add custom rake tasks here
@@ -0,0 +1,30 @@
1
+ # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
+ # from the project root directory.
3
+ ENV["RAILS_ENV"] ||= 'test'
4
+ require File.expand_path("../test_app/config/environment", __FILE__)
5
+ require 'rspec/rails'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ # == Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+ config.mock_with :rspec
20
+
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ #config.include Devise::TestHelpers, :type => :controller
24
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
25
+ # examples within a transaction, comment the following line or assign false
26
+ # instead of true.
27
+ config.use_transactional_fixtures = true
28
+ end
29
+
30
+ @configuration ||= AppConfiguration.find_or_create_by_name("Default configuration")
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = 'spree_google_merchant'
4
+ s.version = '0.60.0.RC1'
5
+ s.summary = 'Add gem summary here'
6
+ s.description = 'Add (optional) gem description here'
7
+ s.required_ruby_version = '>= 1.8.7'
8
+
9
+ s.author = 'Seb Weston'
10
+ s.email = 'sebweston@gmail.com'
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.require_path = 'lib'
15
+ s.requirements << 'none'
16
+
17
+ s.add_dependency('spree_core', '>= 0.60.0.RC1')
18
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_google_merchant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.60.0.RC1
5
+ prerelease: 7
6
+ platform: ruby
7
+ authors:
8
+ - Seb Weston
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: spree_core
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.60.0.RC1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.60.0.RC1
30
+ description: Add (optional) gem description here
31
+ email: sebweston@gmail.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - .gitignore
37
+ - LICENSE
38
+ - README
39
+ - README.md
40
+ - Rakefile
41
+ - Versionfile
42
+ - app/controllers/spree/admin/google_merchants_controller.rb
43
+ - app/controllers/spree/products_decorator.rb
44
+ - app/overrides/insert_google_merchant_into_admin_config_menu.rb
45
+ - app/views/spree/admin/google_merchants/edit.html.erb
46
+ - app/views/spree/admin/google_merchants/show.html.erb
47
+ - app/views/spree/products/google_merchant.rss.builder
48
+ - config/locales/en.yml
49
+ - config/routes.rb
50
+ - lib/spree/google_merchant/config.rb
51
+ - lib/spree/google_merchant_configuration.rb
52
+ - lib/spree_google_merchant.rb
53
+ - lib/tasks/install.rake
54
+ - lib/tasks/spree_google_merchant.rake
55
+ - spec/spec_helper.rb
56
+ - spree_google_merchant.gemspec
57
+ homepage:
58
+ licenses: []
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.8.7
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>'
73
+ - !ruby/object:Gem::Version
74
+ version: 1.3.1
75
+ requirements:
76
+ - none
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.23
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Add gem summary here
82
+ test_files:
83
+ - spec/spec_helper.rb