spree_skroutz 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8399789b8170126986e56193fca96b76eb74ac84fa6f933613dc9eee312256f8
4
+ data.tar.gz: f7913d009f8cb44b9fea3196a8e75dd1d3a9e8b57723597ee125d8b2cc80edf1
5
+ SHA512:
6
+ metadata.gz: 2a4a67024fc640b44afa7a003d16b531b06d7010c9311dd9c7fa9db51b3aa37c2452e8fe22c3e3f0cedf9e8550bb34ee7be23a6254644fa99b2a5b87f0f3dfac
7
+ data.tar.gz: fc2e3cae6270e353901903848e6387c5a1902eb711560e396fcf3080b0a8fb1eae09cce8baa229ae69ce254917db6b0bed6d6d713e162d762e03983048304ccb
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2025 OlympusOne
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # SpreeSkroutz
2
+
3
+ This is a Skroutz extension for [Spree Commerce](https://spreecommerce.org), an open source e-commerce platform built with Ruby on Rails. Adds the ability to provide products listings to Skroutz Marketplace for Spree Commerce.
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/spree_skroutz.svg)](https://badge.fury.io/rb/spree_skroutz)
6
+
7
+ ## Installation
8
+
9
+ 1. Add this extension to your Gemfile with this line:
10
+
11
+ ```ruby
12
+ bundle add spree_skroutz
13
+ ```
14
+
15
+ 2. Install the migrations:
16
+
17
+ ```sh
18
+ bundle exec rake railties:install:migrations FROM=spree_skroutz
19
+ ```
20
+
21
+ 3. Run the migrations:
22
+
23
+ ```sh
24
+ bundle exec rails db:migrate
25
+ ```
26
+
27
+ 4. Restart your server
28
+
29
+ If your server was running, restart it so that it can find the assets properly.
30
+
31
+ ## Developing
32
+
33
+ 1. Create a dummy app
34
+
35
+ ```bash
36
+ bundle update
37
+ bundle exec rake test_app
38
+ ```
39
+
40
+ 2. Add your new code
41
+ 3. Run tests
42
+
43
+ ```bash
44
+ bundle exec rspec
45
+ ```
46
+
47
+ When testing your applications integration with this extension you may use it's factories.
48
+ Simply add this require statement to your spec_helper:
49
+
50
+ ```ruby
51
+ require 'spree_skroutz/factories'
52
+ ```
53
+
54
+ ## Releasing a new version
55
+
56
+ ```shell
57
+ bundle exec gem bump -p -t
58
+ bundle exec gem release
59
+ ```
60
+
61
+ For more options please see [gem-release README](https://github.com/svenfuchs/gem-release)
62
+
63
+ ## Contributing
64
+
65
+ If you'd like to contribute, please take a look at the
66
+ [instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
67
+ pull request.
68
+
69
+ Copyright (c) 2025 OlympusOne, released under the MIT
70
+
71
+ ## Skroutz Center Integration
72
+
73
+ To use your Skroutz endpoint as a data source in Skroutz Center:
74
+
75
+ 1. **Deploy your endpoint**
76
+ Ensure your authentication and data endpoints are publicly accessible and return the required data format (e.g., XML, CSV, or JSON).
77
+ For this extension, your endpoint will typically be:
78
+ `https://yoursite.com/skroutz/products.xml`
79
+
80
+ 2. **Copy your endpoint URL**
81
+ This is the URL that Skroutz Center will fetch data from.
82
+
83
+ 3. **Add as a data feed in Skroutz Center**
84
+ - Go to [Skroutz Merchants](https://merchants.skroutz.gr/).
85
+ - In the header, click **Settings & tools**.
86
+ - Select **Data sources**.
87
+ - Click **Add product source**.
88
+ - Choose **Add products from a file**.
89
+ - Enter your endpoint URL (e.g., `https://yoursite.com/skroutz/products.xml`) as the feed source.
90
+ - Set fetch frequency and credentials if authentication is required.
91
+
92
+ 4. **Test and verify**
93
+ After saving, Google will attempt to fetch your data. Check for errors and ensure your feed is processed correctly.
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/extension_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_skroutz'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
@@ -0,0 +1,16 @@
1
+ module Spree
2
+ class SkroutzController < StoreController
3
+ include BaseHelper
4
+ include StorefrontHelper
5
+
6
+ def products
7
+ respond_to do |format|
8
+ format.xml
9
+ format.gzip do
10
+ gz_xml = ActiveSupport::Gzip.compress(render_to_string(template: 'spree/skroutz/products', formats: [:xml]))
11
+ send_data(gz_xml, filename: 'products.xml.gz', type: 'application/x-gzip', disposition: 'inline')
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,91 @@
1
+ xml.instruct! :xml, version: "1.0", encoding: "UTF-8"
2
+
3
+ xml.mywebstore do
4
+ cache [storefront_products_scope, current_currency] do
5
+ xml.created_at Time.current.strftime("%Y-%m-%d %H:%M")
6
+
7
+ xml.products do
8
+ storefront_products_scope.find_each do |product|
9
+ xml.product do
10
+ xml.tag! "id", product.id
11
+ xml.tag! "name" do
12
+ xml.cdata! product.name
13
+ end
14
+
15
+ if product.storefront_description.present?
16
+ xml.tag! "description", product.storefront_description&.truncate(10000)
17
+ end
18
+
19
+ xml.tag! "link" do
20
+ xml.cdata! spree_storefront_resource_url(product)
21
+ end
22
+
23
+ if product.default_image.present?
24
+ xml.tag! "image" do
25
+ xml.cdata! spree_image_url(product.default_image, width: 500, height: 500)
26
+ end
27
+ end
28
+ if product.secondary_image.present?
29
+ xml.tag! "additionalimage" do
30
+ xml.cdata! spree_image_url(product.secondary_image, width: 500, height: 500)
31
+ end
32
+ end
33
+
34
+ xml.tag! "category" do
35
+ xml.cdata! product_breadcrumb_taxons(product).map(&:name).join(' > ')
36
+ end
37
+ xml.tag! "price_with_vat", format('%.2f', product.display_amount.to_d)
38
+
39
+ if product.tax_category.present?
40
+ tax_rate = product.tax_category.tax_rates.first
41
+ xml.tag! "vat", format('%.2f', tax_rate&.amount_percentage || 0)
42
+ else
43
+ xml.tag! "vat", 0
44
+ end
45
+
46
+ if product.brand.present?
47
+ xml.tag! "manufacturer" do
48
+ xml.cdata! product.brand.name
49
+ end
50
+ end
51
+
52
+ xml.tag! "ean", product.barcode if product.barcode.present?
53
+ xml.tag! "availability", product.in_stock? ? "In stock" : "Out of stock"
54
+ xml.tag! "weight", "#{product.weight} #{product.weight_unit}" if product.weight.present?
55
+
56
+ colors = product.option_values.select{|ov| ov.option_type.name.downcase == 'color' }
57
+ .map(&:presentation)
58
+ .uniq
59
+ xml.tag! "color", colors.join(',') if colors.any?
60
+
61
+ size = product.option_values.select{|ov| ov.option_type.name.downcase == 'size' }
62
+ .map(&:presentation)
63
+ .uniq
64
+ xml.tag! "size", size.join(',') if size.any?
65
+
66
+ xml.tag! "quantity", product.total_on_hand
67
+
68
+ if product.has_variants?
69
+ xml.variations do
70
+ product.variants.each do |variant|
71
+ xml.variation do
72
+ xml.tag! "variationid", variant.id
73
+ xml.tag! "availability", variant.in_stock? ? "In stock" : "Out of stock"
74
+ xml.tag! "ean", variant.barcode if variant.barcode.present?
75
+ xml.tag! "price_with_vat", format('%.2f', variant.display_amount.to_d)
76
+
77
+ size = variant.option_values.select{|ov| ov.option_type.name.downcase == 'size' }
78
+ .map(&:presentation)
79
+ .uniq
80
+ xml.tag! "size", size.join(',') if size.any?
81
+
82
+ xml.tag! "quantity", variant.total_on_hand
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Spree::Core::Engine.add_routes do
2
+ get '/skroutz/products', to: 'skroutz#products', defaults: { format: :xml }
3
+ get '/skroutz/products.xml.gz', to: 'skroutz#products'
4
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeSkroutz
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :migrate, type: :boolean, default: true
5
+
6
+ def add_migrations
7
+ run 'bundle exec rake railties:install:migrations FROM=spree_skroutz'
8
+ end
9
+
10
+ def run_migrations
11
+ run_migrations = options[:migrate] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
12
+ if run_migrations
13
+ run 'bin/rails db:migrate'
14
+ else
15
+ puts 'Skipping rails db:migrate, don\'t forget to run it!'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ module SpreeSkroutz
2
+ class Configuration < Spree::Preferences::Configuration
3
+
4
+ # Some example preferences are shown below, for more information visit:
5
+ # https://docs.spreecommerce.org/developer/contributing/creating-an-extension
6
+
7
+ # preference :enabled, :boolean, default: true
8
+ # preference :dark_chocolate, :boolean, default: true
9
+ # preference :color, :string, default: 'Red'
10
+ # preference :favorite_number, :integer
11
+ # preference :supported_locales, :array, default: [:en]
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module SpreeSkroutz
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_skroutz'
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ initializer 'spree_skroutz.environment', before: :load_config_initializers do |_app|
13
+ SpreeSkroutz::Config = SpreeSkroutz::Configuration.new
14
+ end
15
+
16
+ def self.activate
17
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
18
+ Rails.configuration.cache_classes ? require(c) : load(c)
19
+ end
20
+ end
21
+
22
+ config.to_prepare(&method(:activate).to_proc)
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'spree_skroutz/factories'
6
+ end
@@ -0,0 +1,7 @@
1
+ module SpreeSkroutz
2
+ VERSION = '1.0.0'.freeze
3
+
4
+ def gem_version
5
+ Gem::Version.new(VERSION)
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ require 'spree_core'
2
+ require 'spree_extension'
3
+ require 'spree_skroutz/engine'
4
+ require 'spree_skroutz/version'
5
+ require 'spree_skroutz/configuration'
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_skroutz
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - OlympusOne
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: spree
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 5.0.4
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 5.0.4
26
+ - !ruby/object:Gem::Dependency
27
+ name: spree_storefront
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.4
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 5.0.4
40
+ - !ruby/object:Gem::Dependency
41
+ name: spree_admin
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 5.0.4
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 5.0.4
54
+ - !ruby/object:Gem::Dependency
55
+ name: spree_extension
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: spree_dev_tools
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ description: Adds the ability to provide products feed to Skroutz Marketplace for
83
+ Spree Commerce.
84
+ email: info@olympusone.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - LICENSE.md
90
+ - README.md
91
+ - Rakefile
92
+ - app/controllers/spree/skroutz_controller.rb
93
+ - app/views/spree/skroutz/products.xml.builder
94
+ - config/routes.rb
95
+ - lib/generators/spree_skroutz/install/install_generator.rb
96
+ - lib/spree_skroutz.rb
97
+ - lib/spree_skroutz/configuration.rb
98
+ - lib/spree_skroutz/engine.rb
99
+ - lib/spree_skroutz/factories.rb
100
+ - lib/spree_skroutz/version.rb
101
+ homepage: https://github.com/olympusone/spree_skroutz
102
+ licenses:
103
+ - MIT
104
+ metadata:
105
+ bug_tracker_uri: https://github.com/olympusone/spree_skroutz/issues
106
+ changelog_uri: https://github.com/olympusone/spree_skroutz/releases/tag/v1.0.0
107
+ documentation_uri: https://github.com/olympusone/spree_skroutz
108
+ homepage_uri: https://github.com/olympusone/spree_skroutz
109
+ source_code_uri: https://github.com/olympusone/spree_skroutz/tree/v1.0.0
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements:
124
+ - none
125
+ rubygems_version: 3.6.9
126
+ specification_version: 4
127
+ summary: Spree Commerce Skroutz Extension
128
+ test_files: []