solidus_product_feed 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +11 -0
  5. data/Gemfile +11 -0
  6. data/Guardfile +10 -0
  7. data/LICENSE +26 -0
  8. data/README.md +36 -0
  9. data/Rakefile +21 -0
  10. data/app/assets/javascripts/admin/solidus_product_feed.js +1 -0
  11. data/app/assets/javascripts/spree/backend/solidus_product_feed.js +0 -0
  12. data/app/assets/javascripts/spree/backend/spree_product_feed.js +0 -0
  13. data/app/assets/javascripts/spree/frontend/solidus_product_feed.js +0 -0
  14. data/app/assets/javascripts/spree/frontend/spree_product_feed.js +0 -0
  15. data/app/assets/javascripts/store/solidus_product_feed.js +1 -0
  16. data/app/assets/stylesheets/admin/solidus_product_feed.css +3 -0
  17. data/app/assets/stylesheets/spree/backend/solidus_product_feed.css +0 -0
  18. data/app/assets/stylesheets/spree/backend/spree_product_feed.css +0 -0
  19. data/app/assets/stylesheets/spree/frontend/solidus_product_feed.css +0 -0
  20. data/app/assets/stylesheets/spree/frontend/spree_product_feed.css +0 -0
  21. data/app/assets/stylesheets/store/solidus_product_feed.css +3 -0
  22. data/app/controllers/spree/products_controller_decorator.rb +15 -0
  23. data/app/overrides/rss_link.rb +5 -0
  24. data/app/views/spree/products/index.rss.builder +27 -0
  25. data/config/routes.rb +3 -0
  26. data/lib/generators/solidus_product_feed/install/install_generator.rb +24 -0
  27. data/lib/solidus_product_feed/engine.rb +20 -0
  28. data/lib/solidus_product_feed/version.rb +3 -0
  29. data/lib/solidus_product_feed.rb +2 -0
  30. data/lib/spree_product_feed.rb +1 -0
  31. data/script/rails +7 -0
  32. data/solidus_product_feed.gemspec +28 -0
  33. data/spec/controllers/products_controller_spec.rb +15 -0
  34. data/spec/spec_helper.rb +29 -0
  35. metadata +135 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7c3bec9a0329340d4408fe6ba7e3e9817394ab86
4
+ data.tar.gz: 99c1d07475c2d437db367c2ac5bf52035c40a143
5
+ SHA512:
6
+ metadata.gz: 96f166ddd4787da1441c2c47d335fd529e8232176ddf9c4ae9c20a3724c651d096393c00ec419874f47c3473e1153d61085ed313792ef9c2296d2634ccd59e24
7
+ data.tar.gz: 544fb19985b15ec8bb26c7bb79eeb4b35d6e8a6dfa710a79f61db0453e3d4cda65cbdc9301b903738fdfaa3c20a57e0ad2af1e57a710d18ff18ba49d8f315c76
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
10
+ spec/dummy
11
+ pkg
12
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ env:
6
+ matrix:
7
+ - SOLIDUS_BRANCH=v1.0
8
+ - SOLIDUS_BRANCH=v1.1
9
+ - SOLIDUS_BRANCH=v1.2
10
+ - SOLIDUS_BRANCH=v1.3
11
+ - SOLIDUS_BRANCH=master
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'http://rubygems.org'
2
+
3
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
4
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
5
+
6
+ # Provides basic authentication functionality for testing parts of your engine
7
+ group :development, :test do
8
+ gem 'solidus_auth_devise'
9
+ end
10
+
11
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard 'rspec', :cli => '--color --format doc' do
2
+ watch('spec/spec_helper.rb') { "spec" }
3
+ watch('config/routes.rb') { "spec/routing" }
4
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
8
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
9
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2011 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ Solidus Product Feed
2
+ ================
3
+
4
+ [![Build Status](https://travis-ci.org/solidusio-contrib/solidus_product_feed.svg?branch=master)](https://travis-ci.org/solidusio-contrib/solidus_product_feed)
5
+
6
+ An extension that provides an RSS feed for products. Google Shopper attributes are also implemented.
7
+ An RSS link is automatically appended to the `<head>` tag in the `layouts/spree_application` file.
8
+
9
+
10
+ Installation
11
+ ===============
12
+
13
+ 1) add the gem to your `Gemfile`:
14
+
15
+ `gem 'solidus_product_feed'`
16
+
17
+ 2) run bundler:
18
+
19
+ `bundle install`
20
+
21
+ 3) BOOOM, you're done
22
+
23
+ Viewing Product RSS
24
+ ============
25
+
26
+ `http://yourdomain.tld/products.rss`
27
+
28
+ Testing
29
+ =======
30
+
31
+ Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
32
+
33
+ $ bundle exec rake test app
34
+ $ bundle exec rspec spec
35
+
36
+ Copyright (c) 2011 Joshua Nussbaum, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/common_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'spree_product_feed'
20
+ Rake::Task['common:test_app'].invoke("Spree::User")
21
+ end
@@ -0,0 +1 @@
1
+ //= require admin/spree_core
@@ -0,0 +1 @@
1
+ //= require store/spree_core
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_core
3
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_core
3
+ */
@@ -0,0 +1,15 @@
1
+ Spree::ProductsController.class_eval do
2
+ respond_to :rss, :only => [:index]
3
+ before_filter :check_rss, only: :index
4
+
5
+ def check_rss
6
+ if request.format.rss?
7
+ @products = Spree::Product.all
8
+ respond_to do |format|
9
+ format.rss { render 'spree/products/index.rss', :layout => false }
10
+ end
11
+ end
12
+ end
13
+
14
+ # caches_page :index, :if => Proc.new {|c| c.request.format.rss? }, :expires_in => 1.days
15
+ end
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(:virtual_path => 'layouts/spree_application',
2
+ :name => 'product_rss_link',
3
+ :original => '86987c7feaaea3181df195ca520571d801bbbaf3',
4
+ :insert_bottom => "[data-hook='inside_head']",
5
+ :text => '<%= auto_discovery_link_tag(:rss, products_path(:format => :rss), {:title => "#{Spree::Config[:site_title]} Products"}) %>')
@@ -0,0 +1,27 @@
1
+ xml.instruct! :xml, :version=>"1.0"
2
+ xml.rss(:version=>"2.0", "xmlns:g" => "http://base.google.com/ns/1.0"){
3
+ xml.channel{
4
+ xml.title(current_store.name)
5
+ xml.link("http://#{current_store.url}")
6
+ xml.description("Find out about new products on http://#{current_store.url} first!")
7
+ xml.language('en-us')
8
+ @products.each do |product|
9
+ xml.item do
10
+ xml.title(product.name)
11
+ xml.description((product.images.count > 0 ? link_to(image_tag(product.images.first.attachment.url(:product)), product_url(product)) : '') + simple_format(product.description))
12
+ xml.author(current_store.url)
13
+ xml.pubDate((product.available_on || product.created_at).strftime("%a, %d %b %Y %H:%M:%S %z"))
14
+ xml.link(product_url(product))
15
+ xml.guid(product.id)
16
+
17
+ if product.images.count > 0
18
+ xml.tag!('g:image_link', product.images.first.attachment.url(:large))
19
+ end
20
+
21
+ xml.tag!('g:price', product.price)
22
+ xml.tag!('g:condition', 'retail')
23
+ xml.tag!('g:id', product.id)
24
+ end
25
+ end
26
+ }
27
+ }
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,24 @@
1
+ module SolidusProductFeed
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :auto_run_migrations, :type => :boolean, :default => false
5
+
6
+ def add_migrations
7
+ run 'rake railties:install:migrations FROM=spree_product_feed'
8
+ end
9
+
10
+ def add_javascripts
11
+ append_file "vendor/assets/javascripts/spree/backend/all.js", "//= require spree/backend/spree_product_feed\n"
12
+ end
13
+
14
+ def run_migrations
15
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
16
+ if run_migrations
17
+ run 'rake db:migrate'
18
+ else
19
+ puts "Skiping rake db:migrate, don't forget to run it!"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ module SolidusProductFeed
2
+ class Engine < Rails::Engine
3
+ engine_name 'solidus_product_feed'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator.rb')) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module SolidusProductFeed
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'solidus_product_feed/engine'
@@ -0,0 +1 @@
1
+ require 'solidus_product_feed/version'
data/script/rails ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+
5
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
6
+ load File.expand_path('../../spec/dummy/script/rails', __FILE__)
7
+
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $:.unshift lib unless $:.include?(lib)
4
+
5
+ require 'solidus_product_feed/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.platform = Gem::Platform::RUBY
9
+ s.name = 'solidus_product_feed'
10
+ s.version = SolidusProductFeed::VERSION
11
+ s.summary = 'Spree extension that provides an RSS feed for products'
12
+ s.description = 'A Spree extension that provides an RSS feed for products, with Google Shopper extensions'
13
+ s.required_ruby_version = '>= 1.8.7'
14
+
15
+ s.author = 'Joshua Nussbaum'
16
+ s.email = 'joshnuss@gmail.com'
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.require_path = 'lib'
21
+ s.requirements << 'none'
22
+
23
+ s.add_runtime_dependency 'solidus_core', ["~> 1.0"]
24
+ s.add_runtime_dependency 'solidus_backend', ["~> 1.0"]
25
+
26
+ s.add_development_dependency 'rspec-rails', '~> 3.4'
27
+ s.add_development_dependency 'sqlite3'
28
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::ProductsController, type: :controller do
4
+ context "GET /index.rss" do
5
+ before { get :index, format: 'rss', use_route: :spree}
6
+
7
+ it 'succeeds' do
8
+ expect(response).to be_success
9
+ end
10
+
11
+ it 'returns the correct content type' do
12
+ expect(response.content_type).to eql('application/rss+xml')
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+
6
+ # Requires supporting ruby files with custom matchers and macros, etc,
7
+ # in spec/support/ and its subdirectories.
8
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |file| require file }
9
+
10
+ RSpec.configure do |config|
11
+ # == Mock Framework
12
+ #
13
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
14
+ #
15
+ # config.mock_with :mocha
16
+ # config.mock_with :flexmock
17
+ # config.mock_with :rr
18
+ config.mock_with :rspec
19
+
20
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
+ # examples within a transaction, remove the following line or assign false
25
+ # instead of true.
26
+ config.use_transactional_fixtures = true
27
+
28
+ config.include Devise::TestHelpers, type: :controller
29
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidus_product_feed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Joshua Nussbaum
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: solidus_core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: solidus_backend
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A Spree extension that provides an RSS feed for products, with Google
70
+ Shopper extensions
71
+ email: joshnuss@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - Guardfile
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - app/assets/javascripts/admin/solidus_product_feed.js
85
+ - app/assets/javascripts/spree/backend/solidus_product_feed.js
86
+ - app/assets/javascripts/spree/backend/spree_product_feed.js
87
+ - app/assets/javascripts/spree/frontend/solidus_product_feed.js
88
+ - app/assets/javascripts/spree/frontend/spree_product_feed.js
89
+ - app/assets/javascripts/store/solidus_product_feed.js
90
+ - app/assets/stylesheets/admin/solidus_product_feed.css
91
+ - app/assets/stylesheets/spree/backend/solidus_product_feed.css
92
+ - app/assets/stylesheets/spree/backend/spree_product_feed.css
93
+ - app/assets/stylesheets/spree/frontend/solidus_product_feed.css
94
+ - app/assets/stylesheets/spree/frontend/spree_product_feed.css
95
+ - app/assets/stylesheets/store/solidus_product_feed.css
96
+ - app/controllers/spree/products_controller_decorator.rb
97
+ - app/overrides/rss_link.rb
98
+ - app/views/spree/products/index.rss.builder
99
+ - config/routes.rb
100
+ - lib/generators/solidus_product_feed/install/install_generator.rb
101
+ - lib/solidus_product_feed.rb
102
+ - lib/solidus_product_feed/engine.rb
103
+ - lib/solidus_product_feed/version.rb
104
+ - lib/spree_product_feed.rb
105
+ - script/rails
106
+ - solidus_product_feed.gemspec
107
+ - spec/controllers/products_controller_spec.rb
108
+ - spec/spec_helper.rb
109
+ homepage:
110
+ licenses: []
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 1.8.7
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements:
127
+ - none
128
+ rubyforge_project:
129
+ rubygems_version: 2.5.1
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Spree extension that provides an RSS feed for products
133
+ test_files:
134
+ - spec/controllers/products_controller_spec.rb
135
+ - spec/spec_helper.rb