s41c 0.0.6 → 0.0.7

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.
data/README.md CHANGED
@@ -58,9 +58,10 @@ TCP-socket-сервер и клиент для платформы "1С:Пред
58
58
  client = S41C::Client.new('127.0.0.1', 2000)
59
59
  client.login('username', 'password')
60
60
 
61
- response = client.request do
61
+ vars = {:name => 'Товары'}
62
+ response = client.request(vars) do
62
63
 
63
- spr = @ole.CreateObject('Справочник.Товары')
64
+ spr = @ole.CreateObject("Справочник.#{@vars[:name]}")
64
65
 
65
66
  if spr.invoke('НайтиПоНаименованию', 'Название товара') == 1.0
66
67
  item = spr.invoke('ТекущийЭлемент')
@@ -76,8 +77,8 @@ TCP-socket-сервер и клиент для платформы "1С:Пред
76
77
  puts response
77
78
  client.disconnect
78
79
 
79
- Внутри кода доступен объект @ole, который и является инстансом 1С. У него есть
80
- 3 метода
80
+ Внутри кода доступны объекты @vars и @ole. Первый содержит данные переданные методу request,
81
+ а второй является инстансом 1С и у него есть 3 метода
81
82
 
82
83
  * CreateObject - создает объект агрегатного типа данных 1С:Предприятия и
83
84
  возвращает ссылку на него.
data/lib/s41c/client.rb CHANGED
@@ -63,7 +63,7 @@ module S41C
63
63
  code = S41C::Parser.new(block).parse
64
64
  dump = Marshal.dump({vars: vars, code: code})
65
65
 
66
- self.eval dump
66
+ self.eval [dump].pack('m')
67
67
  end
68
68
 
69
69
  # Выполнить на сервере строку
data/lib/s41c/parser.rb CHANGED
@@ -4,8 +4,8 @@ module S41C #:nodoc
4
4
 
5
5
  class Parser #:nodoc
6
6
 
7
- BLOCK_BEGINNERS = /module|class|def|begin|do|case|if|unless|{/
8
- BLOCK_ENDERS = /end|}/
7
+ BLOCK_BEGINNERS = /\b(module|class|def|begin|do|case|if|unless)\b|{/
8
+ BLOCK_ENDERS = /\bend\b|}/
9
9
 
10
10
  #:nodoc
11
11
  def initialize(block)
@@ -28,7 +28,6 @@ module S41C #:nodoc
28
28
  raw = @lines[@start_line..-1]
29
29
  depth = 0
30
30
  code = []
31
- @finish_line = @start_line
32
31
 
33
32
  raw.each_with_index do |line, index|
34
33
 
@@ -40,10 +39,7 @@ module S41C #:nodoc
40
39
 
41
40
  code << line
42
41
 
43
- if depth == 0
44
- @finish_line = index
45
- break
46
- end #if
42
+ break if depth == 0
47
43
 
48
44
  end # each
49
45
 
data/lib/s41c/sandbox.rb CHANGED
@@ -10,7 +10,7 @@ module S41C #:nodoc
10
10
  def initialize(ole, dump)
11
11
  @ole = ole
12
12
  dump.untaint
13
- hsh = Marshal.load(dump)
13
+ hsh = Marshal.load(dump.unpack('m')[0])
14
14
  @vars = hsh[:vars]
15
15
  @code = proc {
16
16
  $SAFE = 3
@@ -25,7 +25,7 @@ module S41C #:nodoc
25
25
  rescue WIN32OLERuntimeError => e
26
26
  "Error: #{to_utf8(e.message)}"
27
27
  rescue Exception => e
28
- "Error: #{e.message}"
28
+ "Error Exception: #{e.message}"
29
29
  rescue => e
30
30
  "Error: #{e.message} from #{__FILE__}:#{__LINE__}"
31
31
  end
data/lib/s41c/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module S41C
2
2
 
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
 
5
5
  end # S41C
data/s41c-0.0.6.gem ADDED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s41c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-08 00:00:00.000000000 Z
12
+ date: 2012-04-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: TCP-socket сервер и клиент для платформы "1С:Предприятие"
15
15
  email:
@@ -20,6 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - LICENSE.BSD
22
22
  - s41c.gemspec
23
+ - s41c-0.0.6.gem
23
24
  - README.md
24
25
  - lib/s41c/sandbox.rb
25
26
  - lib/s41c/version.rb