spree_frenet 0.1.1 → 0.1.2
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 +4 -4
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.rubocop.yml +24 -0
- data/.travis.yml +31 -0
- data/Appraisals +29 -0
- data/Gemfile +16 -0
- data/LICENSE +26 -0
- data/README.md +54 -0
- data/Rakefile +21 -0
- data/app/assets/javascripts/spree/backend/spree_frenet.js +2 -0
- data/app/assets/javascripts/spree/frontend/spree_frenet.js +2 -0
- data/app/assets/stylesheets/spree/backend/spree_frenet.css +4 -0
- data/app/assets/stylesheets/spree/frontend/spree_frenet.css +4 -0
- data/app/models/spree/calculator/shipping/frenet/azul.rb +11 -0
- data/app/models/spree/calculator/shipping/frenet/base.rb +32 -0
- data/app/models/spree/calculator/shipping/frenet/pac.rb +11 -0
- data/app/models/spree/calculator/shipping/frenet/pac_mini.rb +11 -0
- data/app/models/spree/calculator/shipping/frenet/sedex.rb +11 -0
- data/app/services/frenet/api.rb +24 -0
- data/app/services/frenet/request.rb +33 -0
- data/bin/rails +8 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +3 -0
- data/lib/generators/spree_frenet/install/install_generator.rb +30 -0
- data/lib/spree_frenet.rb +4 -0
- data/lib/spree_frenet/engine.rb +35 -0
- data/lib/spree_frenet/factories.rb +6 -0
- data/lib/spree_frenet/version.rb +17 -0
- data/spree_frenet.gemspec +43 -0
- metadata +32 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6362f7a2e10af44a31452686d85ea317d3403ef4a7ea5a0855a8c40b7f8bf3b1
|
|
4
|
+
data.tar.gz: 9cbfece4679269fc17d96e866bbe92d66f0df5a07705d978985f7554e4c390a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9794cc81f0f1c2d5ff93140616e51d5de01151161929ac0f1deb7a8007f7a2b844147448afd0e5cb118fa15b5be73b65fdda0231505994c3a8b5b288f1a63866
|
|
7
|
+
data.tar.gz: cc56a98e535da6e76e4421c2ab5b1f2bc2eb42c1d33d745ecaf649ba9ff2ec1cdfec447b2751fe0c061be3e7622e2b3ba7f2ec8a3214d3a96b9a9c1a706dcc89
|
data/.gitignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
\#*
|
|
2
|
+
*~
|
|
3
|
+
.#*
|
|
4
|
+
.DS_Store
|
|
5
|
+
.idea
|
|
6
|
+
.localeapp/locales
|
|
7
|
+
.project
|
|
8
|
+
coverage
|
|
9
|
+
default
|
|
10
|
+
Gemfile.lock
|
|
11
|
+
tmp
|
|
12
|
+
nbproject
|
|
13
|
+
pkg
|
|
14
|
+
*.sw?
|
|
15
|
+
spec/dummy
|
|
16
|
+
.rvmrc
|
|
17
|
+
.sass-cache
|
|
18
|
+
public/spree
|
|
19
|
+
.ruby-version
|
|
20
|
+
.ruby-gemset
|
|
21
|
+
gemfiles/*.gemfile.lock
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
DisplayCopNames: true
|
|
3
|
+
TargetRubyVersion: 2.4
|
|
4
|
+
Include:
|
|
5
|
+
- '**/Gemfile'
|
|
6
|
+
- '**/Rakefile'
|
|
7
|
+
- '**/Appraisals'
|
|
8
|
+
Exclude:
|
|
9
|
+
- 'spec/dummy/**/*'
|
|
10
|
+
- 'lib/generators/**/*'
|
|
11
|
+
|
|
12
|
+
Rails:
|
|
13
|
+
Enabled: true
|
|
14
|
+
|
|
15
|
+
Metrics/LineLength:
|
|
16
|
+
Max: 150
|
|
17
|
+
|
|
18
|
+
# DISABLED
|
|
19
|
+
|
|
20
|
+
Style/Documentation:
|
|
21
|
+
Enabled: false
|
|
22
|
+
|
|
23
|
+
Style/FrozenStringLiteralComment:
|
|
24
|
+
Enabled: false
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
sudo: required
|
|
2
|
+
dist: trusty
|
|
3
|
+
|
|
4
|
+
language: ruby
|
|
5
|
+
|
|
6
|
+
env:
|
|
7
|
+
- DB=postgres
|
|
8
|
+
- DB=mysql
|
|
9
|
+
|
|
10
|
+
gemfile:
|
|
11
|
+
- gemfiles/spree_3_1.gemfile
|
|
12
|
+
- gemfiles/spree_3_2.gemfile
|
|
13
|
+
- gemfiles/spree_3_3.gemfile
|
|
14
|
+
- gemfiles/spree_3_4.gemfile
|
|
15
|
+
- gemfiles/spree_master.gemfile
|
|
16
|
+
|
|
17
|
+
script:
|
|
18
|
+
- bundle exec rake test_app
|
|
19
|
+
- bundle exec rake spec
|
|
20
|
+
|
|
21
|
+
rvm:
|
|
22
|
+
- 2.4.2
|
|
23
|
+
- 2.3.1
|
|
24
|
+
- 2.2.7
|
|
25
|
+
|
|
26
|
+
matrix:
|
|
27
|
+
allow_failures:
|
|
28
|
+
- gemfile: gemfiles/spree_master.gemfile
|
|
29
|
+
|
|
30
|
+
before_install:
|
|
31
|
+
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
|
data/Appraisals
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
appraise 'spree-3-1' do
|
|
2
|
+
gem 'spree', '~> 3.1.0'
|
|
3
|
+
gem 'spree_auth_devise', '~> 3.1.0'
|
|
4
|
+
gem 'rails_test_params_backport', group: :test
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
appraise 'spree-3-2' do
|
|
8
|
+
gem 'spree', '~> 3.2.0'
|
|
9
|
+
gem 'spree_auth_devise', '~> 3.2.0'
|
|
10
|
+
gem 'rails-controller-testing'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
appraise 'spree-3-3' do
|
|
14
|
+
gem 'spree', '~> 3.3.0'
|
|
15
|
+
gem 'spree_auth_devise', '~> 3.3.0'
|
|
16
|
+
gem 'rails-controller-testing'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
appraise 'spree-3-4' do
|
|
20
|
+
gem 'spree', '~> 3.4.0'
|
|
21
|
+
gem 'spree_auth_devise', '~> 3.3.0'
|
|
22
|
+
gem 'rails-controller-testing'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
appraise 'spree-master' do
|
|
26
|
+
gem 'spree', github: 'spree/spree', branch: 'master'
|
|
27
|
+
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
|
|
28
|
+
gem 'rails-controller-testing'
|
|
29
|
+
end
|
data/Gemfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
git_source(:github) do |repo_name|
|
|
4
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
|
|
5
|
+
"https://github.com/#{repo_name}.git"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
gem 'spree', github: 'spree/spree', branch: 'master'
|
|
9
|
+
# Provides basic authentication functionality for testing parts of your engine
|
|
10
|
+
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
|
|
11
|
+
gem 'rails-controller-testing'
|
|
12
|
+
|
|
13
|
+
gem 'rubocop', require: false
|
|
14
|
+
gem 'rubocop-rspec', require: false
|
|
15
|
+
|
|
16
|
+
gemspec
|
data/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) 2021 [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,54 @@
|
|
|
1
|
+
# SpreeFrenet
|
|
2
|
+
|
|
3
|
+
Spree extension with custom calculators to quote shipments via Frenet
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
1. Add this extension to your Gemfile with this line:
|
|
8
|
+
```ruby
|
|
9
|
+
gem 'spree_frenet'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
2. Install the gem using Bundler:
|
|
13
|
+
```ruby
|
|
14
|
+
bundle install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. Add your Frenet token as an ENV variable
|
|
18
|
+
```sh
|
|
19
|
+
export FRENET_TOKEN="your-token"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
<!-- 3. Copy & run migrations
|
|
23
|
+
```ruby
|
|
24
|
+
bundle exec rails g spree_frenet:install
|
|
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
|
+
## Testing
|
|
32
|
+
|
|
33
|
+
First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
bundle
|
|
37
|
+
bundle exec rake
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
When testing your applications integration with this extension you may use it's factories.
|
|
41
|
+
Simply add this require statement to your spec_helper:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
require 'spree_frenet/factories'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Contributing
|
|
49
|
+
|
|
50
|
+
If you'd like to contribute, please take a look at the
|
|
51
|
+
[instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
|
|
52
|
+
pull request.
|
|
53
|
+
|
|
54
|
+
Copyright (c) 2021 [name of extension creator], 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/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_frenet'
|
|
20
|
+
Rake::Task['extension:test_app'].invoke
|
|
21
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require_dependency 'spree/calculator'
|
|
2
|
+
|
|
3
|
+
module Spree::Calculator::Shipping::Frenet
|
|
4
|
+
class Base < Spree::ShippingCalculator
|
|
5
|
+
|
|
6
|
+
def compute(object = nil)
|
|
7
|
+
# Low level cache to avoid multiple calls since frenet returns all options in the first call
|
|
8
|
+
shipping_quotes = Rails.cache.fetch("#{object.order.number}/frenet_quotes", expires_in: 10.seconds) do
|
|
9
|
+
::Frenet::Api.get_shipping_quote(object)
|
|
10
|
+
end
|
|
11
|
+
get_rate_for_shipping_method(shipping_quotes)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_rate_for_shipping_method(shipping_quotes)
|
|
15
|
+
availabe_services = shipping_quotes["ShippingSevicesArray"].reject { |service| service["Error"] == true }
|
|
16
|
+
quote_for_method = availabe_services.detect { |service| service["ServiceCode"] == shipping_method_service_code }
|
|
17
|
+
return nil unless quote_for_method
|
|
18
|
+
{
|
|
19
|
+
delivery_business_days: quote_for_method["DeliveryTime"],
|
|
20
|
+
delivery_transit_business_days: quote_for_method["DeliveryTime"],
|
|
21
|
+
estimated_carrier_price: quote_for_method["ShippingPrice"],
|
|
22
|
+
cost: quote_for_method["ShippingPrice"],
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def shipping_method_service_code
|
|
27
|
+
# Constant defined on each shipping method calculator
|
|
28
|
+
self.class::FRENET_SERVICE_CODE
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require_dependency 'spree/calculator'
|
|
2
|
+
|
|
3
|
+
module Spree::Calculator::Shipping::Frenet
|
|
4
|
+
class PacMini < Spree::Calculator::Shipping::Frenet::Base
|
|
5
|
+
FRENET_SERVICE_CODE = '04227'
|
|
6
|
+
|
|
7
|
+
def self.description
|
|
8
|
+
"Frenet - Correios PAC Mini Envios"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class Frenet::Api
|
|
2
|
+
class << self
|
|
3
|
+
def get_shipping_quote(package)
|
|
4
|
+
body = {
|
|
5
|
+
"SellerCEP": package.stock_location.zipcode,
|
|
6
|
+
"RecipientCEP": package.order.ship_address.zipcode.gsub(/-/,""),
|
|
7
|
+
"ShipmentInvoiceValue": package.item_total,
|
|
8
|
+
"ShippingServiceCode": nil,
|
|
9
|
+
"ShippingItemArray": [
|
|
10
|
+
{
|
|
11
|
+
"Height": package.height,
|
|
12
|
+
"Length": package.depth,
|
|
13
|
+
"Width": package.width,
|
|
14
|
+
"Weight": package.weight,
|
|
15
|
+
"Quantity": 1
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"RecipientCountry": package.order.ship_address.country.iso
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Frenet::Request.new.post("/shipping/quote", body)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class Frenet::Request
|
|
2
|
+
def initialize; end
|
|
3
|
+
|
|
4
|
+
def get(path, body={})
|
|
5
|
+
response = request.get(path, body)
|
|
6
|
+
raise_error(response) unless response.success?
|
|
7
|
+
response.body
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def post(path, body={})
|
|
11
|
+
response = request.post(path, body)
|
|
12
|
+
raise_error(response) unless response.success?
|
|
13
|
+
response.body
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def request
|
|
19
|
+
@request ||= Faraday.new(url:"http://api.frenet.com.br") do |conn|
|
|
20
|
+
conn.request :json
|
|
21
|
+
conn.response :json
|
|
22
|
+
conn.adapter :net_http
|
|
23
|
+
conn.headers[:token] = ENV["FRENET_TOKEN"] || Rails.application.secrets.frenet_token
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def raise_error(response)
|
|
28
|
+
puts "SPREE_FRENET: Request returned the following error"
|
|
29
|
+
puts "Status: #{response.status}\nBody: #{response.body}"
|
|
30
|
+
raise "Status: #{response.status}\nBody: #{response.body}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
data/bin/rails
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" from the root of your extension
|
|
3
|
+
|
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/spree_frenet/engine', __FILE__)
|
|
6
|
+
|
|
7
|
+
require 'rails/all'
|
|
8
|
+
require 'rails/engine/commands'
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module SpreeFrenet
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
class_option :auto_run_migrations, type: :boolean, default: false
|
|
5
|
+
|
|
6
|
+
def add_javascripts
|
|
7
|
+
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_frenet\n"
|
|
8
|
+
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_frenet\n"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def add_stylesheets
|
|
12
|
+
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_frenet\n", before: %r{\*\/}, verbose: true
|
|
13
|
+
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_frenet\n", before: %r{\*\/}, verbose: true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add_migrations
|
|
17
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_frenet'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def run_migrations
|
|
21
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
|
|
22
|
+
if run_migrations
|
|
23
|
+
run 'bundle exec rake db:migrate'
|
|
24
|
+
else
|
|
25
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/spree_frenet.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module SpreeFrenet
|
|
2
|
+
class Engine < Rails::Engine
|
|
3
|
+
require 'spree/core'
|
|
4
|
+
isolate_namespace Spree
|
|
5
|
+
engine_name 'spree_frenet'
|
|
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
|
+
|
|
20
|
+
# Code to initializee calculators into Spree. It loads all calculators except base.rb
|
|
21
|
+
# Copied from Spree Active Shipping: https://github.com/spree-contrib/spree_active_shipping/blob/master/lib/spree_active_shipping/engine.rb#L30
|
|
22
|
+
initializer "spree_active_shipping.register.calculators", after: "spree.register.calculators" do |app|
|
|
23
|
+
if app.config.spree.calculators.shipping_methods
|
|
24
|
+
classes = Dir.chdir File.join(File.dirname(__FILE__), "../../app/models") do
|
|
25
|
+
Dir["spree/calculator/**/*.rb"].reject {|path| path =~ /base.rb$/ }.map do |path|
|
|
26
|
+
path.gsub('.rb', '').camelize.constantize
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
app.config.spree.calculators.shipping_methods.concat classes
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
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_frenet/factories'
|
|
6
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module SpreeFrenet
|
|
2
|
+
module_function
|
|
3
|
+
|
|
4
|
+
# Returns the version of the currently loaded SpreeFrenet as a
|
|
5
|
+
# <tt>Gem::Version</tt>.
|
|
6
|
+
def version
|
|
7
|
+
Gem::Version.new VERSION::STRING
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module VERSION
|
|
11
|
+
MAJOR = 0
|
|
12
|
+
MINOR = 1
|
|
13
|
+
TINY = 2
|
|
14
|
+
|
|
15
|
+
STRING = [MAJOR, MINOR, TINY].compact.join('.')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|
4
|
+
|
|
5
|
+
require 'spree_frenet/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.name = 'spree_frenet'
|
|
10
|
+
s.version = SpreeFrenet.version
|
|
11
|
+
s.summary = 'Shipping quotes using Frenet'
|
|
12
|
+
s.description = 'Spree extension with custom calculators to quote shipments via Frenet'
|
|
13
|
+
s.required_ruby_version = '>= 2.2.7'
|
|
14
|
+
|
|
15
|
+
s.author = 'Lucas Kuhn'
|
|
16
|
+
s.email = 'lucas@nordweg.com'
|
|
17
|
+
s.homepage = 'https://github.com/nordweg/spree_frenet'
|
|
18
|
+
s.license = 'BSD-3-Clause'
|
|
19
|
+
|
|
20
|
+
s.files = `git ls-files`.split("\n").reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
|
|
21
|
+
s.require_path = 'lib'
|
|
22
|
+
s.requirements << 'none'
|
|
23
|
+
|
|
24
|
+
spree_version = '>= 3.1.0', '< 4.0'
|
|
25
|
+
s.add_dependency 'spree_core', spree_version
|
|
26
|
+
s.add_dependency 'spree_backend', spree_version
|
|
27
|
+
s.add_dependency 'spree_extension'
|
|
28
|
+
|
|
29
|
+
s.add_development_dependency 'appraisal'
|
|
30
|
+
s.add_development_dependency 'capybara'
|
|
31
|
+
s.add_development_dependency 'capybara-screenshot'
|
|
32
|
+
s.add_development_dependency 'coffee-rails'
|
|
33
|
+
s.add_development_dependency 'database_cleaner'
|
|
34
|
+
s.add_development_dependency 'factory_bot'
|
|
35
|
+
s.add_development_dependency 'ffaker'
|
|
36
|
+
s.add_development_dependency 'mysql2'
|
|
37
|
+
s.add_development_dependency 'rspec-rails'
|
|
38
|
+
s.add_development_dependency 'sass-rails'
|
|
39
|
+
s.add_development_dependency 'selenium-webdriver'
|
|
40
|
+
s.add_development_dependency 'sqlite3'
|
|
41
|
+
s.add_development_dependency 'pg', '~> 0.18'
|
|
42
|
+
s.add_development_dependency 'simplecov'
|
|
43
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_frenet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lucas Kuhn
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree_core
|
|
@@ -265,7 +265,36 @@ email: lucas@nordweg.com
|
|
|
265
265
|
executables: []
|
|
266
266
|
extensions: []
|
|
267
267
|
extra_rdoc_files: []
|
|
268
|
-
files:
|
|
268
|
+
files:
|
|
269
|
+
- ".gitignore"
|
|
270
|
+
- ".rspec"
|
|
271
|
+
- ".rubocop.yml"
|
|
272
|
+
- ".travis.yml"
|
|
273
|
+
- Appraisals
|
|
274
|
+
- Gemfile
|
|
275
|
+
- LICENSE
|
|
276
|
+
- README.md
|
|
277
|
+
- Rakefile
|
|
278
|
+
- app/assets/javascripts/spree/backend/spree_frenet.js
|
|
279
|
+
- app/assets/javascripts/spree/frontend/spree_frenet.js
|
|
280
|
+
- app/assets/stylesheets/spree/backend/spree_frenet.css
|
|
281
|
+
- app/assets/stylesheets/spree/frontend/spree_frenet.css
|
|
282
|
+
- app/models/spree/calculator/shipping/frenet/azul.rb
|
|
283
|
+
- app/models/spree/calculator/shipping/frenet/base.rb
|
|
284
|
+
- app/models/spree/calculator/shipping/frenet/pac.rb
|
|
285
|
+
- app/models/spree/calculator/shipping/frenet/pac_mini.rb
|
|
286
|
+
- app/models/spree/calculator/shipping/frenet/sedex.rb
|
|
287
|
+
- app/services/frenet/api.rb
|
|
288
|
+
- app/services/frenet/request.rb
|
|
289
|
+
- bin/rails
|
|
290
|
+
- config/locales/en.yml
|
|
291
|
+
- config/routes.rb
|
|
292
|
+
- lib/generators/spree_frenet/install/install_generator.rb
|
|
293
|
+
- lib/spree_frenet.rb
|
|
294
|
+
- lib/spree_frenet/engine.rb
|
|
295
|
+
- lib/spree_frenet/factories.rb
|
|
296
|
+
- lib/spree_frenet/version.rb
|
|
297
|
+
- spree_frenet.gemspec
|
|
269
298
|
homepage: https://github.com/nordweg/spree_frenet
|
|
270
299
|
licenses:
|
|
271
300
|
- BSD-3-Clause
|