bitrix_on_rails 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -25,5 +25,5 @@ group :development, :test do
25
25
  gem "guard-test"
26
26
  # http://test-unit.rubyforge.org/
27
27
  # gem 'test-unit-notify'
28
- gem 'test-unit-rr'
28
+ gem 'rr'
29
29
  end
@@ -42,6 +42,7 @@ GEM
42
42
  abstract (>= 1.0.0)
43
43
  factory_girl (2.0.2)
44
44
  git (1.2.5)
45
+ growl (1.0.3)
45
46
  guard (0.5.1)
46
47
  thor (~> 0.14.6)
47
48
  guard-test (0.3.0)
@@ -81,6 +82,7 @@ GEM
81
82
  rdoc (~> 3.4)
82
83
  thor (~> 0.14.4)
83
84
  rake (0.9.2)
85
+ rb-fsevent (0.4.3.1)
84
86
  rcov (0.9.9)
85
87
  rdoc (3.9.1)
86
88
  rr (1.0.3)
@@ -97,9 +99,6 @@ GEM
97
99
  shoulda (2.11.3)
98
100
  sqlite3 (1.3.4)
99
101
  test-unit (2.3.0)
100
- test-unit-rr (1.0.1)
101
- rr (>= 1.0.2)
102
- test-unit (>= 2.1.2)
103
102
  thor (0.14.6)
104
103
  treetop (1.4.10)
105
104
  polyglot
@@ -112,13 +111,15 @@ PLATFORMS
112
111
  DEPENDENCIES
113
112
  bundler (~> 1.0.0)
114
113
  factory_girl
114
+ growl
115
115
  guard-test
116
116
  jeweler (~> 1.6.4)
117
117
  php_serialize!
118
118
  rails (>= 3.0)
119
+ rb-fsevent
119
120
  rcov
121
+ rr
120
122
  ruby-debug19
121
123
  shoulda
122
124
  sqlite3
123
125
  test-unit
124
- test-unit-rr
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bitrix_on_rails}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Danil Pismenny}]
12
- s.date = %q{2011-08-29}
11
+ s.authors = ["Danil Pismenny"]
12
+ s.date = %q{2011-08-30}
13
13
  s.description = %q{Использование инфоблоков 1С-Битрикс в Ruby On Rails проектах}
14
14
  s.email = %q{danil@orionet.ru}
15
15
  s.extra_rdoc_files = [
@@ -37,7 +37,6 @@ Gem::Specification.new do |s|
37
37
  "app/models/iblock_type.rb",
38
38
  "bitrix_on_rails.gemspec",
39
39
  "init.rb",
40
- "lib/active_record/connection_adapters/mysql2_downcase_adapter.rb",
41
40
  "lib/bitrix_on_rails.rb",
42
41
  "lib/bitrix_on_rails/active_record.rb",
43
42
  "lib/bitrix_on_rails/configuration.rb",
@@ -45,6 +44,7 @@ Gem::Specification.new do |s|
45
44
  "lib/bitrix_on_rails/iblock_element.rb",
46
45
  "lib/bitrix_on_rails/iblock_element_prop_m.rb",
47
46
  "lib/bitrix_on_rails/iblock_element_prop_s.rb",
47
+ "lib/php_serialize_encoded.rb",
48
48
  "test/dump.sql",
49
49
  "test/factories.rb",
50
50
  "test/get_dump.sh",
@@ -53,12 +53,13 @@ Gem::Specification.new do |s|
53
53
  "test/test_active_record.rb",
54
54
  "test/test_bitrix_on_rails.rb",
55
55
  "test/test_iblock_element.rb",
56
- "test/test_iblock_element_prop_s.rb"
56
+ "test/test_iblock_element_prop_s.rb",
57
+ "test/test_php_serialize_encoded.rb"
57
58
  ]
58
59
  s.homepage = %q{http://github.com/dapi/bitrix_on_rails}
59
- s.licenses = [%q{MIT}]
60
- s.require_paths = [%q{lib}]
61
- s.rubygems_version = %q{1.8.6}
60
+ s.licenses = ["MIT"]
61
+ s.require_paths = ["lib"]
62
+ s.rubygems_version = %q{1.6.2}
62
63
  s.summary = %q{Работа с инфоблоками 1С-Битрикс}
63
64
 
64
65
  if s.respond_to? :specification_version then
@@ -75,8 +76,10 @@ Gem::Specification.new do |s|
75
76
  s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
76
77
  s.add_development_dependency(%q<factory_girl>, [">= 0"])
77
78
  s.add_development_dependency(%q<test-unit>, [">= 0"])
79
+ s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
80
+ s.add_development_dependency(%q<growl>, [">= 0"])
78
81
  s.add_development_dependency(%q<guard-test>, [">= 0"])
79
- s.add_development_dependency(%q<test-unit-rr>, [">= 0"])
82
+ s.add_development_dependency(%q<rr>, [">= 0"])
80
83
  else
81
84
  s.add_dependency(%q<rails>, [">= 3.0"])
82
85
  s.add_dependency(%q<php_serialize>, [">= 0"])
@@ -88,8 +91,10 @@ Gem::Specification.new do |s|
88
91
  s.add_dependency(%q<ruby-debug19>, [">= 0"])
89
92
  s.add_dependency(%q<factory_girl>, [">= 0"])
90
93
  s.add_dependency(%q<test-unit>, [">= 0"])
94
+ s.add_dependency(%q<rb-fsevent>, [">= 0"])
95
+ s.add_dependency(%q<growl>, [">= 0"])
91
96
  s.add_dependency(%q<guard-test>, [">= 0"])
92
- s.add_dependency(%q<test-unit-rr>, [">= 0"])
97
+ s.add_dependency(%q<rr>, [">= 0"])
93
98
  end
94
99
  else
95
100
  s.add_dependency(%q<rails>, [">= 3.0"])
@@ -102,8 +107,10 @@ Gem::Specification.new do |s|
102
107
  s.add_dependency(%q<ruby-debug19>, [">= 0"])
103
108
  s.add_dependency(%q<factory_girl>, [">= 0"])
104
109
  s.add_dependency(%q<test-unit>, [">= 0"])
110
+ s.add_dependency(%q<rb-fsevent>, [">= 0"])
111
+ s.add_dependency(%q<growl>, [">= 0"])
105
112
  s.add_dependency(%q<guard-test>, [">= 0"])
106
- s.add_dependency(%q<test-unit-rr>, [">= 0"])
113
+ s.add_dependency(%q<rr>, [">= 0"])
107
114
  end
108
115
  end
109
116
 
@@ -22,5 +22,6 @@ require 'bitrix_on_rails/active_record'
22
22
  require 'bitrix_on_rails/iblock_element'
23
23
  require 'bitrix_on_rails/iblock_element_prop_s'
24
24
  require 'bitrix_on_rails/iblock_element_prop_m'
25
+ require 'php_serialize_encoded'
25
26
 
26
27
  ActiveRecord::Base.extend BitrixOnRails::ActiveRecord
@@ -8,7 +8,9 @@ module BitrixOnRails
8
8
  end
9
9
 
10
10
  def self.define_iblock_class(iblock_id, options = {})
11
- iblock_element_class = create_iblock_class(iblock_id, options[:extended_class], options[:extended_by])
11
+ iblock_version = Iblock.find(iblock_id).version
12
+
13
+ iblock_element_class = send("create_iblock_v#{iblock_version}_class", iblock_id, options[:extended_class], options[:extended_by])
12
14
 
13
15
  unless options[:extended_class]
14
16
  # Определяем имя класса, который нужно создать, а также namespace, в котором
@@ -28,28 +30,54 @@ module BitrixOnRails
28
30
  namespace.const_set(class_name, iblock_element_class)
29
31
  end
30
32
 
31
- create_prop_classes(iblock_id, iblock_element_class)
33
+ # Порядок вызова важен, так как только в этот момент у iblock_element_class появляется имя, которое
34
+ # используется в IblockElementPropS.
35
+ create_prop_classes(iblock_id, iblock_element_class) if iblock_version == 2
36
+
37
+ iblock_element_class
32
38
  end
33
39
 
34
40
  protected
35
41
 
36
- def self.create_iblock_class(iblock_id, extended_class = nil, extended_by = nil)
37
- iblock_element_class = extended_class || Class.new(::IblockElement) {}
42
+ def self.create_iblock_v1_class(iblock_id, extended_class = nil, extended_by = nil)
43
+ create_iblock_class(iblock_id, extended_class, extended_by) do
44
+ has_many :prop_values, :class_name => 'IblockElementProperty', :foreign_key => 'iblock_element_id'
38
45
 
39
- iblock_element_class.instance_eval do
40
- @iblock_id = iblock_id
41
- @iblock_properties = Iblock.get_properties(iblock_id).inject({}){ |a,e| a[e[1].code] = {:id => e[1].id, :multiple => e[1].multiple == 'Y'}; a}
46
+ @iblock_properties.each { |m, property|
47
+ define_method m do
48
+ prop_values.where(:iblock_property_id => property[:id]).first.try(:value)
49
+ end
50
+
51
+ define_method "#{m}=" do |value|
52
+ prop_values.create(:iblock_property_id => property[:id], :value => value)
53
+ end
54
+ }
55
+ end
56
+ end
42
57
 
58
+ def self.create_iblock_v2_class(iblock_id, extended_class = nil, extended_by = nil)
59
+ create_iblock_class(iblock_id, extended_class, extended_by) do
43
60
  has_one :property_set, :class_name => "IblockElementPropS#{iblock_id}", :foreign_key => 'iblock_element_id', :autosave => true
44
61
  has_many :m_props, :class_name => "IblockElementPropM#{iblock_id}", :foreign_key => 'iblock_element_id', :readonly => true
45
62
 
46
- default_scope where(:iblock_id => iblock_id)
47
-
48
63
  @iblock_properties.each { |m, property|
49
64
  delegate m, :to => :property_set
50
65
  delegate "#{m}=", :to => :property_set unless property[:multiple]
51
66
  }
52
67
  end
68
+ end
69
+
70
+ def self.create_iblock_class(iblock_id, extended_class = nil, extended_by = nil, &blk)
71
+ iblock_element_class = extended_class || Class.new(::IblockElement) {}
72
+
73
+ iblock_element_class.instance_eval do
74
+ @iblock_id = iblock_id
75
+ @iblock_properties = Iblock.get_properties(iblock_id).inject({}){ |a,e| a[e[1].code] = {:id => e[1].id, :multiple => e[1].multiple == 'Y'}; a}
76
+
77
+ instance_eval(&blk)
78
+
79
+ default_scope where(:iblock_id => iblock_id)
80
+ end
53
81
 
54
82
  iblock_element_class.extend Object.const_get(extended_by) if extended_by
55
83
 
@@ -79,7 +79,7 @@ module BitrixOnRails::IblockElementPropS
79
79
  before_save do
80
80
  self.class.m_props.each { |code, p|
81
81
  values = send(code).values
82
- self.send("property_#{p[:id]}=", ::PHP.serialize({'VALUE' => values, 'DESCRIPTION' => Array.new(values.size, nil)}))
82
+ self.send("property_#{p[:id]}=", ::PHP.serialize_encoded({'VALUE' => values, 'DESCRIPTION' => Array.new(values.size, nil)}))
83
83
  }
84
84
  end
85
85
  end
@@ -107,7 +107,7 @@ module BitrixOnRails::IblockElementPropS
107
107
  value.is_a?(BigDecimal) ? value.to_i : value
108
108
  when 'S'
109
109
  if value.length > 5 && value[0..3] =~ /[a-z]:\d/
110
- v = ::PHP.unserialize(value)
110
+ v = ::PHP.unserialize_encoded(value)
111
111
  v.is_a?(Hash) && v.include?('TEXT') ? v['TEXT'] : value
112
112
  elsif user_type == 'DateTime'
113
113
  Time.parse(value).in_time_zone
@@ -125,7 +125,7 @@ module BitrixOnRails::IblockElementPropS
125
125
  case type
126
126
  when 'S'
127
127
  if user_type == 'HTML'
128
- ::PHP.serialize({'TEXT' => value, 'TYPE' => 'html'})
128
+ ::PHP.serialize_encoded({'TEXT' => value, 'TYPE' => 'html'})
129
129
  elsif user_type == 'DateTime'
130
130
  value.strftime('%Y-%m-%d %H:%M:%S')
131
131
  else
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+ module PHP
3
+ # Когда битрикс работает с базой в cp1251, а рельсы с UTF-8
4
+ # Возникают проблемы с подсчетом длинны строк при сериализации
5
+ # 'тест' в cp1251 имеет 4 символа, а в utf-8 - 8.
6
+ #
7
+ # Поэтому приходится производить все сериализацию через эти врапперы.
8
+ #
9
+
10
+ def PHP.encode_in_deep(val, encoding)
11
+ if val.is_a? Array
12
+ val = val.map { |v| encode_in_deep(v, encoding) }
13
+ elsif val.is_a? Hash
14
+ val.each_pair do |k,v|
15
+ val[k] = encode_in_deep(v, encoding)
16
+ end
17
+ elsif val.is_a? String
18
+ val = val.encode(encoding)
19
+ end
20
+ val
21
+ end
22
+
23
+ def PHP.serialize_encoded(val)
24
+ val = encode_in_deep(val, 'CP1251')
25
+ serialize(val).encode('UTF-8')
26
+ end
27
+
28
+ def PHP.unserialize_encoded(s)
29
+ val = unserialize(s.encode('CP1251'))
30
+ val = encode_in_deep(val, 'UTF-8')
31
+ val
32
+ end
33
+ end
@@ -102,4 +102,22 @@ FactoryGirl.define do
102
102
  factory :iblock_element7, :parent => :iblock_element do
103
103
  association :iblock, :factory=>:iblock7
104
104
  end
105
+
106
+ #
107
+ # Инфоблок с version = 1
108
+ #
109
+ factory :iblock_v1, :parent => :iblock do
110
+ version 1
111
+
112
+ after_build { |iblock|
113
+ iblock.iblock_properties.build Factory.build(:iblock_v1_prop_synonym).attributes
114
+ }
115
+ end
116
+
117
+ factory :iblock_v1_prop_synonym, :parent => :iblock_property do
118
+ name 'Синоним'
119
+ code 'synonym'
120
+ property_type 'S'
121
+ multiple 'N'
122
+ end
105
123
  end
@@ -14,6 +14,7 @@ require 'active_record'
14
14
  require 'factory_girl'
15
15
  require 'shoulda'
16
16
  require 'active_support/test_case'
17
+ require 'rr'
17
18
 
18
19
  ActiveRecord::Base.establish_connection(
19
20
  :adapter => 'sqlite3',
@@ -40,12 +41,5 @@ require 'factories'
40
41
  class Test::Unit::TestCase
41
42
  include Factory::Syntax::Methods
42
43
  include ActiveSupport::Testing::Assertions
43
-
44
- def bitrix_configure
45
- BitrixOnRails.configure do
46
- infoblock 3, IblockElement3
47
- infoblock 7, IblockElement7
48
- end
49
- end
50
-
44
+ include RR::Adapters::TestUnit
51
45
  end
@@ -16,6 +16,10 @@ class ActiveRecordTest < Test::Unit::TestCase
16
16
  end
17
17
  end
18
18
 
19
+ teardown do
20
+ Object.send :remove_const, "IblockElement#{@iblock.id}"
21
+ end
22
+
19
23
  should 'create associations' do
20
24
  assert Post.reflections.include?("iblock_element_prop_s#{@iblock.id}".to_sym)
21
25
  assert Post.reflections.include?(:iblock_element)
@@ -6,23 +6,4 @@ class TestBitrixOnRails < Test::Unit::TestCase
6
6
  def tests
7
7
  assert_respond_to BitrixOnRails, :configure
8
8
  end
9
-
10
- # should "автоматичеки создает модели свойств для всех инфоблоков при инициализации" do
11
- # assert_equal 2, BitrixOnRails.init.count, '2 инфоблока в нашей схеме'
12
- # # assert defined?(IblockElementPropM7), 'должен определиться автоматически'
13
- # puts IblockElementPropM7
14
- # end
15
-
16
- # should "Брать свойства для блока и кешировать их" do
17
-
18
- # Iblock.get_properties(3)
19
-
20
- # # А этот запрос уже кеширован
21
- # Iblock.get_properties(3)
22
- # end
23
9
  end
24
-
25
-
26
- # При инициализации создаются модели для всех инфоблоков
27
- # При использовании IblockElement можно работать со свойствами
28
- # Пожно подключать Инфоблок через has_infoblock к модели
@@ -3,14 +3,22 @@ require 'helper'
3
3
  class IblockElementTest < Test::Unit::TestCase
4
4
 
5
5
  context 'define_iblock_class' do
6
+ setup do
7
+ stub(iblock = Object.new).version { 2 }
8
+ stub(Iblock).find { iblock }
9
+ end
6
10
 
7
11
  context 'with class_name set to nil' do
8
12
  setup do
9
13
  BitrixOnRails.define_iblock_class(3)
10
14
  end
11
15
 
16
+ teardown do
17
+ Object.send :remove_const, "IblockElement3"
18
+ end
19
+
12
20
  should 'create class IblockElement3 in global namespace' do
13
- assert_not_nil Object.const_defined?('IblockElement3')
21
+ assert_not_nil Object.const_defined?("IblockElement3")
14
22
  end
15
23
  end
16
24
 
@@ -40,6 +48,10 @@ class IblockElementTest < Test::Unit::TestCase
40
48
  BitrixOnRails.define_iblock_class(3)
41
49
  end
42
50
 
51
+ teardown do
52
+ Object.send :remove_const, "IblockElement3"
53
+ end
54
+
43
55
  should 'create association with property classes' do
44
56
  assert_not_nil IblockElement3.reflections[:property_set]
45
57
  assert_not_nil IblockElement3.reflections[:m_props]
@@ -66,6 +78,10 @@ class IblockElementTest < Test::Unit::TestCase
66
78
  BitrixOnRails.define_iblock_class(3, :extended_by => 'IblockElementExtension')
67
79
  end
68
80
 
81
+ teardown do
82
+ Object.send :remove_const, "IblockElement3"
83
+ end
84
+
69
85
  should 'extend created class with given module' do
70
86
  # Не нашел другого способа проверить, что модуль был включен в класс
71
87
  assert IblockElement3.methods.include?(:some_method)
@@ -74,4 +90,20 @@ class IblockElementTest < Test::Unit::TestCase
74
90
 
75
91
  end
76
92
 
93
+ context 'described by iblock with version == 1' do
94
+ setup do
95
+ @iblock = Factory.create(:iblock_v1)
96
+ @iblock_element_class = BitrixOnRails.define_iblock_class(@iblock.id)
97
+ end
98
+
99
+ should 'set multiple association for prop_values' do
100
+ assert_not_nil @iblock_element_class.reflections[:prop_values]
101
+ end
102
+
103
+ should 'define access methods for iblock properties' do
104
+ assert @iblock_element_class.instance_methods.include?(:synonym)
105
+ assert @iblock_element_class.instance_methods.include?(:synonym=)
106
+ end
107
+ end
108
+
77
109
  end
@@ -9,19 +9,19 @@ class IblockElementPropSTest < Test::Unit::TestCase
9
9
  ]
10
10
 
11
11
  def create_iblock(iblock_factory, iblock_element_factory, prop_s_values = [], prop_m_values = [])
12
- iblock = Factory.create(iblock_factory)
12
+ @iblock = Factory.create(iblock_factory)
13
13
 
14
- BitrixOnRails.define_iblock_class(iblock.id)
14
+ BitrixOnRails.define_iblock_class(@iblock.id)
15
15
 
16
- @s_prop_class = Object.const_get("IblockElementPropS#{iblock.id}")
17
- @m_prop_class = Object.const_get("IblockElementPropM#{iblock.id}")
16
+ @s_prop_class = Object.const_get("IblockElementPropS#{@iblock.id}")
17
+ @m_prop_class = Object.const_get("IblockElementPropM#{@iblock.id}")
18
18
 
19
19
  properties = @s_prop_class.columns.collect { |c| c.name }
20
20
 
21
- @iblock_element = Factory.create(iblock_element_factory, :iblock => iblock)
21
+ @iblock_element = Factory.create(iblock_element_factory, :iblock => @iblock)
22
22
 
23
23
  prop_m_values.each { |v|
24
- @m_prop_class.create(:iblock_element_id => @iblock_element.id, :iblock_property_id => iblock.iblock_properties.last.id, :value => v)
24
+ @m_prop_class.create(:iblock_element_id => @iblock_element.id, :iblock_property_id => @iblock.iblock_properties.last.id, :value => v)
25
25
  }
26
26
 
27
27
  prop_s_values = [@iblock_element.id] + prop_s_values
@@ -37,6 +37,10 @@ class IblockElementPropSTest < Test::Unit::TestCase
37
37
  @s_prop_class = Object.const_get("IblockElementPropS#{@iblock.id}")
38
38
  end
39
39
 
40
+ teardown do
41
+ Object.send :remove_const, "IblockElement#{@iblock.id}"
42
+ end
43
+
40
44
  should 'set table name to b_iblock_element_prop_s#{id}' do
41
45
  assert_equal "b_iblock_element_prop_s#{@iblock.id}", @s_prop_class.table_name
42
46
  end
@@ -62,6 +66,10 @@ class IblockElementPropSTest < Test::Unit::TestCase
62
66
  create_iblock :iblock3, :iblock_element3, PROP_S_VALUES, [144, 1394860, 35, 6, 165]
63
67
  end
64
68
 
69
+ teardown do
70
+ Object.send :remove_const, "IblockElement#{@iblock.id}"
71
+ end
72
+
65
73
  should 'return unserialized values' do
66
74
  assert_equal 11286, @iblock_element_prop_s.post_id
67
75
  assert_equal 'Полемика по повышению.', @iblock_element_prop_s.preview_mpage
@@ -77,6 +85,10 @@ class IblockElementPropSTest < Test::Unit::TestCase
77
85
  create_iblock :iblock3, :iblock_element3, PROP_S_VALUES, [10]
78
86
  end
79
87
 
88
+ teardown do
89
+ Object.send :remove_const, "IblockElement#{@iblock.id}"
90
+ end
91
+
80
92
  should 'add new record to b_iblock_element_prop_m on add' do
81
93
  assert_difference("#{@iblock_element_prop_s.m_prop_class}.count") do
82
94
  @iblock_element_prop_s.glob_class.add(16)
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'helper'
4
+
5
+ class TestPHPSerializeEncoded < Test::Unit::TestCase
6
+ def tests
7
+ assert_respond_to PHP, :serialize_encoded
8
+ assert_respond_to PHP, :unserialize_encoded
9
+
10
+ s = "a:2:{s:4:\"TEXT\";s:294:\"В четверг, 25 августа, торги в России начались хорошим ростом, но после обеда рынок начал терять отвоеванные позиции. В итоге почти 1,5% роста индекса ММВБ на 17:00 сменились 0,2% падения. При этом некоторую довольно слабую поддержку нашему рынку оказывают немного подрастающие котировки нефти.\";s:4:\"TYPE\";s:4:\"html\";}"
11
+ val = PHP.unserialize_encoded(s)
12
+
13
+ assert_equal val['TEXT'], "В четверг, 25 августа, торги в России начались хорошим ростом, но после обеда рынок начал терять отвоеванные позиции. В итоге почти 1,5% роста индекса ММВБ на 17:00 сменились 0,2% падения. При этом некоторую довольно слабую поддержку нашему рынку оказывают немного подрастающие котировки нефти."
14
+
15
+ val = PHP.serialize_encoded(['тест'])
16
+ assert_equal val, 'a:1:{i:0;s:4:"тест";}'
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitrix_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-29 00:00:00.000000000Z
12
+ date: 2011-08-30 00:00:00.000000000 +04:00
13
+ default_executable:
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rails
16
- requirement: &19514180 !ruby/object:Gem::Requirement
17
+ requirement: &2153466700 !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ! '>='
@@ -21,10 +22,10 @@ dependencies:
21
22
  version: '3.0'
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *19514180
25
+ version_requirements: *2153466700
25
26
  - !ruby/object:Gem::Dependency
26
27
  name: php_serialize
27
- requirement: &19513460 !ruby/object:Gem::Requirement
28
+ requirement: &2153465440 !ruby/object:Gem::Requirement
28
29
  none: false
29
30
  requirements:
30
31
  - - ! '>='
@@ -32,10 +33,10 @@ dependencies:
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *19513460
36
+ version_requirements: *2153465440
36
37
  - !ruby/object:Gem::Dependency
37
38
  name: sqlite3
38
- requirement: &19512780 !ruby/object:Gem::Requirement
39
+ requirement: &2153463940 !ruby/object:Gem::Requirement
39
40
  none: false
40
41
  requirements:
41
42
  - - ! '>='
@@ -43,10 +44,10 @@ dependencies:
43
44
  version: '0'
44
45
  type: :development
45
46
  prerelease: false
46
- version_requirements: *19512780
47
+ version_requirements: *2153463940
47
48
  - !ruby/object:Gem::Dependency
48
49
  name: shoulda
49
- requirement: &19512200 !ruby/object:Gem::Requirement
50
+ requirement: &2153458140 !ruby/object:Gem::Requirement
50
51
  none: false
51
52
  requirements:
52
53
  - - ! '>='
@@ -54,10 +55,10 @@ dependencies:
54
55
  version: '0'
55
56
  type: :development
56
57
  prerelease: false
57
- version_requirements: *19512200
58
+ version_requirements: *2153458140
58
59
  - !ruby/object:Gem::Dependency
59
60
  name: bundler
60
- requirement: &19511460 !ruby/object:Gem::Requirement
61
+ requirement: &2153456080 !ruby/object:Gem::Requirement
61
62
  none: false
62
63
  requirements:
63
64
  - - ~>
@@ -65,10 +66,10 @@ dependencies:
65
66
  version: 1.0.0
66
67
  type: :development
67
68
  prerelease: false
68
- version_requirements: *19511460
69
+ version_requirements: *2153456080
69
70
  - !ruby/object:Gem::Dependency
70
71
  name: jeweler
71
- requirement: &19509100 !ruby/object:Gem::Requirement
72
+ requirement: &2153452480 !ruby/object:Gem::Requirement
72
73
  none: false
73
74
  requirements:
74
75
  - - ~>
@@ -76,10 +77,10 @@ dependencies:
76
77
  version: 1.6.4
77
78
  type: :development
78
79
  prerelease: false
79
- version_requirements: *19509100
80
+ version_requirements: *2153452480
80
81
  - !ruby/object:Gem::Dependency
81
82
  name: rcov
82
- requirement: &19508220 !ruby/object:Gem::Requirement
83
+ requirement: &2153450440 !ruby/object:Gem::Requirement
83
84
  none: false
84
85
  requirements:
85
86
  - - ! '>='
@@ -87,10 +88,10 @@ dependencies:
87
88
  version: '0'
88
89
  type: :development
89
90
  prerelease: false
90
- version_requirements: *19508220
91
+ version_requirements: *2153450440
91
92
  - !ruby/object:Gem::Dependency
92
93
  name: ruby-debug19
93
- requirement: &19507400 !ruby/object:Gem::Requirement
94
+ requirement: &2153449020 !ruby/object:Gem::Requirement
94
95
  none: false
95
96
  requirements:
96
97
  - - ! '>='
@@ -98,10 +99,10 @@ dependencies:
98
99
  version: '0'
99
100
  type: :development
100
101
  prerelease: false
101
- version_requirements: *19507400
102
+ version_requirements: *2153449020
102
103
  - !ruby/object:Gem::Dependency
103
104
  name: factory_girl
104
- requirement: &19506560 !ruby/object:Gem::Requirement
105
+ requirement: &2153448060 !ruby/object:Gem::Requirement
105
106
  none: false
106
107
  requirements:
107
108
  - - ! '>='
@@ -109,10 +110,10 @@ dependencies:
109
110
  version: '0'
110
111
  type: :development
111
112
  prerelease: false
112
- version_requirements: *19506560
113
+ version_requirements: *2153448060
113
114
  - !ruby/object:Gem::Dependency
114
115
  name: test-unit
115
- requirement: &19505960 !ruby/object:Gem::Requirement
116
+ requirement: &2153446980 !ruby/object:Gem::Requirement
116
117
  none: false
117
118
  requirements:
118
119
  - - ! '>='
@@ -120,10 +121,32 @@ dependencies:
120
121
  version: '0'
121
122
  type: :development
122
123
  prerelease: false
123
- version_requirements: *19505960
124
+ version_requirements: *2153446980
125
+ - !ruby/object:Gem::Dependency
126
+ name: rb-fsevent
127
+ requirement: &2153445780 !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: *2153445780
136
+ - !ruby/object:Gem::Dependency
137
+ name: growl
138
+ requirement: &2153444480 !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: *2153444480
124
147
  - !ruby/object:Gem::Dependency
125
148
  name: guard-test
126
- requirement: &19505320 !ruby/object:Gem::Requirement
149
+ requirement: &2153443040 !ruby/object:Gem::Requirement
127
150
  none: false
128
151
  requirements:
129
152
  - - ! '>='
@@ -131,10 +154,10 @@ dependencies:
131
154
  version: '0'
132
155
  type: :development
133
156
  prerelease: false
134
- version_requirements: *19505320
157
+ version_requirements: *2153443040
135
158
  - !ruby/object:Gem::Dependency
136
- name: test-unit-rr
137
- requirement: &19504640 !ruby/object:Gem::Requirement
159
+ name: rr
160
+ requirement: &2153441700 !ruby/object:Gem::Requirement
138
161
  none: false
139
162
  requirements:
140
163
  - - ! '>='
@@ -142,7 +165,7 @@ dependencies:
142
165
  version: '0'
143
166
  type: :development
144
167
  prerelease: false
145
- version_requirements: *19504640
168
+ version_requirements: *2153441700
146
169
  description: Использование инфоблоков 1С-Битрикс в Ruby On Rails проектах
147
170
  email: danil@orionet.ru
148
171
  executables: []
@@ -171,7 +194,6 @@ files:
171
194
  - app/models/iblock_type.rb
172
195
  - bitrix_on_rails.gemspec
173
196
  - init.rb
174
- - lib/active_record/connection_adapters/mysql2_downcase_adapter.rb
175
197
  - lib/bitrix_on_rails.rb
176
198
  - lib/bitrix_on_rails/active_record.rb
177
199
  - lib/bitrix_on_rails/configuration.rb
@@ -179,6 +201,7 @@ files:
179
201
  - lib/bitrix_on_rails/iblock_element.rb
180
202
  - lib/bitrix_on_rails/iblock_element_prop_m.rb
181
203
  - lib/bitrix_on_rails/iblock_element_prop_s.rb
204
+ - lib/php_serialize_encoded.rb
182
205
  - test/dump.sql
183
206
  - test/factories.rb
184
207
  - test/get_dump.sh
@@ -188,6 +211,8 @@ files:
188
211
  - test/test_bitrix_on_rails.rb
189
212
  - test/test_iblock_element.rb
190
213
  - test/test_iblock_element_prop_s.rb
214
+ - test/test_php_serialize_encoded.rb
215
+ has_rdoc: true
191
216
  homepage: http://github.com/dapi/bitrix_on_rails
192
217
  licenses:
193
218
  - MIT
@@ -203,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
228
  version: '0'
204
229
  segments:
205
230
  - 0
206
- hash: 3075423241846664278
231
+ hash: -2381565352969100600
207
232
  required_rubygems_version: !ruby/object:Gem::Requirement
208
233
  none: false
209
234
  requirements:
@@ -212,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
237
  version: '0'
213
238
  requirements: []
214
239
  rubyforge_project:
215
- rubygems_version: 1.8.6
240
+ rubygems_version: 1.6.2
216
241
  signing_key:
217
242
  specification_version: 3
218
243
  summary: Работа с инфоблоками 1С-Битрикс
@@ -1,76 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Just use 'mysql2_downcase' adapter in database.yml
3
- #
4
-
5
- require 'active_record/connection_adapters/mysql2_adapter'
6
-
7
- module ActiveRecord
8
- class Base
9
- # Establishes a connection to the database that's used by all Active Record objects.
10
- def self.mysql2_downcase_connection(config)
11
- config[:username] = 'root' if config[:username].nil?
12
-
13
- if Mysql2::Client.const_defined? :FOUND_ROWS
14
- config[:flags] = Mysql2::Client::FOUND_ROWS
15
- end
16
-
17
- client = Mysql2::Client.new(config.symbolize_keys)
18
- options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0]
19
- ConnectionAdapters::Mysql2DowncaseAdapter.new(client, logger, options, config)
20
- # ActiveRecord::Base.mysql2_connection(config)
21
- end
22
- end
23
-
24
- class Result
25
-
26
- # Это выполняется через ActiveRecord::Result.new в mysql2_adapter
27
- # при выполнении запроса
28
- def initialize(columns, rows)
29
- @columns = columns.map { |c| c.downcase }
30
- @rows = rows
31
- @hash_rows = nil
32
- end
33
- end
34
-
35
- module ConnectionAdapters
36
- class Column
37
-
38
- alias_method :old_initialize, :initialize
39
-
40
- # Это выполняется при выборке списка аттрибутов на уровне класса
41
- #
42
- def initialize(name, default, sql_type = nil, null = true)
43
- old_initialize name.downcase, default, sql_type, null
44
- end
45
-
46
- end
47
-
48
- class Mysql2DowncaseAdapter < Mysql2Adapter
49
-
50
- ADAPTER_NAME = 'Mysql2Downcase'
51
-
52
- # Надо бы глобально сделать тут:
53
- # def execute(sql, name = nil)
54
- # debugger
55
- # end
56
-
57
- # Это чтобы нормально определся primary_key
58
- def pk_and_sequence_for(table)
59
- keys = []
60
- result = execute("DESCRIBE #{quote_table_name(table)}", 'SCHEMA')
61
- result.each(:symbolize_keys => true, :as => :hash) do |row|
62
- keys << row[:Field].downcase if row[:Key] == "PRI"
63
- end
64
- keys.length == 1 ? [keys.first, nil] : nil
65
- end
66
-
67
- end
68
- end
69
- end
70
-
71
-
72
- # Возможно понадобится исправить этот метод
73
- # quote_column_name
74
-
75
- # Хороший пример адаптера - http://virtuoso.rubyforge.org/activerecord-mysql2spatial-adapter/
76
- # https://github.com/dazuma/activerecord-mysql2spatial-adapter