glysellin 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +100 -0
  4. data/Rakefile +29 -0
  5. data/app/assets/javascripts/glysellin/address.coffee +38 -0
  6. data/app/assets/javascripts/glysellin/async-cart.coffee +139 -0
  7. data/app/assets/javascripts/glysellin/base.js +6 -0
  8. data/app/assets/javascripts/glysellin/cart.coffee +54 -0
  9. data/app/assets/javascripts/glysellin/main.coffee +0 -0
  10. data/app/assets/javascripts/glysellin/product.coffee +0 -0
  11. data/app/assets/stylesheets/glysellin/application.css +13 -0
  12. data/app/assets/stylesheets/glysellin/orders.css +4 -0
  13. data/app/assets/stylesheets/glysellin/products.css +4 -0
  14. data/app/controllers/glysellin/cart/addresses_controller.rb +17 -0
  15. data/app/controllers/glysellin/cart/discount_code_controller.rb +10 -0
  16. data/app/controllers/glysellin/cart/payment_method_controller.rb +17 -0
  17. data/app/controllers/glysellin/cart/products_controller.rb +37 -0
  18. data/app/controllers/glysellin/cart/shipping_method_controller.rb +18 -0
  19. data/app/controllers/glysellin/cart/state_controller.rb +15 -0
  20. data/app/controllers/glysellin/cart_controller.rb +53 -0
  21. data/app/controllers/glysellin/orders_controller.rb +53 -0
  22. data/app/controllers/glysellin/products_controller.rb +12 -0
  23. data/app/helpers/glysellin/application_helper.rb +4 -0
  24. data/app/helpers/glysellin/cart_helper.rb +21 -0
  25. data/app/helpers/glysellin/orders_helper.rb +35 -0
  26. data/app/helpers/glysellin/products_helper.rb +4 -0
  27. data/app/mailers/glysellin/order_admin_mailer.rb +17 -0
  28. data/app/mailers/glysellin/order_customer_mailer.rb +27 -0
  29. data/app/models/glysellin/address.rb +35 -0
  30. data/app/models/glysellin/brand.rb +14 -0
  31. data/app/models/glysellin/discount_code.rb +36 -0
  32. data/app/models/glysellin/discount_type.rb +9 -0
  33. data/app/models/glysellin/order.rb +243 -0
  34. data/app/models/glysellin/order_adjustment.rb +19 -0
  35. data/app/models/glysellin/order_item.rb +38 -0
  36. data/app/models/glysellin/orderer.rb +28 -0
  37. data/app/models/glysellin/payment.rb +46 -0
  38. data/app/models/glysellin/payment_method.rb +36 -0
  39. data/app/models/glysellin/product.rb +136 -0
  40. data/app/models/glysellin/product_image.rb +11 -0
  41. data/app/models/glysellin/product_property.rb +22 -0
  42. data/app/models/glysellin/product_property_type.rb +11 -0
  43. data/app/models/glysellin/product_type.rb +11 -0
  44. data/app/models/glysellin/shipping_method.rb +22 -0
  45. data/app/models/glysellin/taxonomy.rb +35 -0
  46. data/app/models/glysellin/variant.rb +100 -0
  47. data/app/views/glysellin/cart/_added_to_cart_warning.html.erb +21 -0
  48. data/app/views/glysellin/cart/_cart.html.erb +13 -0
  49. data/app/views/glysellin/cart/_navigation.html.erb +11 -0
  50. data/app/views/glysellin/cart/_products.html.erb +125 -0
  51. data/app/views/glysellin/cart/_recap.html.erb +16 -0
  52. data/app/views/glysellin/cart/recap/_addresses.html.erb +13 -0
  53. data/app/views/glysellin/cart/recap/_products.html.erb +63 -0
  54. data/app/views/glysellin/cart/show.html.erb +13 -0
  55. data/app/views/glysellin/cart/states/_addresses.html.erb +25 -0
  56. data/app/views/glysellin/cart/states/_choose_payment_method.html.erb +14 -0
  57. data/app/views/glysellin/cart/states/_choose_shipping_method.html.erb +14 -0
  58. data/app/views/glysellin/cart/states/_filled.html.erb +3 -0
  59. data/app/views/glysellin/cart/states/_init.html.erb +5 -0
  60. data/app/views/glysellin/cart/states/_ready.html.erb +1 -0
  61. data/app/views/glysellin/order_admin_mailer/_order_header.text.erb +5 -0
  62. data/app/views/glysellin/order_admin_mailer/send_check_order_created_email.text.erb +8 -0
  63. data/app/views/glysellin/order_admin_mailer/send_order_paid_email.text.erb +8 -0
  64. data/app/views/glysellin/order_customer_mailer/_order_footer.text.erb +3 -0
  65. data/app/views/glysellin/order_customer_mailer/_order_header.text.erb +5 -0
  66. data/app/views/glysellin/order_customer_mailer/send_order_created_email.text.erb +7 -0
  67. data/app/views/glysellin/order_customer_mailer/send_order_paid_email.text.erb +7 -0
  68. data/app/views/glysellin/order_customer_mailer/send_order_shipped_email.text.erb +8 -0
  69. data/app/views/glysellin/orders/_addresses_fields.html.erb +29 -0
  70. data/app/views/glysellin/orders/_order.html.erb +18 -0
  71. data/app/views/glysellin/orders/_payment_canceled.html.erb +13 -0
  72. data/app/views/glysellin/orders/_payment_successful.html.erb +6 -0
  73. data/app/views/glysellin/orders/payment_response.html.erb +5 -0
  74. data/app/views/glysellin/payment_methods/_paypal-integral.html.erb +22 -0
  75. data/app/views/glysellin/products/_add_to_cart.html.erb +16 -0
  76. data/app/views/glysellin/products/_item.html.erb +21 -0
  77. data/app/views/glysellin/products/filter.html.erb +0 -0
  78. data/app/views/glysellin/products/index.html.erb +3 -0
  79. data/app/views/glysellin/products/show.html.erb +3 -0
  80. data/app/views/glysellin/shared/_address.html.erb +11 -0
  81. data/app/views/glysellin/shared/_address.text.erb +7 -0
  82. data/app/views/glysellin/shared/_order.text.erb +56 -0
  83. data/app/views/glysellin/shared/mailer/_footer.text.erb +2 -0
  84. data/app/views/layouts/glysellin/application.html.erb +14 -0
  85. data/config/locales/glysellin.en.yml +113 -0
  86. data/config/locales/glysellin.fr.yml +119 -0
  87. data/db/migrate/20120206115004_create_glysellin_orders.rb +16 -0
  88. data/db/migrate/20120206115132_create_glysellin_customers.rb +8 -0
  89. data/db/migrate/20120206115657_create_glysellin_addresses.rb +22 -0
  90. data/db/migrate/20120206124505_create_glysellin_products.rb +20 -0
  91. data/db/migrate/20120206124545_create_glysellin_order_items.rb +15 -0
  92. data/db/migrate/20120206124630_create_glysellin_product_images.rb +10 -0
  93. data/db/migrate/20120206125210_add_attachment_image_to_product_image.rb +15 -0
  94. data/db/migrate/20120206130920_create_glysellin_payments.rb +13 -0
  95. data/db/migrate/20120206131042_create_glysellin_payment_methods.rb +10 -0
  96. data/db/migrate/20120207175050_create_glysellin_taxonomies.rb +11 -0
  97. data/db/migrate/20120207175158_create_products_taxonomies_table.rb +12 -0
  98. data/db/migrate/20120515143231_create_brands.rb +9 -0
  99. data/db/migrate/20120515143233_add_attachment_image_to_brands.rb +15 -0
  100. data/db/migrate/20120620151705_create_product_properties.rb +12 -0
  101. data/db/migrate/20130204121211_create_glysellin_discount_types.rb +10 -0
  102. data/db/migrate/20130204121228_create_glysellin_discount_codes.rb +15 -0
  103. data/db/migrate/20130204125310_create_glysellin_order_adjustments.rb +13 -0
  104. data/db/migrate/20130204202102_create_glysellin_shipping_methods.rb +12 -0
  105. data/db/migrate/20130204202109_add_shipping_method_id_to_glysellin_orders.rb +5 -0
  106. data/db/migrate/20130205110036_add_weight_to_glysellin_products.rb +5 -0
  107. data/db/migrate/20130205120541_add_weight_to_glysellin_order_items.rb +5 -0
  108. data/db/migrate/20130208162813_create_glysellin_variants.rb +17 -0
  109. data/db/migrate/20130208165020_create_glysellin_product_property_types.rb +7 -0
  110. data/db/migrate/20130211105557_add_type_id_to_glysellin_product_properties.rb +5 -0
  111. data/db/migrate/20130211112302_add_variant_id_to_glysellin_product_properties.rb +13 -0
  112. data/db/migrate/20130211152651_add_product_id_to_glysellin_variants.rb +5 -0
  113. data/db/migrate/20130212131658_add_weight_to_glysellin_variants.rb +5 -0
  114. data/db/migrate/20130212132253_remove_variant_columns_from_glysellin_products.rb +15 -0
  115. data/db/migrate/20130212154943_remove_eot_price_from_glysellin_products.rb +9 -0
  116. data/db/migrate/20130214184204_create_glysellin_product_types.rb +9 -0
  117. data/db/migrate/20130214184352_create_product_type_behavior.rb +15 -0
  118. data/db/migrate/20130221102200_add_unmarked_price_to_glysellin_variants.rb +5 -0
  119. data/db/migrate/20130311135842_add_addressable_to_glysellin_addresses.rb +6 -0
  120. data/db/migrate/20130314114048_change_addressable_associations_in_glysellin_addresses.rb +15 -0
  121. data/db/migrate/20130325113903_remove_address_ids_from_glysellin_orders.rb +11 -0
  122. data/db/seeds/shipping_carrier/rates/colissimo.csv +16 -0
  123. data/db/seeds/shipping_carrier/rates/lettre-max.csv +9 -0
  124. data/lib/active_model/model.rb +101 -0
  125. data/lib/generators/glysellin/install/USAGE +8 -0
  126. data/lib/generators/glysellin/install/install_generator.rb +50 -0
  127. data/lib/generators/glysellin/install/templates/initializer.rb +119 -0
  128. data/lib/generators/glysellin/install/templates/order_observer.rb +12 -0
  129. data/lib/generators/glysellin/install/utils.rb +11 -0
  130. data/lib/glysellin.rb +124 -0
  131. data/lib/glysellin/acts_as_sellable.rb +14 -0
  132. data/lib/glysellin/cart.rb +21 -0
  133. data/lib/glysellin/cart/address.rb +16 -0
  134. data/lib/glysellin/cart/adjustment.rb +17 -0
  135. data/lib/glysellin/cart/adjustment/base.rb +41 -0
  136. data/lib/glysellin/cart/adjustment/discount_code.rb +43 -0
  137. data/lib/glysellin/cart/adjustment/shipping_method.rb +31 -0
  138. data/lib/glysellin/cart/basket.rb +482 -0
  139. data/lib/glysellin/cart/customer.rb +36 -0
  140. data/lib/glysellin/cart/model_wrapper.rb +90 -0
  141. data/lib/glysellin/cart/nested_resource.rb +39 -0
  142. data/lib/glysellin/cart/payment_method.rb +8 -0
  143. data/lib/glysellin/cart/product.rb +16 -0
  144. data/lib/glysellin/cart/select.rb +31 -0
  145. data/lib/glysellin/cart/serializable.rb +30 -0
  146. data/lib/glysellin/cart/shipping_method.rb +8 -0
  147. data/lib/glysellin/discount_type_calculator.rb +7 -0
  148. data/lib/glysellin/discount_type_calculator/base.rb +30 -0
  149. data/lib/glysellin/discount_type_calculator/order_percentage.rb +16 -0
  150. data/lib/glysellin/engine.rb +14 -0
  151. data/lib/glysellin/engine/routes.rb +61 -0
  152. data/lib/glysellin/gateway.rb +16 -0
  153. data/lib/glysellin/gateway/atos.rb +111 -0
  154. data/lib/glysellin/gateway/base.rb +43 -0
  155. data/lib/glysellin/gateway/check.rb +34 -0
  156. data/lib/glysellin/gateway/paypal_integral.rb +71 -0
  157. data/lib/glysellin/helpers.rb +15 -0
  158. data/lib/glysellin/helpers/controller.rb +22 -0
  159. data/lib/glysellin/helpers/countries.rb +261 -0
  160. data/lib/glysellin/helpers/views.rb +28 -0
  161. data/lib/glysellin/product_methods.rb +66 -0
  162. data/lib/glysellin/products_list.rb +72 -0
  163. data/lib/glysellin/property_finder.rb +13 -0
  164. data/lib/glysellin/shipping_carrier.rb +14 -0
  165. data/lib/glysellin/shipping_carrier/base.rb +55 -0
  166. data/lib/glysellin/shipping_carrier/colissimo.rb +19 -0
  167. data/lib/glysellin/shipping_carrier/flat_rate.rb +19 -0
  168. data/lib/glysellin/shipping_carrier/free_shipping.rb +14 -0
  169. data/lib/glysellin/shipping_carrier/helpers/country_weight_table.rb +65 -0
  170. data/lib/glysellin/shipping_carrier/lettre_max.rb +19 -0
  171. data/lib/glysellin/version.rb +3 -0
  172. data/lib/tasks/glysellin_tasks.rake +37 -0
  173. metadata +341 -0
@@ -0,0 +1,28 @@
1
+ module Glysellin
2
+ module Helpers
3
+ module Views
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ helper_method :flatten_products
8
+ end
9
+
10
+ # Creates a list of all items and replaces bundles by their sub items
11
+ # Flattens only one level of sub products
12
+ #
13
+ # @param [Array] products The products array to flatten
14
+ #
15
+ # @return [Array] The flattened list of products
16
+ #
17
+ def flatten_products products
18
+ products.reduce([]) do |list, product|
19
+ if product.bundle?
20
+ list += product.bundled_products
21
+ else
22
+ list << product
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,66 @@
1
+ module Glysellin
2
+ module ProductMethods
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ attr_writer :bundle_attributes
7
+
8
+ def bundle_attributes
9
+ @bundle_attributes ||= {}
10
+ end
11
+
12
+ def bundle_attribute attribute, &block
13
+ # Store block to be called to retrieve
14
+ self.bundle_attributes[attribute.to_sym] = block
15
+
16
+ class_eval <<-CLASS, __FILE__, __LINE__
17
+ def bundle_#{ attribute }
18
+ if bundled_products.length > 0
19
+ self.class.bundle_attributes[:#{ attribute }].call(self)
20
+ end
21
+ end
22
+
23
+ def #{ attribute }
24
+ value = super
25
+ value = bundle_#{ attribute } if value == nil
26
+ value
27
+ end
28
+
29
+ def #{ attribute }=(value)
30
+ super(value) if value != bundle_#{ attribute }
31
+ end
32
+ CLASS
33
+ end
34
+ end
35
+
36
+ # SKU generation helper
37
+ #
38
+ # @return [String] The generated SKU
39
+ def generate_sku
40
+ # Get last product only selecting id
41
+ last_item = self.class.select(:id).order('id DESC').first
42
+ # Generate SKU from the last product id we got,
43
+ # or appending "1" if there's no product
44
+ sku = (last_item ? (last_item.id + 1).to_s : '1')
45
+ sku += self.name.parameterize
46
+ end
47
+
48
+ # Checks if a product is a bundle of other sub products
49
+ #
50
+ # @return [true, false]
51
+ def bundle?
52
+ false
53
+ # bundled_products.length > 0
54
+ end
55
+
56
+ # Gives calculable vat rate
57
+ #
58
+ # Example :
59
+ # If vat_rate is set to 19.6%, returns back 1.196
60
+ #
61
+ # @return [Float] The processed VAT rate
62
+ def vat_ratio
63
+ 1 + vat_rate / 100
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,72 @@
1
+ module Glysellin
2
+ module ProductsList
3
+ extend ActiveSupport::Concern
4
+
5
+ def quantified_items
6
+ raise "You should implement `#quantified_items` in any class including Glysellin::ProductsList"
7
+ end
8
+
9
+ def each_items &block
10
+ if block_given?
11
+ quantified_items.each &block
12
+ else
13
+ quantified_items.each
14
+ end
15
+ end
16
+
17
+ # Gets order subtotal from items only
18
+ #
19
+ # @param [Boolean] df Defines if we want to get duty free price or not
20
+ #
21
+ # @return [BigDecimal] the calculated subtotal
22
+ #
23
+ def subtotal
24
+ quantified_items.reduce(0) do |total, quantified_item|
25
+ item, quantity = quantified_item
26
+ total + (item.price * quantity)
27
+ end
28
+ end
29
+
30
+ def eot_subtotal
31
+ quantified_items.reduce(0) do |total, quantified_item|
32
+ item, quantity = quantified_item
33
+ total + (item.eot_price * quantity)
34
+ end
35
+ end
36
+
37
+ def total_weight
38
+ each_items.reduce(0) do |total, quantified_item|
39
+ item, quantity = quantified_item
40
+ weight = item.weight.presence || Glysellin.default_product_weight
41
+ total + (quantity * weight)
42
+ end
43
+ end
44
+
45
+ def adjustments
46
+ respond_to?(:order_adjustments) ? order_adjustments : []
47
+ end
48
+
49
+ def adjustments_total
50
+ adjustments.reduce(0) do |total, adj|
51
+ total + adj.value.to_f
52
+ end
53
+ end
54
+
55
+ def eot_adjustments_total
56
+ adjustments_total * (eot_subtotal / subtotal)
57
+ end
58
+
59
+ # Gets order total price from subtotal and adjustments
60
+ #
61
+ # @param [Boolean] df Defines if we want to get duty free price or not
62
+ #
63
+ # @return [BigDecimal] the calculated total price
64
+ def total_price
65
+ (subtotal + adjustments_total).round(2)
66
+ end
67
+
68
+ def total_eot_price
69
+ (eot_subtotal + eot_adjustments_total).round(2)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,13 @@
1
+ module Glysellin
2
+ module PropertyFinder
3
+ def method_missing method, *args, &block
4
+ if (prop = find { |prop| prop.type.name == method.to_s })
5
+ prop.value
6
+ elsif Glysellin::ProductPropertyType.select('1').find_by_name(method)
7
+ false
8
+ else
9
+ super(method, *args, &block)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ require 'glysellin/shipping_carrier/helpers/country_weight_table'
2
+
3
+ module Glysellin
4
+ module ShippingCarrier
5
+ end
6
+ end
7
+
8
+ # Base class and helpers
9
+ require 'glysellin/shipping_carrier/base'
10
+
11
+ # Shipping Carriers
12
+ require 'glysellin/shipping_carrier/colissimo'
13
+ require 'glysellin/shipping_carrier/lettre_max'
14
+ require 'glysellin/shipping_carrier/free_shipping'
@@ -0,0 +1,55 @@
1
+ module Glysellin
2
+
3
+ def self.shipping_carriers
4
+ Hash[ShippingCarrier.shipping_carriers_list.map { |sc| [sc[:name], sc[:carrier]] }]
5
+ end
6
+
7
+ def shipping_carrier &block
8
+ if block_given?
9
+ ShippingCarrier.config &block
10
+ else
11
+ ShippingCarrier
12
+ end
13
+ end
14
+
15
+ module ShippingCarrier
16
+ extend AbstractController::Rendering
17
+
18
+ # List of available gateways in the app
19
+ mattr_accessor :shipping_carriers_list
20
+ @@shipping_carriers_list = []
21
+
22
+ class Base
23
+ class << self
24
+ def register name, carrier
25
+ ShippingCarrier.shipping_carriers_list << { :name => name, :carrier => carrier }
26
+ end
27
+
28
+ def config
29
+ yield self
30
+ end
31
+ end
32
+
33
+ @@config_file = nil
34
+
35
+ def initialize
36
+ raise "Config file is not defined for #{ self.name } shipping method" unless @@config_file
37
+ @config = YAML.load(File.read @@config_file)['config']
38
+ end
39
+
40
+ def rate order
41
+ @config.each do |item|
42
+ if item['countries'].split(',').include?(order.shipping_address.country)
43
+ return process_rate(order, item['rates'])
44
+ end
45
+ end
46
+ # Return nil if country not accepted
47
+ nil
48
+ end
49
+
50
+ def process_rate order, rates
51
+
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,19 @@
1
+ module Glysellin
2
+ module ShippingCarrier
3
+ class Colissimo < Base
4
+ include Helpers::CountryWeightTable
5
+
6
+ register 'colissimo', self
7
+
8
+ country_weight_table_file 'colissimo.csv'
9
+
10
+ def initialize order
11
+ @order = order
12
+ end
13
+
14
+ def calculate
15
+ price_for_weight_and_country
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Glysellin
2
+ module ShippingCarrier
3
+ class FlatRate < Base
4
+ register 'flat-rate', self
5
+
6
+ def price_for_order order
7
+ total_items = order.products.reduce(0) do |total, item|
8
+ total + item.quantity
9
+ end
10
+
11
+ price_for_items_quantity(total_items)
12
+ end
13
+
14
+ def price_for_items_quantity quantity
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module Glysellin
2
+ module ShippingCarrier
3
+ class FreeShipping < Base
4
+ register 'free-shipping', self
5
+
6
+ def initialize order
7
+ end
8
+
9
+ def calculate
10
+ 0
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,65 @@
1
+ module Glysellin
2
+ module ShippingCarrier
3
+ module Helpers
4
+ module CountryWeightTable
5
+ extend ActiveSupport::Concern
6
+
7
+ module ClassMethods
8
+ attr_accessor :path_to_data
9
+
10
+ def country_weight_table_file path
11
+ loadable_paths = [File.join(ENV['PWD'], 'lib')] + $LOAD_PATH
12
+ # Try to find table file in load path
13
+ loadable_paths.each do |loadable_path|
14
+ file = File.join(loadable_path, '..', 'db', 'seeds', 'shipping_carrier', 'rates', path)
15
+ if File.exists?(file)
16
+ @path_to_data = file
17
+ return
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ def price_for_weight_and_country
24
+ weight = @order.total_weight
25
+ country = @order.use_another_address_for_shipping ?
26
+ @order.shipping_address.country : @order.billing_address.country
27
+
28
+ zone = prices_data.find do |zone|
29
+ zone[:countries].include?(country)
30
+ end
31
+
32
+ if zone
33
+ weight_price = zone[:prices].find do |max_weight, price|
34
+ weight < max_weight
35
+ end
36
+
37
+ weight_price.last if weight_price
38
+ end
39
+ end
40
+
41
+ def prices_data
42
+ return @prices if @prices
43
+
44
+ csv = CSV.parse File.read self.class.path_to_data
45
+
46
+ @prices = csv.shift[1..-1].map do |c|
47
+ {
48
+ countries: c.split(",").map(&:strip),
49
+ prices: {}
50
+ }
51
+ end
52
+
53
+ csv.each do |row|
54
+ max_weight = row.shift.to_f
55
+ row.each_with_index do |cell, index|
56
+ @prices[index][:prices][max_weight] = cell.presence ? cell.to_f : cell
57
+ end
58
+ end
59
+
60
+ @prices
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,19 @@
1
+ module Glysellin
2
+ module ShippingCarrier
3
+ class LettreMax < Glysellin::ShippingCarrier::Base
4
+ include Helpers::CountryWeightTable
5
+
6
+ register 'lettre-max', self
7
+
8
+ country_weight_table_file 'lettre-max.csv'
9
+
10
+ def initialize order
11
+ @order = order
12
+ end
13
+
14
+ def calculate
15
+ price_for_weight_and_country
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Glysellin
2
+ VERSION = "0.4.1"
3
+ end
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+ require 'fileutils'
3
+
4
+ namespace :glysellin do
5
+ task :seed => :environment do
6
+ [['Chèque', 'check'],
7
+ ['Paypal', 'paypal-integral'],
8
+ ['Atos', 'atos']].each do |payment_method|
9
+ attributes = Hash[[:name, :slug].zip(payment_method)]
10
+ Glysellin::PaymentMethod.create(attributes)
11
+ puts "Created payment method : #{ attributes[:name] }"
12
+ end
13
+
14
+ [
15
+ { name: 'Colissimo', identifier: 'colissimo' },
16
+ { name: 'Lettre Max', identifier: 'lettre-max' },
17
+ { name: 'Frais de ports Offerts', identifier: 'free-shipping' }
18
+ ].each do |attributes|
19
+ Glysellin::ShippingMethod.create! attributes
20
+ end
21
+
22
+ Glysellin::DiscountType.create!(
23
+ name: 'Order percentage', identifier: 'order-percentage'
24
+ )
25
+ end
26
+
27
+ task :copy_views => :environment do
28
+ folder = %w(app views glysellin)
29
+ source_dir = File.expand_path(File.join('..', '..', '..', *folder), __FILE__)
30
+ dest_dir = Rails.root.join(*folder)
31
+ print "Copying glysellin views folder to #{ dest_dir } ... "
32
+
33
+ FileUtils.cp_r source_dir, dest_dir
34
+
35
+ puts 'done !'
36
+ end
37
+ end