Skip to content

Instantly share code, notes, and snippets.

View Exorcist's full-sized avatar

Иван Хлипиткин Exorcist

View GitHub Profile
@Exorcist
Exorcist / 1c.rb
Created April 25, 2017 12:09
Разбор 1С xml
price_xml.search('price_items/price_item').each_with_index do |item, inx|
row = []
price_item_filters = {}
item.children.each do |item_attr|
case item_attr.name
when 'oem'
row[0] = item_attr.text.to_s.gsub(/[\r\n\t\;\"]/, '').upcase
row[1] = item_attr.text.to_s.to_oem
when 'make_name'
row[2] = item_attr.text.to_s.mb_chars.upcase.gsub(/[\r\n\t\;\"]/, '').strip
[{
"price_request_id": null,
"price_id": 319,
"oem": "S1K25",
"make_name": "Frixa",
"detail_name": "Колодки тормозные дисковые | перед |",
"cost": 5636.2,
"raw_cost": null,
"first_cost": null,
"min_qnt": 1,
public abstract class ExcelBlank
{
protected Application _excel_ap;
protected Workbook _excel_wb;
protected Worksheet _excel_ws_current;
public ExcelBlank()
{
_excel_ap = new Application();
_excel_ap.Visible = false;
require 'rubygems'
require 'mechanize'
class TestApiClient
attr_accessor :agent, :host, :login, :password
def initialize(host, login, password)
self.agent, self.host, self.login, self.password = Mechanize.new, host, login, password
end
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
helper_method :current_user
private
def current_user_session
return @current_user_session if defined?(@current_user_session) && ! @current_user_session.blank?
@current_user_session = UserSession.find
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
helper_method :current_user
private
def current_user_session
return @current_user_session if defined?(@current_user_session) && ! @current_user_session.blank?
@current_user_session = UserSession.find