spree_yandex_market 1.1.1 → 1.2.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.
@@ -3,21 +3,21 @@
3
3
  Экспорт товаров в Яндекс.Маркет
4
4
  ==============================
5
5
  Расширение предназначено для выгрузки списка товара в Яндекс.Маркет.(http://partner.market.yandex.ru/legal/tt/)
6
- При экспорте передаеться следующая информация:
6
+ При экспорте передается следующая информация:
7
7
  1. Название магазина и его url.
8
8
  2. Валюты используемые в магазине.
9
9
  3. Категории товара.
10
10
  В качестве категорий выгружаемых в файл используется один из 'Таксонов', который задается в админке Яндекс.Маркет.
11
11
  4. Список товара.
12
12
  При выгрузке Товар может быть описан несколькими типами:
13
- 1. "vendor.model" - Основной тип описания, рекомендуемый
13
+ 1. "vendor.model" - основной тип описания, рекомендуемый
14
14
  2. "book", "audiobook" - для книг и аудиокниг
15
15
  3. "music", "video" - для музыки и видео
16
16
  4. "event_ticket" - билеты на мероприятия
17
- Определение типа описания происходит следующим образом: если в свойстве товара,которое определено
17
+ Определение типа описания происходит следующим образом: если в свойстве товара, которое определено
18
18
  в "Типе продукции" (Wares Type), одно из следующих значений ["book", "audiobook", "music", "video",
19
- "event_ticket"] то товар выгружается в соответствии с типом продукции, если свойство "тип продукции"
20
- не определено или нет нужного значения ,то описыаеться по основному типу "vendor.model"
19
+ "event_ticket"], то товар выгружается в соответствии с типом продукции, если свойство "тип продукции"
20
+ не определено или нет нужного значения, то описывается по основному типу "vendor.model"
21
21
 
22
22
 
23
23
  Формирование файла экспорта:
@@ -25,7 +25,7 @@
25
25
  Файл формируется следующей командой: RAILS_ENV=#{RAILS_ENV} rake spree:extensions:yandex_market:generate_ym
26
26
  Сформированные файлы сохраняются в папку ROOT_RAILS/public/yandex_market с формируемым именем
27
27
  файла "yandex_market_%Y_%m_%d__%H_%M".
28
- Для Яндекс.Робота создаться линк на самый последний файл ROOT_RAILS/public/yandex_market/yandex_market.gz,
28
+ Для Яндекс.Робота создается линк на самый последний файл ROOT_RAILS/public/yandex_market/yandex_market.gz,
29
29
  который доступен по адресу http://[host]/yandex_market/yandex_market.gz
30
30
  Формирование файла можно делать через крон или запуском команды из блока администрирования.
31
31
 
@@ -45,8 +45,8 @@
45
45
  В основных настройках устанавливается название и адрес магазина, выгружаемая категория и отбор
46
46
  товара при выгрузке.
47
47
  В настройках валюты устанавливается список валют используемых в магазине.
48
- В настройке "Выгружаемые свойства товара" - сопоставляются выгружаемые данные со свойствами товара.
49
- Также для настроек можно использовать следующий синтаксис: YandexMarket::Config.set(:number_of_files => 10)
48
+ В настройке "Выгружаемые свойства товара" - сопоставляются выгружаемые данные со свойствами товара.
49
+ Также для настроек можно использовать следующий синтаксис: Spree::YandexMarket::Config.set(:number_of_files => 10)
50
50
 
51
51
 
52
52
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
6
6
  require 'rake/packagetask'
7
7
  require 'rake/gempackagetask'
8
8
 
9
- spec = eval(File.read('yandex_market.gemspec'))
9
+ spec = eval(File.read('spree_yandex_market.gemspec'))
10
10
 
11
11
  Rake::GemPackageTask.new(spec) do |p|
12
12
  p.gem_spec = spec
@@ -1,10 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
- class Admin::YandexMarketsController < Admin::BaseController
2
+ class Admin::YandexMarketSettingsController < Admin::BaseController
3
3
  before_filter :get_config
4
4
 
5
5
  def show
6
6
  @taxons = Taxon.roots
7
7
  end
8
+
8
9
  def general
9
10
  @taxons = Taxon.roots
10
11
  end
@@ -19,21 +20,20 @@ class Admin::YandexMarketsController < Admin::BaseController
19
20
  def export_files
20
21
  directory = File.join(Rails.root, 'public', 'yandex_market', '**', '*')
21
22
  # нельзя вызывать стат, не удостоверившись в наличии файла!!111
22
- @export_files = Dir[directory].map {|x| [File.basename(x), (File.file?(x) ? File.mtime(x).to_i : 0)] }.
23
+ @export_files = Dir[directory].map {|x| [File.basename(x), (File.file?(x) ? File.mtime(x) : 0)] }.
23
24
  sort{|x,y| y.last <=> x.last }
24
- e =@export_files.find {|x| x.first == "yandex_market.xml" }
25
+ e = @export_files.find {|x| x.first == "yandex_market.xml" }
25
26
  @export_files.reject! {|x| x.first == "yandex_market.xml" }
26
27
  @export_files.unshift(e) unless e.blank?
27
28
  end
28
29
 
29
30
  def run_export
30
- command = %{cd #{ RAILS_ROOT } && RAILS_ENV=#{RAILS_ENV} rake spree:extensions:yandex_market:generate_ym &}
31
+ command = %{cd #{Rails.root} && RAILS_ENV=#{Rails.env} rake spree_yandex_market:generate_ym &}
31
32
  logger.info "[ yandex market ] Запуск формирование файла экспорта из блока администрирования "
32
33
  logger.info "[ yandex market ] команда - #{command} "
33
34
  system command
34
- # Временно убрано для перехода на Rails 3
35
- # render :text => "Обновите страницу через несколько минут.", :status => :ok, :layout => false
36
- redirect_to export_files_admin_yandex_markets_url
35
+ flash[:notice] = "Обновите страницу через несколько минут."
36
+ redirect_to export_files_admin_yandex_market_settings_url
37
37
  end
38
38
 
39
39
  def update
@@ -42,7 +42,7 @@ class Admin::YandexMarketsController < Admin::BaseController
42
42
 
43
43
  respond_to do |format|
44
44
  format.html {
45
- redirect_to admin_yandex_markets_path
45
+ redirect_to admin_yandex_market_settings_path
46
46
  }
47
47
  end
48
48
  end
@@ -50,6 +50,6 @@ class Admin::YandexMarketsController < Admin::BaseController
50
50
  private
51
51
 
52
52
  def get_config
53
- @config = YandexMarket::Config.instance
53
+ @config = Spree::YandexMarket::Config.instance
54
54
  end
55
55
  end
@@ -41,7 +41,7 @@ class YandexMarketConfiguration < Configuration
41
41
  preference :media , :string # Носитель
42
42
  preference :starring , :string # Актеры
43
43
  preference :director , :string # Режиссер
44
- preference :orginal_name , :string # Оригинальное наименовани
44
+ preference :original_name , :string # Оригинальное наименовани
45
45
  preference :video_country, :string # Страна
46
46
 
47
47
  # wares property Билеты
@@ -1,6 +1,6 @@
1
- <%= render :partial => 'admin/yandex_markets/shared/configuration_menu' %>
1
+ <%= render :partial => 'admin/yandex_market_settings/shared/configuration_menu' %>
2
2
  <%= content_tag :h3, t('configure_yandex_market.list_currency'), :class => "name" %>
3
- <% form_tag(admin_yandex_markets_path, :method => :put) do -%>
3
+ <% form_tag(admin_yandex_market_settings_path, :method => :put) do -%>
4
4
  <label for="preferences_preferred_currency">
5
5
  <%= t('configure_yandex_market.currency') %>
6
6
  <%= text_field_tag('preferences[preferred_currency]', @config.preferred_currency, :size => 50) %>
@@ -34,6 +34,6 @@
34
34
  </div>
35
35
  <p class="form-buttons">
36
36
  <%= button t('update') %>
37
- <%= t("or") %> <%= link_to t("cancel"), admin_yandex_markets_url %>
37
+ <%= t("or") %> <%= link_to t("cancel"), admin_yandex_market_settings_url %>
38
38
  </p>
39
39
  <% end -%>
@@ -1,8 +1,8 @@
1
- <%= render :partial => 'admin/yandex_markets/shared/configuration_menu' %>
1
+ <%= render :partial => 'admin/yandex_market_settings/shared/configuration_menu' %>
2
2
  <div class='toolbar'>
3
3
  <ul class='actions'>
4
4
  <li id="new_ot_link">
5
- <%= link_to t('configure_yandex_market.run_generate_file'), run_export_admin_yandex_markets_path %>
5
+ <%= link_to t('configure_yandex_market.run_generate_file'), run_export_admin_yandex_market_settings_path %>
6
6
 
7
7
  </li>
8
8
  </ul>
@@ -19,7 +19,7 @@
19
19
  <% @export_files && @export_files.each do |ef| -%>
20
20
  <tr>
21
21
  <td><%= ef.first %></td>
22
- <td><%= ef.last.to_s(:long) %></td>
22
+ <td><%= ef.last %></td>
23
23
  <td class="actions"><%= link_to t("configure_yandex_market.download"), url_for("/yandex_market/#{ef.first}") %> </td>
24
24
  </tr>
25
25
  <% end -%>
@@ -1,6 +1,6 @@
1
- <%= render :partial => 'admin/yandex_markets/shared/configuration_menu' %>
1
+ <%= render :partial => 'admin/yandex_market_settings/shared/configuration_menu' %>
2
2
  <%= content_tag :h3, t('configure_yandex_market.general'), :class => "name" %>
3
- <% form_tag(admin_yandex_markets_path, :method => :put) do -%>
3
+ <% form_tag(admin_yandex_market_settings_path, :method => :put) do -%>
4
4
  <fieldset>
5
5
  <label for="preferences_preferred_short_name">
6
6
  <%= t('configure_yandex_market.short_name') %>
@@ -51,6 +51,6 @@
51
51
  </fieldset>
52
52
  <p class="form-buttons">
53
53
  <%= button t('update') %>
54
- <%= t("or") %> <%= link_to t("cancel"), admin_yandex_markets_url %>
54
+ <%= t("or") %> <%= link_to t("cancel"), admin_yandex_market_settings_url %>
55
55
  </p>
56
56
  <% end -%>
@@ -0,0 +1,23 @@
1
+ <% content_for :sidebar do %>
2
+ <%= content_tag :h3, t('configure_yandex_market.title'), :class => "name" %>
3
+ <br class="clear" />
4
+
5
+ <ul class="sidebar">
6
+ <%= content_tag :li, :class => (params[:action] == "general" ? "active": "") do -%>
7
+ <%= link_to t("configure_yandex_market.general"), general_admin_yandex_market_settings_path %>
8
+ <% end -%>
9
+
10
+ <%= content_tag :li, :class => (params[:action] == "currency" ? "active": "") do -%>
11
+ <%= link_to t("configure_yandex_market.list_currency") , currency_admin_yandex_market_settings_path %>
12
+ <% end -%>
13
+
14
+ <%= content_tag :li, :class => (params[:action] == "export_files" ? "active": "") do -%>
15
+ <%= link_to t("configure_yandex_market.export_files"),export_files_admin_yandex_market_settings_path %>
16
+ <% end -%>
17
+
18
+
19
+ <%= content_tag :li, :class => (params[:action] == "ware_property" ? "active": "") do -%>
20
+ <%= link_to t("configure_yandex_market.ware_property"),ware_property_admin_yandex_market_settings_path %>
21
+ <% end -%>
22
+ </ul>
23
+ <% end -%>
@@ -1,4 +1,4 @@
1
- <%= render :partial => 'admin/yandex_markets/shared/configuration_menu' %>
1
+ <%= render :partial => 'admin/yandex_market_settings/shared/configuration_menu' %>
2
2
  <table>
3
3
  <tr>
4
4
  <th scope="row"><%= t 'configure_yandex_market.short_name_small' %>:</th>
@@ -1,14 +1,14 @@
1
- <%= render :partial => 'admin/yandex_markets/shared/configuration_menu' %>
1
+ <%= render :partial => 'admin/yandex_market_settings/shared/configuration_menu' %>
2
2
 
3
3
  <%= content_tag :h3, t('configure_yandex_market.ware_property'), :class => "name" %>
4
4
 
5
- <% form_tag(admin_yandex_markets_path, :method => :put) do -%>
5
+ <% form_tag(admin_yandex_market_settings_path, :method => :put) do -%>
6
6
  <fieldset>
7
7
  <legend><span><%= t('configure_yandex_market.field_for') %></span></legend>
8
- <label><%= radio_button_tag 'wares_type', 'basic', true %> Основные</label>
8
+ <label><%= radio_button_tag 'wares_type', 'simple', true %> Основные</label>
9
9
  <label><%= radio_button_tag 'wares_type', 'book' %> Книги </label>
10
10
  <label><%= radio_button_tag 'wares_type', 'music_video' %> Музыка/Видео </label>
11
- <label><%= radio_button_tag 'wares_type', 'event_ticket' %> Билетов на мероприятия</label>
11
+ <label><%= radio_button_tag 'wares_type', 'event_ticket' %> Билеты на мероприятия</label>
12
12
  </fieldset>
13
13
 
14
14
  <fieldset class="fields" id="basic">
@@ -43,7 +43,7 @@
43
43
  <fieldset class="fields" id="music_video" style="display:none;">
44
44
  <legend><span><%= t('configure_yandex_market.music_video_property') %></span></legend>
45
45
  <table class="index">
46
- <% %w{ artist title music_video_year media starring director orginal_name video_country }.each do |property| -%>
46
+ <% %w{ artist title music_video_year media starring director original_name video_country }.each do |property| -%>
47
47
  <tr>
48
48
  <td><%= t("configure_yandex_market.#{property}") %>:</td>
49
49
  <td>
@@ -73,7 +73,7 @@
73
73
 
74
74
  <p class="form-buttons">
75
75
  <%= button t('update') %>
76
- <%= t("or") %> <%= link_to t("cancel"), admin_yandex_markets_url %>
76
+ <%= t("or") %> <%= link_to t("cancel"), admin_yandex_market_settings_url %>
77
77
  </p>
78
78
  <% end -%>
79
79
  <script type="text/javascript" charset="utf-8">
@@ -14,7 +14,7 @@ ru:
14
14
  what_wares_export: Какой товар выгружать в Яндекс.Маркет
15
15
  all_active_wares: Весь активный товар
16
16
  on_hand_wares: Только товар который есть в наличии
17
- run_generate_file: Запусить формирование файла
17
+ run_generate_file: Запустить формирование файла
18
18
  download: Скачать
19
19
  name: Наименование
20
20
  date: Дата\Время
@@ -24,17 +24,17 @@ ru:
24
24
  vendor_code: Код производителя
25
25
  country_of_manufacturer: Страна-производитель
26
26
  type_prefix: Группа товаров\категория
27
- manufacturer_warranty: Есть официальная гарантию производителя
27
+ manufacturer_warranty: Есть официальная гарантия производителя
28
28
  local_delivery_cost: Стоимость доставки по своему региону
29
- short_name: Короткое название магазина( не более 20 символов)
30
- full_name: Полное наименование компании, владеющей магазином.
29
+ short_name: Короткое название магазина (не более 20 символов)
30
+ full_name: Полное наименование компании, владеющей магазином
31
31
  short_name_small: Короткое название магазина
32
32
  full_name_small: Полное наименование компании
33
33
  url: URL-адрес главной страницы магазина
34
34
  wares_type: Тип продукции
35
35
  basic_property: Поля для основного описания товара
36
36
  field_for: Поля для типа описания
37
- book_property: "Поля для описание типа 'книга', 'аудиокнига' "
37
+ book_property: "Поля для описания типа 'книга', 'аудиокнига' "
38
38
  author: Автор книги
39
39
  publisher: Издательство
40
40
  series: Серия
@@ -44,10 +44,10 @@ ru:
44
44
  part: Номер тома
45
45
  language: Язык произведения
46
46
  binding: Переплет
47
- page_extent: Количествово страниц в книге
47
+ page_extent: Количество страниц в книге
48
48
  performed_by: Исполнитель для аудиокниги
49
49
  storage: Носитель аудиокниги
50
- format: Формат аудиокниги.
50
+ format: Формат аудиокниги
51
51
  recording_length: Время звучания
52
52
  artist: Исполнитель
53
53
  title: Наименование
@@ -55,14 +55,14 @@ ru:
55
55
  media: Носитель
56
56
  starring: Актеры
57
57
  director: Режиссер
58
- orginal_name: Оригинальное наименовани
58
+ original_name: Оригинальное наименование
59
59
  video_country: Страна
60
- music_video_property: "Поля для описание типа 'музыка', 'видео' "
61
- event_ticket_property: "Поля для описание типа 'билеты на мероприятия' "
60
+ music_video_property: "Поля для описания типа 'музыка', 'видео' "
61
+ event_ticket_property: "Поля для описания типа 'билеты на мероприятия' "
62
62
  place: Место мероприятия
63
63
  hall: Зал
64
64
  hall_url_plan: Ссылка на картинку версии зала
65
- event_date: Дата и время сеанса.
65
+ event_date: Дата и время сеанса
66
66
  is_premiere: Признак премьерности мероприятия
67
67
  is_kids: Признак детского мероприятия
68
68
  export_to_yandex_market: Экспортировать в Яндекс-Маркет
@@ -1,6 +1,6 @@
1
1
  Rails.application.routes.draw do
2
2
  namespace :admin do
3
- resource :yandex_markets do
3
+ resource :yandex_market_settings do
4
4
  member do
5
5
  match :general
6
6
  match :currency
@@ -6,22 +6,22 @@ module Export
6
6
  include ActionController::UrlWriter
7
7
  attr_accessor :host, :currencies
8
8
 
9
- DEFAULT_OFFER = "book"
9
+ DEFAULT_OFFER = "simple"
10
10
 
11
11
  def helper
12
12
  @helper ||= ApplicationController.helpers
13
13
  end
14
14
 
15
15
  def export
16
- @config = YandexMarket::Config.instance
16
+ @config = Spree::YandexMarket::Config.instance
17
17
  @host = @config.preferred_url.sub(%r[^http://],'').sub(%r[/$], '')
18
18
  ActionController::Base.asset_host = @config.preferred_url
19
19
 
20
20
  @currencies = @config.preferred_currency.split(';').map{|x| x.split(':')}
21
21
  @currencies.first[1] = 1
22
22
 
23
- @categories = Taxon.find_by_name(@config.preferred_category)
24
- @categories = @categories.self_and_descendants
23
+ @preferred_category = Taxon.find_by_name(@config.preferred_category)
24
+ @categories = @preferred_category.self_and_descendants
25
25
  @categories_ids = @categories.collect { |x| x.id }
26
26
 
27
27
  # Nokogiri::XML::Builder.new({ :encoding =>"utf-8"}, SCHEME) do |xml|
@@ -54,14 +54,12 @@ module Export
54
54
  end
55
55
  }
56
56
  xml.offers { # список товаров
57
- @categories && @categories.each do |cat|
58
- products = Product.taxons_id_equals(cat).active.master_price_gt(0)
59
- products = products.on_hand if @config.preferred_wares == "on_hand"
60
- products = products.find_all_by_export_to_yandex_market(true)
61
- products && products.each do |product|
62
- offer(xml,product, cat)
63
- end
64
- end
57
+ products = Product.in_taxon(@preferred_category).active.master_price_gte(0.001)
58
+ products = products.on_hand if @config.preferred_wares == "on_hand"
59
+ products = products.where(:export_to_yandex_market => true).group_by_products_id
60
+ products.each do |product|
61
+ offer(xml, product, product.taxons.first)
62
+ end
65
63
  }
66
64
  }
67
65
  }
@@ -87,7 +85,7 @@ module Export
87
85
  product_properties = { }
88
86
  product.product_properties.map {|x| product_properties[x.property_name] = x.value }
89
87
  wares_type_value = product_properties[@config.preferred_wares_type]
90
- if ["book", "audiobook", "music", "video", "tour", "event_ticket"].include? wares_type_value
88
+ if ["book", "audiobook", "music", "video", "tour", "event_ticket", "vendor_model"].include? wares_type_value
91
89
  send("offer_#{wares_type_value}".to_sym, xml, product, cat)
92
90
  else
93
91
  send("offer_#{DEFAULT_OFFER}".to_sym, xml, product, cat)
@@ -116,15 +114,15 @@ module Export
116
114
  # смотри http://spreecommerce.com/documentation/shipping.html#shipping-category
117
115
  xml.delivery true
118
116
  xml.local_delivery_cost @config.preferred_local_delivery_cost if @config.preferred_local_delivery_cost
119
- xml.typePrefix product_properties[@config.preferred_type_prefix] if product_properties[@config.preferred_type_prefix]
120
- xml.name product.name
121
- xml.vendor product_properties[@config.preferred_vendor] if product_properties[@config.preferred_vendor]
122
- xml.vendorCode product_properties[@config.preferred_vendor_code] if product_properties[@config.preferred_vendor_code]
117
+ xml.typePrefix product_properties[@config.preferred_type_prefix] if product_properties[@config.preferred_type_prefix]
118
+ xml.name product.name
119
+ xml.vendor product_properties[@config.preferred_vendor] if product_properties[@config.preferred_vendor]
120
+ xml.vendorCode product_properties[@config.preferred_vendor_code] if product_properties[@config.preferred_vendor_code]
123
121
  xml.model product_properties[@config.preferred_model] if product_properties[@config.preferred_model]
124
122
  xml.description product.description if product.description
125
123
  xml.manufacturer_warranty !product_properties[@config.preferred_manufacturer_warranty].blank?
126
124
  xml.country_of_origin product_properties[@config.preferred_country_of_manufacturer] if product_properties[@config.preferred_country_of_manufacturer]
127
- xml.downloadable false
125
+ xml.downloadable false
128
126
  }
129
127
  end
130
128
 
@@ -236,7 +234,7 @@ module Export
236
234
  xml.media product_properties[@config.preferred_media]
237
235
  xml.starring product_properties[@config.preferred_starring]
238
236
  xml.director product_properties[@config.preferred_director]
239
- xml.originalName product_properties[@config.preferred_orginal_name]
237
+ xml.originalName product_properties[@config.preferred_original_name]
240
238
  xml.country_of_origin product_properties[@config.preferred_video_country]
241
239
  xml.description product_url.description
242
240
  }
@@ -0,0 +1,23 @@
1
+ module Spree
2
+ module YandexMarket
3
+ # Singleton class to access the advanced cart configuration object (YandexMarketConfiguration.first by default) and it's preferences.
4
+ #
5
+ # Usage:
6
+ # Spree::YandexMarket::Config[:foo] # Returns the foo preference
7
+ # Spree::YandexMarket::Config[] # Returns a Hash with all the google base preferences
8
+ # Spree::YandexMarket::Config.instance # Returns the configuration object (YandexMarketConfiguration.first)
9
+ # Spree::YandexMarket::Config.set(preferences_hash) # Set the advanced cart preferences as especified in +preference_hash+
10
+ class Config
11
+ include Singleton
12
+ include PreferenceAccess
13
+
14
+ class << self
15
+ def instance
16
+ return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
17
+ YandexMarketConfiguration.find_or_create_by_name("Yandex Market configuration")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -12,26 +12,11 @@ module SpreeYandexMarket
12
12
  end
13
13
  end
14
14
 
15
- rake_tasks do
16
- puts File.join(File.dirname(__FILE__), "tasks/yandex_market.rake").inspect
17
- load File.join(File.dirname(__FILE__), "tasks/yandex_market.rake")
18
- end
15
+ # rake_tasks do
16
+ # load File.join(File.dirname(__FILE__), "tasks/yandex_market.rake")
17
+ # end
19
18
 
20
19
  config.to_prepare &method(:activate).to_proc
21
20
  end
22
-
23
- class Config
24
- include Singleton
25
- include Spree::PreferenceAccess
26
-
27
- class << self
28
- def instance
29
- return @configuration if @configuration
30
- return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
31
- @configuration ||= YandexMarketConfiguration.find_or_create_by_name("Default configuration")
32
- @configuration
33
- end
34
- end
35
- end
36
21
 
37
22
  end
@@ -1,5 +1,5 @@
1
1
  class SpreeYandexMarketHooks < Spree::ThemeSupport::HookListener
2
2
  insert_after :admin_tabs do
3
- %(<%= tab(:yandex_market, { :route => "admin_yandex_markets" }) %>)
3
+ %(<%= tab(:yandex_market, { :route => "admin_yandex_market_settings" }) %>)
4
4
  end
5
5
  end
@@ -1,68 +1,61 @@
1
1
  # -*- coding: utf-8 -*-
2
- namespace :spree do
3
- namespace :extensions do
4
- namespace :yandex_market do
5
- desc "Copies public assets of the Yandex Market to the instance public/ directory."
6
- task :update => :environment do
7
- is_svn_git_or_dir = proc {|path| path =~ /\.svn/ || path =~ /\.git/ || File.directory?(path) }
8
- Dir[YandexMarketExtension.root + "/public/**/*"].reject(&is_svn_git_or_dir).each do |file|
9
- path = file.sub(YandexMarketExtension.root, '')
10
- directory = File.dirname(path)
11
- puts "Copying #{path}..."
12
- mkdir_p Rails.root + directory
13
- cp file, Rails.root + path
14
- end
15
- end
16
-
17
-
18
- desc "Generate Yandex.Market export file"
19
- task :generate_ym => :environment do
20
- generate_export_file 'yandex_market'
21
- end
2
+ namespace :spree_yandex_market do
3
+ desc "Copies public assets of the Yandex Market to the instance public/ directory."
4
+ task :update => :environment do
5
+ is_svn_git_or_dir = proc { |path| path =~ /\.svn/ || path =~ /\.git/ || File.directory?(path) }
6
+ Dir[YandexMarketExtension.root + "/public/**/*"].reject(&is_svn_git_or_dir).each do |file|
7
+ path = file.sub(YandexMarketExtension.root, '')
8
+ directory = File.dirname(path)
9
+ puts "Copying #{path}..."
10
+ mkdir_p Rails.root + directory
11
+ cp file, Rails.root + path
12
+ end
13
+ end
22
14
 
23
- desc "Generate Torg.mail.ru export file"
24
- task :generate_torg_mail_ru => :environment do
25
- generate_export_file 'torg_mail_ru'
26
- end
15
+ desc "Generate Yandex.Market export file"
16
+ task :generate_ym => :environment do
17
+ generate_export_file 'yandex_market'
18
+ end
19
+
20
+ desc "Generate Torg.mail.ru export file"
21
+ task :generate_torg_mail_ru => :environment do
22
+ generate_export_file 'torg_mail_ru'
23
+ end
24
+
25
+ def generate_export_file torgovaya_sistema='yandex_market'
26
+ directory = File.join(Rails.root, 'public', "#{torgovaya_sistema}")
27
+ mkdir_p directory unless File.exist?(directory)
28
+ require File.expand_path(File.join(Rails.root, "config/environment"))
29
+ require File.join(File.dirname(__FILE__), '..', "export/#{torgovaya_sistema}_exporter.rb")
30
+ ::Time::DATE_FORMATS[:ym] = "%Y-%m-%d %H:%M"
31
+ yml_xml = Export.const_get("#{torgovaya_sistema.camelize}Exporter").new.export
32
+ puts 'saving file...'
33
+
34
+ # Создаем файл, сохраняем в нужной папке,
35
+ tfile_basename = "#{torgovaya_sistema}_#{Time.now.strftime("%Y_%m_%d__%H_%M")}"
36
+ tfile = File.new(File.join(directory, tfile_basename), "w+")
37
+ tfile.write(yml_xml)
38
+ tfile.close
39
+ # пакуем в gz и делаем симлинк на ссылку файла yandex_market_last.gz
40
+ `ln -sf "#{tfile.path}" "#{File.join(directory, "#{torgovaya_sistema}.xml")}"`
27
41
 
28
- def generate_export_file torgovaya_sistema='yandex_market'
29
- directory = File.join(Rails.root,'public', "#{torgovaya_sistema}")
30
- mkdir_p directory unless File.exist?(directory)
31
- require File.expand_path(File.join(Rails.root,"config/environment"))
32
- require File.join(File.dirname(__FILE__), '..', "export/#{torgovaya_sistema}_exporter.rb")
33
- ::Time::DATE_FORMATS[:ym] = "%Y-%m-%d %H:%M"
34
- yml_xml = Export.const_get("#{torgovaya_sistema.camelize}Exporter").new.export
35
- puts 'saving file...'
42
+ # Удаляем лишнии файлы
43
+ @config = Spree::YandexMarket::Config.instance
44
+ @number_of_files = @config.preferred_number_of_files
36
45
 
37
- # Создаем файл, сохраняем в нужной папке,
38
- tfile_basename = "#{torgovaya_sistema}_#{Time.now.strftime("%Y_%m_%d__%H_%M")}"
39
- tfile = File.new( File.join(directory,tfile_basename), "w+")
40
- tfile.write(yml_xml)
41
- tfile.close
42
- # пакуем в gz и делаем симлинк на ссылку файла yandex_market_last.gz
43
- `ln -sf "#{tfile.path}" "#{File.join(directory, "#{torgovaya_sistema}.xml")}"`
46
+ @export_files = Dir[File.join(directory, '**', '*')].
47
+ map { |x| [File.basename(x), File.mtime(x)] }.
48
+ sort { |x, y| y.last <=> x.last }
49
+ e =@export_files.find { |x| x.first == "#{torgovaya_sistema}.gz" }
50
+ @export_files.reject! { |x| x.first == "#{torgovaya_sistema}.gz" }
51
+ @export_files.unshift(e)
44
52
 
45
- # Удаляем лишнии файлы
46
- @config = YandexMarket::Config.instance
47
- @number_of_files = @config.preferred_number_of_files
48
-
49
- @export_files = Dir[File.join(directory, '**','*')].
50
- map {|x| [File.basename(x), File.mtime(x)] }.
51
- sort{|x,y| y.last <=> x.last }
52
- e =@export_files.find {|x| x.first == "#{torgovaya_sistema}.gz" }
53
- @export_files.reject! {|x| x.first == "#{torgovaya_sistema}.gz" }
54
- @export_files.unshift(e)
55
-
56
- @export_files[@number_of_files..-1] && @export_files[@number_of_files..-1].each do |x|
57
- if File.exist?(File.join(directory,x.first))
58
- Rails.logger.info "[ #{torgovaya_sistema} ] удаляем устаревший файл"
59
- Rails.logger.info "[ #{torgovaya_sistema} ] путь к файлу #{File.join(directory,x.first)}"
60
- File.delete(File.join(directory,x.first))
61
- end
62
- end
63
-
53
+ @export_files[@number_of_files..-1] && @export_files[@number_of_files..-1].each do |x|
54
+ if File.exist?(File.join(directory, x.first))
55
+ Rails.logger.info "[ #{torgovaya_sistema} ] удаляем устаревший файл"
56
+ Rails.logger.info "[ #{torgovaya_sistema} ] путь к файлу #{File.join(directory, x.first)}"
57
+ File.delete(File.join(directory, x.first))
64
58
  end
65
-
66
59
  end
67
60
  end
68
61
  end
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.platform = Gem::Platform::RUBY
3
3
  s.name = 'spree_yandex_market'
4
- s.version = '1.1.1'
4
+ s.version = '1.2.0'
5
5
  s.summary = 'Export products to Yandex.Market'
6
6
  #s.description = 'Add (optional) gem description here'
7
7
  s.required_ruby_version = '>= 1.8.7'
8
8
 
9
9
  # s.author = 'David Heinemeier Hansson'
10
10
  # s.email = 'david@loudthinking.com'
11
- # s.homepage = 'http://www.rubyonrails.org'
11
+ s.homepage = 'https://github.com/romul/spree-yandex-market'
12
12
  # s.rubyforge_project = 'actionmailer'
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
@@ -16,8 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.require_path = 'lib'
17
17
  s.requirements << 'none'
18
18
 
19
- s.has_rdoc = true
20
-
21
- s.add_dependency('spree_core', '>= 0.40.99')
19
+ s.add_dependency('spree_core', '>= 0.50.0')
22
20
  s.add_dependency('nokogiri', '~> 1.4.0')
23
21
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_yandex_market
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
- - 1
9
- - 1
10
- version: 1.1.1
7
+ - 2
8
+ - 0
9
+ version: 1.2.0
11
10
  platform: ruby
12
11
  authors: []
13
12
 
@@ -15,34 +14,30 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-03-17 00:00:00 +03:00
17
+ date: 2011-04-27 00:00:00 +04:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: spree_core
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 121
30
27
  segments:
31
28
  - 0
32
- - 40
33
- - 99
34
- version: 0.40.99
29
+ - 50
30
+ - 0
31
+ version: 0.50.0
35
32
  type: :runtime
36
33
  version_requirements: *id001
37
34
  - !ruby/object:Gem::Dependency
38
35
  name: nokogiri
39
36
  prerelease: false
40
37
  requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
39
  - - ~>
44
40
  - !ruby/object:Gem::Version
45
- hash: 7
46
41
  segments:
47
42
  - 1
48
43
  - 4
@@ -64,22 +59,23 @@ files:
64
59
  - LICENSE
65
60
  - README.markdown
66
61
  - Rakefile
67
- - app/controllers/admin/yandex_markets_controller.rb
62
+ - app/controllers/admin/yandex_market_settings_controller.rb
68
63
  - app/helpers/admin/yandex_markets_helper.rb
69
64
  - app/models/.DS_Store
70
65
  - app/models/yandex_market_configuration.rb
71
- - app/views/admin/yandex_markets/currency.html.erb
72
- - app/views/admin/yandex_markets/export_files.html.erb
73
- - app/views/admin/yandex_markets/general.html.erb
74
- - app/views/admin/yandex_markets/shared/_configuration_menu.html.erb
75
- - app/views/admin/yandex_markets/show.html.erb
76
- - app/views/admin/yandex_markets/ware_property.html.erb
66
+ - app/views/admin/yandex_market_settings/currency.html.erb
67
+ - app/views/admin/yandex_market_settings/export_files.html.erb
68
+ - app/views/admin/yandex_market_settings/general.html.erb
69
+ - app/views/admin/yandex_market_settings/shared/_configuration_menu.html.erb
70
+ - app/views/admin/yandex_market_settings/show.html.erb
71
+ - app/views/admin/yandex_market_settings/ware_property.html.erb
77
72
  - config/locales/en-US.yml
78
73
  - config/locales/ru.yml
79
74
  - config/routes.rb
80
75
  - db/migrate/20110110094042_add_export_flag_to_product.rb
81
76
  - lib/export/torg_mail_ru_exporter.rb
82
77
  - lib/export/yandex_market_exporter.rb
78
+ - lib/spree/yandex_market/config.rb
83
79
  - lib/spree_yandex_market.rb
84
80
  - lib/spree_yandex_market_hooks.rb
85
81
  - lib/tasks/install.rake
@@ -92,7 +88,7 @@ files:
92
88
  - spec/spec_helper.rb
93
89
  - spree_yandex_market.gemspec
94
90
  has_rdoc: true
95
- homepage:
91
+ homepage: https://github.com/romul/spree-yandex-market
96
92
  licenses: []
97
93
 
98
94
  post_install_message:
@@ -101,29 +97,25 @@ rdoc_options: []
101
97
  require_paths:
102
98
  - lib
103
99
  required_ruby_version: !ruby/object:Gem::Requirement
104
- none: false
105
100
  requirements:
106
101
  - - ">="
107
102
  - !ruby/object:Gem::Version
108
- hash: 57
109
103
  segments:
110
104
  - 1
111
105
  - 8
112
106
  - 7
113
107
  version: 1.8.7
114
108
  required_rubygems_version: !ruby/object:Gem::Requirement
115
- none: false
116
109
  requirements:
117
110
  - - ">="
118
111
  - !ruby/object:Gem::Version
119
- hash: 3
120
112
  segments:
121
113
  - 0
122
114
  version: "0"
123
115
  requirements:
124
116
  - none
125
117
  rubyforge_project:
126
- rubygems_version: 1.3.7
118
+ rubygems_version: 1.3.6
127
119
  signing_key:
128
120
  specification_version: 3
129
121
  summary: Export products to Yandex.Market
@@ -1,23 +0,0 @@
1
- <% content_for :sidebar do %>
2
- <%= content_tag :h3, t('configure_yandex_market.title'), :class => "name" %>
3
- <br class="clear" />
4
-
5
- <ul class="sidebar">
6
- <% content_tag :li, :class => (params[:action] == "general" ? "active": "") do -%>
7
- <%= link_to t("configure_yandex_market.general"), general_admin_yandex_markets_path %>
8
- <% end -%>
9
-
10
- <% content_tag :li, :class => (params[:action] == "currency" ? "active": "") do -%>
11
- <%= link_to t("configure_yandex_market.list_currency") , currency_admin_yandex_markets_path %>
12
- <% end -%>
13
-
14
- <% content_tag :li, :class => (params[:action] == "export_files" ? "active": "") do -%>
15
- <%= link_to t("configure_yandex_market.export_files"),export_files_admin_yandex_markets_path %>
16
- <% end -%>
17
-
18
-
19
- <% content_tag :li, :class => (params[:action] == "ware_property" ? "active": "") do -%>
20
- <%= link_to t("configure_yandex_market.ware_property"),ware_property_admin_yandex_markets_path %>
21
- <% end -%>
22
- </ul>
23
- <% end -%>