smith 0.6.3.1 → 0.6.4
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.
- checksums.yaml +4 -4
- data/lib/smith/acl_compiler.rb +18 -37
- data/lib/smith/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15b0f5502947a211eac261f595a91abae778941
|
4
|
+
data.tar.gz: ee098f6e8ce36b909cfd0c521b7208f73ca89798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9000646169a24af31b427389e24d03f8bdaee492bf3ccc3f9dd12e975335711d1e0c468d99c78c0f83ac119bad5f3848fb24f36ef1268cfabbb7768d96c6414
|
7
|
+
data.tar.gz: ec817e13da4fc3cdf8e56f1ef252f45c794882c7e69c1fb9eef19b6f24ffe394084b793b13c553c5bdcf3086ab6de7ba8856b1080dc92702c9b11f8095923e0d
|
data/lib/smith/acl_compiler.rb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require 'ffi'
|
3
2
|
require "tempfile"
|
4
3
|
require 'ruby_parser'
|
4
|
+
|
5
5
|
require 'smith/messaging/acl_type_cache'
|
6
6
|
|
7
7
|
module Smith
|
8
8
|
class ACLCompiler
|
9
9
|
|
10
10
|
include Logger
|
11
|
-
extend FFI::Library
|
12
|
-
|
13
|
-
def self.find_so
|
14
|
-
$:.map{|p| Pathname.new(p).join("ruby_generator.so")}.detect{|so| so.exist? }
|
15
|
-
end
|
16
|
-
|
17
|
-
ffi_lib(find_so)
|
18
|
-
attach_function(:_rprotoc_extern, [:int, :pointer], :int32)
|
19
11
|
|
20
12
|
def initialize
|
21
13
|
@acl_type_cache = AclTypeCache.instance
|
@@ -28,13 +20,13 @@ module Smith
|
|
28
20
|
Smith.acl_path.each do |path|
|
29
21
|
$LOAD_PATH << path
|
30
22
|
|
31
|
-
|
23
|
+
acl_files = path_glob(path)
|
32
24
|
out_of_date_acls = path_glob(path).select { |p| should_compile?(p) }
|
33
25
|
if out_of_date_acls.size > 0
|
34
|
-
compile_on_path(path,
|
26
|
+
compile_on_path(path, acl_files, out_of_date_acls)
|
35
27
|
end
|
36
28
|
|
37
|
-
|
29
|
+
acl_files.each do |acl_file|
|
38
30
|
acl_class_path = acl_compiled_path(acl_file)
|
39
31
|
load_acl(acl_class_path)
|
40
32
|
add_to_type_cache(acl_class_path)
|
@@ -49,36 +41,25 @@ module Smith
|
|
49
41
|
|
50
42
|
unless acls.empty?
|
51
43
|
Dir.chdir(path) do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
args += ffi_acls
|
63
|
-
argv = FFI::MemoryPointer.new(:pointer, args.size)
|
64
|
-
|
65
|
-
args.each_with_index { |p, index| argv[index].put_pointer(0, p) }
|
66
|
-
|
67
|
-
errors = capture_stderr do
|
68
|
-
self._rprotoc_extern(args.compact.size, argv)
|
69
|
-
end.split("\n")
|
70
|
-
|
71
|
-
errors.each do |error|
|
72
|
-
logger.fatal { "Cannot compile ACLs: #{error}" }
|
73
|
-
raise RuntimeError, error
|
74
|
-
end
|
75
|
-
ensure
|
76
|
-
GC.enable
|
44
|
+
cmd = %Q{sh -c 'protoc --ruby_out=#{Smith.acl_cache_path} -I #{path} #{out_of_date_acls.map(&:to_s).join(' ')} 2>&1'}
|
45
|
+
protoc = IO.popen(cmd)
|
46
|
+
output = protoc.read
|
47
|
+
protoc.close
|
48
|
+
|
49
|
+
if $?.exitstatus != 0
|
50
|
+
error = parse_protoc_error(output)
|
51
|
+
logger.fatal { "Cannot compile ACLs: #{error[:file]}" }
|
52
|
+
raise RuntimeError, output
|
77
53
|
end
|
78
54
|
end
|
79
55
|
end
|
80
56
|
end
|
81
57
|
|
58
|
+
def parse_protoc_error(s)
|
59
|
+
e = s.split(/:/)
|
60
|
+
{:file => e[0], :line => e[1], :pos => e[2], :error => e[3,-1]}
|
61
|
+
end
|
62
|
+
|
82
63
|
# Returns true if the .proto file is newer that the .pb.rb file
|
83
64
|
def should_compile?(file)
|
84
65
|
cached_file = Smith.acl_cache_path.join(file.basename).sub_ext(".pb.rb")
|
data/lib/smith/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Heycock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amqp
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: protobuf
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '3.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '3.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: state_machine
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,9 +274,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
274
|
version: '0'
|
275
275
|
requirements: []
|
276
276
|
rubyforge_project: smith
|
277
|
-
rubygems_version: 2.2.
|
277
|
+
rubygems_version: 2.2.2
|
278
278
|
signing_key:
|
279
279
|
specification_version: 4
|
280
280
|
summary: Multi-agent framework
|
281
281
|
test_files: []
|
282
|
-
has_rdoc: false
|