liquid-ext 3.4.1 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b764df4729f17b844fdee83ac5b3e15dd6219c86
4
- data.tar.gz: 0e2d9e998e92281068cfaf817f61690a26e80c65
3
+ metadata.gz: 9ab68e51c9209484d0aa966b8498578a715ebba1
4
+ data.tar.gz: 13123b71496c35456f68419ac5868a06a730c1fe
5
5
  SHA512:
6
- metadata.gz: 3aa9bd7e4bae835d482e9fea03543b2739ccbd25f37d4a024118f4c64cb4d1574e8c763aea78e4ecf60f9a9699161d1ae75edb20b7df10fd8eb484dad8048825
7
- data.tar.gz: 99c4a27e5ac4f51f3786b886cdb947f5ed4cbd75b26cbfdf95075952ee2987f489411dd60b031ff7fdcbdb4c3168e7d73d1d5dcec6b44676311b142394657fb5
6
+ metadata.gz: 6ff8cddc75aef8e7e262451341db272c9e7fe2cf0003bead9d8cedb9247cef145b42d4513ebee0615b01461e06e5d0a9108b546b7003e0f5563f57fb0994ad2a
7
+ data.tar.gz: 8ca4dcdf20fdf87b1aa0714f5253e4f5f89a69b76a0219e3d670b983ddff16625be2fb49cb3b5ce46129e1dbb37cd538bba40007a21332bad442466581cac8e9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liquid-ext (3.4.1)
4
+ liquid-ext (3.4.2)
5
5
  activesupport
6
6
  erubis
7
7
  jmx4r
@@ -12,7 +12,7 @@ PATH
12
12
  GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
- activesupport (4.1.0)
15
+ activesupport (4.1.1)
16
16
  i18n (~> 0.6, >= 0.6.9)
17
17
  json (~> 1.7, >= 1.7.7)
18
18
  minitest (~> 5.1)
@@ -22,16 +22,16 @@ GEM
22
22
  bond (0.5.1-java)
23
23
  brice (0.2.9)
24
24
  ruby-nuggets (>= 0.5.2)
25
- cane (2.6.1)
25
+ cane (2.6.2)
26
26
  parallel
27
27
  coderay (1.1.0)
28
28
  diff-lcs (1.2.5)
29
29
  docile (1.1.3)
30
30
  erubis (2.7.0)
31
31
  ffi (1.9.3-java)
32
- fuubar (1.3.2)
32
+ fuubar (1.3.3)
33
33
  rspec (>= 2.14.0, < 3.1.0)
34
- ruby-progressbar (~> 1.3)
34
+ ruby-progressbar (~> 1.4)
35
35
  hirb (0.7.1)
36
36
  i18n (0.6.9)
37
37
  jmx4r (0.1.4)
@@ -55,12 +55,10 @@ GEM
55
55
  yard
56
56
  log_switch (0.4.0)
57
57
  method_source (0.8.2)
58
- mini_portile (0.5.3)
59
- minitest (5.3.3)
58
+ minitest (5.3.4)
60
59
  mixlib-cli (1.5.0)
61
- multi_json (1.9.2)
62
- nokogiri (1.6.1-java)
63
- mini_portile (~> 0.5.0)
60
+ multi_json (1.10.0)
61
+ nokogiri (1.6.2.1-java)
64
62
  parallel (1.0.0)
65
63
  pry (0.9.12.6-java)
66
64
  coderay (~> 1.0)
@@ -68,7 +66,7 @@ GEM
68
66
  slop (~> 3.4)
69
67
  spoon (~> 0.0)
70
68
  rainbow (2.0.0)
71
- rake (10.3.1)
69
+ rake (10.3.2)
72
70
  reek (1.3.7)
73
71
  rainbow
74
72
  ruby2ruby (~> 2.0.8)
@@ -84,12 +82,12 @@ GEM
84
82
  rspec-expectations (2.14.5)
85
83
  diff-lcs (>= 1.1.3, < 2.0)
86
84
  rspec-mocks (2.14.6)
87
- ruby-nuggets (0.9.8.1)
88
- ruby-progressbar (1.4.2)
85
+ ruby-nuggets (0.9.9)
86
+ ruby-progressbar (1.5.1)
89
87
  ruby2ruby (2.0.8)
90
88
  ruby_parser (~> 3.1)
91
89
  sexp_processor (~> 4.0)
92
- ruby_parser (3.5.0)
90
+ ruby_parser (3.6.1)
93
91
  sexp_processor (~> 4.1)
94
92
  sexp_processor (4.4.3)
95
93
  simplecov (0.8.2)
@@ -111,7 +109,7 @@ GEM
111
109
  text-table (1.2.3)
112
110
  thread_safe (0.3.3-java)
113
111
  timecop (0.7.1)
114
- tins (1.1.0)
112
+ tins (1.3.0)
115
113
  tzinfo (1.1.0)
116
114
  thread_safe (~> 0.1)
117
115
  yard (0.8.7.4)
@@ -62,7 +62,7 @@ class CLI
62
62
 
63
63
  # infer some variables
64
64
  opts = cli.config.merge({
65
- fqdn: Socket.gethostbyname(Socket.gethostname).first
65
+ fqdn: Socket.fqdn
66
66
  })
67
67
 
68
68
  # sneak in opts without subclassing
@@ -1,43 +1,45 @@
1
- require 'active_support/core_ext/hash/keys'
2
- require 'jmx4r'
1
+ if RUBY_PLATFORM == "java"
2
+ require 'active_support/core_ext/hash/keys'
3
+ require 'jmx4r'
3
4
 
4
- java_import 'javax.management.RuntimeMBeanException'
5
- java_import 'java.lang.UnsupportedOperationException'
5
+ java_import 'javax.management.RuntimeMBeanException'
6
+ java_import 'java.lang.UnsupportedOperationException'
6
7
 
7
- class JMX::MBean
8
+ class JMX::MBean
8
9
 
9
- def self.to_tree
10
- find_all_by_name("*:*").inject({}) do |result, mbean|
11
- domain = mbean.object_name.domain
12
- properties = mbean.object_name.key_property_list_string.split(',')
13
- mresult = result[domain] ||= {}
14
- mresult = mresult[properties.shift] ||= {} until properties.empty?
15
- mbean.to_h(mresult)
16
- result
10
+ def self.to_tree
11
+ find_all_by_name("*:*").inject({}) do |result, mbean|
12
+ domain = mbean.object_name.domain
13
+ properties = mbean.object_name.key_property_list_string.split(',')
14
+ mresult = result[domain] ||= {}
15
+ mresult = mresult[properties.shift] ||= {} until properties.empty?
16
+ mbean.to_h(mresult)
17
+ result
18
+ end
17
19
  end
18
- end
19
20
 
20
- def to_h(hsh = {})
21
- attributes.keys.inject(hsh) do |result, key|
22
- result[key.to_sym] = get_value(key)
23
- result
24
- end.merge!({
25
- object_name: object_name.to_s,
26
- })
27
- end
21
+ def to_h(hsh = {})
22
+ attributes.keys.inject(hsh) do |result, key|
23
+ result[key.to_sym] = get_value(key)
24
+ result
25
+ end.merge!({
26
+ object_name: object_name.to_s,
27
+ })
28
+ end
28
29
 
29
- def get_value(key)
30
- case value = send(key)
31
- when Java::JavaxManagementOpenmbean::CompositeDataSupport
32
- Hash[value.to_a].symbolize_keys
33
- when Enumerable
34
- value.to_a
35
- else
36
- value
30
+ def get_value(key)
31
+ case value = send(key)
32
+ when Java::JavaxManagementOpenmbean::CompositeDataSupport
33
+ Hash[value.to_a].symbolize_keys
34
+ when Enumerable
35
+ value.to_a
36
+ else
37
+ value
38
+ end
39
+ rescue RuntimeMBeanException => e
40
+ raise unless e.cause.is_a?(UnsupportedOperationException)
41
+ nil
37
42
  end
38
- rescue RuntimeMBeanException => e
39
- raise unless e.cause.is_a?(UnsupportedOperationException)
40
- nil
41
- end
42
43
 
44
+ end
43
45
  end
@@ -2,11 +2,10 @@ require 'ipaddr'
2
2
 
3
3
  class Socket
4
4
  def self.ipaddress
5
- hostname = %x(hostname).chomp
6
- getaddrinfo(hostname, nil).first[3]
5
+ getaddrinfo(gethostname, nil).first[3]
7
6
  end
8
7
 
9
8
  def self.fqdn
10
- Socket.gethostbyaddr(IPAddr.new(ipaddress).hton)[0]
9
+ gethostbyaddr(IPAddr.new(ipaddress).hton)[0]
11
10
  end
12
11
  end
@@ -1,4 +1,8 @@
1
- java_import 'org.slf4j.LoggerFactory'
1
+ if RUBY_PLATFORM == "java"
2
+ java_import 'org.slf4j.LoggerFactory'
3
+ else
4
+ require 'logger'
5
+ end
2
6
 
3
7
  module Liquid
4
8
  class Logger
@@ -7,14 +11,16 @@ module Liquid
7
11
  attr_accessor :appender
8
12
 
9
13
  def initialize(name, progname = nil)
14
+ @java = RUBY_PLATFORM == "java"
10
15
  @progname = progname || File.basename($0)
11
- @logger = LoggerFactory.getLogger(name)
16
+ @logger = @java ? LoggerFactory.getLogger(name) : ::Logger.new(STDOUT)
12
17
  @exceptions = {}
13
18
  @exception_handlers = [method(:_log_error_exception)]
14
19
  unmute!
15
20
  end
16
21
 
17
22
  def reload!
23
+ return unless @java
18
24
  root = org.apache.log4j.Logger.getRootLogger
19
25
  appender = @appender.new
20
26
  appender.name = "default"
@@ -26,17 +32,25 @@ module Liquid
26
32
  end
27
33
 
28
34
  def mute!
29
- @appender = org.apache.log4j.varia.NullAppender
35
+ if @java
36
+ @appender = org.apache.log4j.varia.NullAppender
37
+ else
38
+ @logger = ::Logger.new("/dev/null")
39
+ end
30
40
  reload!
31
41
  end
32
42
 
33
43
  def unmute!
34
- @appender = org.apache.log4j.ConsoleAppender
44
+ if @java
45
+ @appender = org.apache.log4j.ConsoleAppender
46
+ else
47
+ @logger = ::Logger.new(STDOUT)
48
+ end
35
49
  reload!
36
50
  end
37
51
 
38
52
  def trace?
39
- @logger.trace_enabled?
53
+ @java ? @logger.trace_enabled? : @logger.trace?
40
54
  end
41
55
 
42
56
  def trace(*args, &block)
@@ -46,7 +60,7 @@ module Liquid
46
60
  end
47
61
 
48
62
  def debug?
49
- @logger.debug_enabled?
63
+ @java ? @logger.debug_enabled? : @logger.debug?
50
64
  end
51
65
 
52
66
  def debug(*args, &block)
@@ -56,7 +70,7 @@ module Liquid
56
70
  end
57
71
 
58
72
  def info?
59
- @logger.info_enabled?
73
+ @java ? @logger.info_enabled? : @logger.info?
60
74
  end
61
75
 
62
76
  def info(*args, &block)
@@ -66,7 +80,7 @@ module Liquid
66
80
  end
67
81
 
68
82
  def warn?
69
- @logger.warn_enabled?
83
+ @java ? @logger.warn_enabled? : @logger.warn?
70
84
  end
71
85
 
72
86
  def warn(*args, &block)
@@ -76,7 +90,7 @@ module Liquid
76
90
  end
77
91
 
78
92
  def error?
79
- @logger.error_enabled?
93
+ @java ? @logger.error_enabled? : @logger.error?
80
94
  end
81
95
 
82
96
  def error(*args, &block)
@@ -1,53 +1,55 @@
1
- java_import 'com.codahale.metrics.Histogram'
2
- java_import 'com.codahale.metrics.JmxReporter'
3
- java_import 'com.codahale.metrics.MetricRegistry'
4
- java_import 'java.util.concurrent.TimeUnit'
1
+ if RUBY_PLATFORM == "java"
2
+ java_import 'com.codahale.metrics.Histogram'
3
+ java_import 'com.codahale.metrics.JmxReporter'
4
+ java_import 'com.codahale.metrics.MetricRegistry'
5
+ java_import 'java.util.concurrent.TimeUnit'
5
6
 
6
- class Histogram
7
- java_alias :update_long, :update, [Java::long]
8
- end
7
+ class Histogram
8
+ java_alias :update_long, :update, [Java::long]
9
+ end
9
10
 
10
- module Metrics
11
- @registry = MetricRegistry.new
12
- @reporters = []
11
+ module Metrics
12
+ @registry = MetricRegistry.new
13
+ @reporters = []
13
14
 
14
- def self.start(period = nil, unit = nil)
15
- @period ||= 60
16
- @unit ||= TimeUnit::SECONDS
17
- JmxReporter.forRegistry(@registry).build.start
18
- Signal.register_shutdown_handler { stop }
19
- end
15
+ def self.start(period = nil, unit = nil)
16
+ @period ||= 60
17
+ @unit ||= TimeUnit::SECONDS
18
+ JmxReporter.forRegistry(@registry).build.start
19
+ Signal.register_shutdown_handler { stop }
20
+ end
20
21
 
21
- def self.stop
22
- @reporters.each do |reporter|
23
- reporter.run if reporter.respond_to?(:run)
24
- reporter.stop
22
+ def self.stop
23
+ @reporters.each do |reporter|
24
+ reporter.run if reporter.respond_to?(:run)
25
+ reporter.stop
26
+ end
27
+ @reporters.clear
25
28
  end
26
- @reporters.clear
27
- end
28
29
 
29
- def self.register_reporter(reporter)
30
- reporter.start(@period, @unit)
31
- @reporters << reporter
32
- end
30
+ def self.register_reporter(reporter)
31
+ reporter.start(@period, @unit)
32
+ @reporters << reporter
33
+ end
33
34
 
34
- def self.registry
35
- @registry
36
- end
35
+ def self.registry
36
+ @registry
37
+ end
37
38
 
38
- def self.counter(name)
39
- registry.counter(name)
40
- end
39
+ def self.counter(name)
40
+ registry.counter(name)
41
+ end
41
42
 
42
- def self.meter(name)
43
- registry.meter(name)
44
- end
43
+ def self.meter(name)
44
+ registry.meter(name)
45
+ end
45
46
 
46
- def self.histogram(name)
47
- registry.histogram(name)
48
- end
47
+ def self.histogram(name)
48
+ registry.histogram(name)
49
+ end
49
50
 
50
- def self.timer(name)
51
- registry.timer(name)
51
+ def self.timer(name)
52
+ registry.timer(name)
53
+ end
52
54
  end
53
55
  end
@@ -1,70 +1,72 @@
1
- require 'liquid/metrics'
2
- require 'liquid/tracker'
1
+ if RUBY_PLATFORM == "java"
2
+ require 'liquid/metrics'
3
+ require 'liquid/tracker'
3
4
 
4
- module Liquid
5
- class Server
6
- def initialize
7
- $log.info("#{self.class.name.downcase} #{RUBY_DESCRIPTION}")
8
- $log.info("#{self.class.name.downcase}", env: Env.mode)
9
- Signal.register_shutdown_handler { System.exit(0) }
10
- Signal.register_shutdown_handler { ZContext.destroy }
11
- initialize_raven
12
- initialize_tracker
13
- initialize_metrics
14
- initialize_health_checks
15
- end
5
+ module Liquid
6
+ class Server
7
+ def initialize
8
+ $log.info("#{self.class.name.downcase} #{RUBY_DESCRIPTION}")
9
+ $log.info("#{self.class.name.downcase}", env: Env.mode)
10
+ Signal.register_shutdown_handler { System.exit(0) }
11
+ Signal.register_shutdown_handler { ZContext.destroy }
12
+ initialize_raven
13
+ initialize_tracker
14
+ initialize_metrics
15
+ initialize_health_checks
16
+ end
16
17
 
17
- def initialize_raven
18
- return unless $conf.raven
19
- require 'raven'
20
- Raven.configure do |config|
21
- config.dsn = $conf.raven.dsn
22
- config.logger = $log
18
+ def initialize_raven
19
+ return unless $conf.raven
20
+ require 'raven'
21
+ Raven.configure do |config|
22
+ config.dsn = $conf.raven.dsn
23
+ config.logger = $log
24
+ end
25
+ $log.add_exception_handler do |exc, message, attribs|
26
+ Raven.capture_exception(exc)
27
+ end
23
28
  end
24
- $log.add_exception_handler do |exc, message, attribs|
25
- Raven.capture_exception(exc)
29
+
30
+ def initialize_tracker
31
+ if $conf.tracker.kafka.enabled
32
+ # http://kafka.apache.org/documentation.html#producerconfigs
33
+ properties = java.util.Properties.new
34
+ properties['metadata.broker.list'] = $conf.tracker.kafka.brokers.join(',')
35
+ properties['producer.type'] = 'async'
36
+ properties['serializer.class'] = 'kafka.serializer.StringEncoder'
37
+ $tracker = ::Tracker::KafkaTracker.new(properties, $conf.tracker.dimensions)
38
+ else
39
+ $tracker = ::Tracker::LoggerTracker.new($conf.tracker.dimensions)
40
+ end
41
+ Signal.register_shutdown_handler { $tracker.shutdown }
26
42
  end
27
- end
28
43
 
29
- def initialize_tracker
30
- if $conf.tracker.kafka.enabled
31
- # http://kafka.apache.org/documentation.html#producerconfigs
32
- properties = java.util.Properties.new
33
- properties['metadata.broker.list'] = $conf.tracker.kafka.brokers.join(',')
34
- properties['producer.type'] = 'async'
35
- properties['serializer.class'] = 'kafka.serializer.StringEncoder'
36
- $tracker = ::Tracker::KafkaTracker.new(properties, $conf.tracker.dimensions)
37
- else
38
- $tracker = ::Tracker::LoggerTracker.new($conf.tracker.dimensions)
44
+ def initialize_metrics
45
+ ::Metrics.start
46
+ ::Metrics::TrackerReporter.new($tracker.with_topic('metrics'))
47
+ Signal.register_shutdown_handler { ::Metrics.stop }
39
48
  end
40
- Signal.register_shutdown_handler { $tracker.shutdown }
41
- end
42
49
 
43
- def initialize_metrics
44
- ::Metrics.start
45
- ::Metrics::TrackerReporter.new($tracker.with_topic('metrics'))
46
- Signal.register_shutdown_handler { ::Metrics.stop }
47
- end
50
+ def initialize_health_checks
51
+ Thread.new do
52
+ Thread.name = "Health Check"
53
+ HealthCheck.poll
54
+ end
55
+ end
48
56
 
49
- def initialize_health_checks
50
- Thread.new do
51
- Thread.name = "Health Check"
52
- HealthCheck.poll
57
+ def initialize_zmachine
58
+ require 'zmachine'
59
+ ZMachine.logger = $log
60
+ ZMachine.debug = true if $conf.zmachine.debug
61
+ ZMachine.heartbeat_interval = 0.1
62
+ Signal.register_shutdown_handler { ZMachine.stop }
53
63
  end
54
- end
55
64
 
56
- def initialize_zmachine
57
- require 'zmachine'
58
- ZMachine.logger = $log
59
- ZMachine.debug = true if $conf.zmachine.debug
60
- ZMachine.heartbeat_interval = 0.1
61
- Signal.register_shutdown_handler { ZMachine.stop }
62
- end
65
+ def run
66
+ # by default wait for all workers
67
+ Thread.join
68
+ end
63
69
 
64
- def run
65
- # by default wait for all workers
66
- Thread.join
67
70
  end
68
-
69
71
  end
70
72
  end
@@ -1,30 +1,32 @@
1
- java_import 'java.lang.System'
1
+ if RUBY_PLATFORM == "java"
2
+ java_import 'java.lang.System'
2
3
 
3
- module Timing
4
- def self.start
5
- TimingContext.new
6
- end
7
-
8
- class TimingContext
9
- def initialize
10
- reset!
4
+ module Timing
5
+ def self.start
6
+ TimingContext.new
11
7
  end
12
8
 
13
- def reset!
14
- @start = @last_tick = System.nano_time
15
- end
9
+ class TimingContext
10
+ def initialize
11
+ reset!
12
+ end
16
13
 
17
- def tick
18
- rt = System.nano_time - @last_tick
19
- @last_tick = System.nano_time
20
- rt
21
- end
14
+ def reset!
15
+ @start = @last_tick = System.nano_time
16
+ end
22
17
 
23
- def stop
24
- rt = System.nano_time - @start
25
- reset!
26
- rt
27
- end
18
+ def tick
19
+ rt = System.nano_time - @last_tick
20
+ @last_tick = System.nano_time
21
+ rt
22
+ end
23
+
24
+ def stop
25
+ rt = System.nano_time - @start
26
+ reset!
27
+ rt
28
+ end
28
29
 
30
+ end
29
31
  end
30
32
  end
@@ -1,14 +1,16 @@
1
- require 'liquid/metrics'
2
- require 'liquid/metrics/tracker_reporter'
1
+ if RUBY_PLATFORM == "java"
2
+ require 'liquid/metrics'
3
+ require 'liquid/metrics/tracker_reporter'
3
4
 
4
- module Tracker
5
- class Metrics
6
- def self.event
7
- (@events ||= ::Metrics.meter("tracker.events")).mark
5
+ module Tracker
6
+ class Metrics
7
+ def self.event
8
+ (@events ||= ::Metrics.meter("tracker.events")).mark
9
+ end
8
10
  end
9
11
  end
10
- end
11
12
 
12
- Dir[File.expand_path("../tracker/*.rb", __FILE__)].each do |f|
13
- require f
13
+ Dir[File.expand_path("../tracker/*.rb", __FILE__)].each do |f|
14
+ require f
15
+ end
14
16
  end
@@ -1,71 +1,73 @@
1
- java_import 'gnu.trove.TIntCollection'
2
- java_import 'gnu.trove.set.hash.TIntHashSet'
3
- java_import 'gnu.trove.set.hash.TLongHashSet'
4
- java_import 'gnu.trove.map.hash.TIntObjectHashMap'
5
- java_import 'gnu.trove.map.hash.TLongObjectHashMap'
1
+ if RUBY_PLATFORM == "java"
2
+ java_import 'gnu.trove.TIntCollection'
3
+ java_import 'gnu.trove.set.hash.TIntHashSet'
4
+ java_import 'gnu.trove.set.hash.TLongHashSet'
5
+ java_import 'gnu.trove.map.hash.TIntObjectHashMap'
6
+ java_import 'gnu.trove.map.hash.TLongObjectHashMap'
6
7
 
7
- module TMap
8
- def each
9
- it = iterator
10
- while it.has_next
11
- it.advance
12
- yield it.key, it.value
8
+ module TMap
9
+ def each
10
+ it = iterator
11
+ while it.has_next
12
+ it.advance
13
+ yield it.key, it.value
14
+ end
13
15
  end
14
16
  end
15
- end
16
17
 
17
- module TSet
18
- def each
19
- it = iterator
20
- while it.has_next
21
- yield it.next
18
+ module TSet
19
+ def each
20
+ it = iterator
21
+ while it.has_next
22
+ yield it.next
23
+ end
22
24
  end
23
- end
24
25
 
25
- def inspect
26
- if size > 1000
27
- "#{self.class.name}{too large to display,l=#{size}}"
28
- else
29
- to_string
26
+ def inspect
27
+ if size > 1000
28
+ "#{self.class.name}{too large to display,l=#{size}}"
29
+ else
30
+ to_string
31
+ end
30
32
  end
31
33
  end
32
- end
33
34
 
34
- class TLongObjectHashMap
35
- include TMap
36
- alias :has_key? :containsKey
37
- alias :[] :get
38
- alias :[]= :put
39
- alias :length :size
40
- alias :delete :remove
41
- end
35
+ class TLongObjectHashMap
36
+ include TMap
37
+ alias :has_key? :containsKey
38
+ alias :[] :get
39
+ alias :[]= :put
40
+ alias :length :size
41
+ alias :delete :remove
42
+ end
42
43
 
43
- class TIntObjectHashMap
44
- include TMap
45
- alias :has_key? :containsKey
46
- alias :[] :get
47
- alias :[]= :put
48
- alias :length :size
49
- alias :delete :remove
50
- end
44
+ class TIntObjectHashMap
45
+ include TMap
46
+ alias :has_key? :containsKey
47
+ alias :[] :get
48
+ alias :[]= :put
49
+ alias :length :size
50
+ alias :delete :remove
51
+ end
51
52
 
52
- class TLongHashSet
53
- include TSet
54
- alias :include? :contains
55
- alias :length :size
56
- alias :delete :remove
57
- end
53
+ class TLongHashSet
54
+ include TSet
55
+ alias :include? :contains
56
+ alias :length :size
57
+ alias :delete :remove
58
+ end
58
59
 
59
- class TIntHashSet
60
- include TSet
61
- alias :include? :contains
62
- alias :length :size
63
- alias :delete :remove
60
+ class TIntHashSet
61
+ include TSet
62
+ alias :include? :contains
63
+ alias :length :size
64
+ alias :delete :remove
64
65
 
65
- java_alias :concat_ints, :addAll, [TIntCollection.java_class]
66
+ java_alias :concat_ints, :addAll, [TIntCollection.java_class]
66
67
 
67
- def concat(list)
68
- return if !list
69
- concat_ints list
68
+ def concat(list)
69
+ return if !list
70
+ concat_ints list
71
+ end
70
72
  end
71
73
  end
@@ -1,130 +1,132 @@
1
- java_import "org.zeromq.ZContext"
2
- java_import "org.zeromq.ZFrame"
3
- java_import "org.zeromq.ZLoop"
4
- java_import "org.zeromq.ZMQ"
5
- java_import "org.zeromq.ZMQException"
6
- java_import "org.zeromq.ZMQQueue"
7
- java_import "org.zeromq.ZMsg"
8
- java_import "org.zeromq.ZThread"
9
-
10
- class ZMQ
11
- class Socket
12
- # for performance reason we alias the method here (otherwise it uses reflections all the time!)
13
- # super ugly, since we need to dynamically infer the java class of byte[]
14
- java_alias :send_byte_buffer, :sendByteBuffer, [Java::JavaNio::ByteBuffer.java_class, Java::int]
15
- java_alias :send_byte_array, :send, [[].to_java(:byte).java_class, Java::int]
16
- java_alias :recv_byte_array, :recv, [Java::int]
17
-
18
- def write(buffer)
19
- bytes = send_byte_buffer(buffer, 0)
20
- buffer.position(buffer.position + bytes)
1
+ if RUBY_PLATFORM == "java"
2
+ java_import "org.zeromq.ZContext"
3
+ java_import "org.zeromq.ZFrame"
4
+ java_import "org.zeromq.ZLoop"
5
+ java_import "org.zeromq.ZMQ"
6
+ java_import "org.zeromq.ZMQException"
7
+ java_import "org.zeromq.ZMQQueue"
8
+ java_import "org.zeromq.ZMsg"
9
+ java_import "org.zeromq.ZThread"
10
+
11
+ class ZMQ
12
+ class Socket
13
+ # for performance reason we alias the method here (otherwise it uses reflections all the time!)
14
+ # super ugly, since we need to dynamically infer the java class of byte[]
15
+ java_alias :send_byte_buffer, :sendByteBuffer, [Java::JavaNio::ByteBuffer.java_class, Java::int]
16
+ java_alias :send_byte_array, :send, [[].to_java(:byte).java_class, Java::int]
17
+ java_alias :recv_byte_array, :recv, [Java::int]
18
+
19
+ def write(buffer)
20
+ bytes = send_byte_buffer(buffer, 0)
21
+ buffer.position(buffer.position + bytes)
22
+ end
21
23
  end
22
24
  end
23
- end
24
25
 
25
- class ZContext
26
+ class ZContext
26
27
 
27
- def create_socket_with_opts(type, opts = {})
28
- socket = create_socket(type)
29
- opts.each do |key, value|
30
- next if key == :bind || key == :connect
31
- socket.__send__("#{key}=", value)
28
+ def create_socket_with_opts(type, opts = {})
29
+ socket = create_socket(type)
30
+ opts.each do |key, value|
31
+ next if key == :bind || key == :connect
32
+ socket.__send__("#{key}=", value)
33
+ end
34
+ socket.connect(opts[:connect]) if opts[:connect]
35
+ socket.bind(opts[:bind]) if opts[:bind]
36
+ socket
32
37
  end
33
- socket.connect(opts[:connect]) if opts[:connect]
34
- socket.bind(opts[:bind]) if opts[:bind]
35
- socket
36
- end
37
38
 
38
- def router(opts = {})
39
- create_socket_with_opts(ZMQ::ROUTER, opts)
40
- end
39
+ def router(opts = {})
40
+ create_socket_with_opts(ZMQ::ROUTER, opts)
41
+ end
41
42
 
42
- def dealer(opts = {})
43
- create_socket_with_opts(ZMQ::DEALER, opts)
44
- end
43
+ def dealer(opts = {})
44
+ create_socket_with_opts(ZMQ::DEALER, opts)
45
+ end
45
46
 
46
- def push(opts = {})
47
- create_socket_with_opts(ZMQ::PUSH, opts)
48
- end
47
+ def push(opts = {})
48
+ create_socket_with_opts(ZMQ::PUSH, opts)
49
+ end
49
50
 
50
- def pull(opts = {})
51
- create_socket_with_opts(ZMQ::PULL, opts)
52
- end
51
+ def pull(opts = {})
52
+ create_socket_with_opts(ZMQ::PULL, opts)
53
+ end
53
54
 
54
- def pub(opts = {})
55
- create_socket_with_opts(ZMQ::PUB, opts)
56
- end
55
+ def pub(opts = {})
56
+ create_socket_with_opts(ZMQ::PUB, opts)
57
+ end
57
58
 
58
- def sub(opts = {})
59
- create_socket_with_opts(ZMQ::SUB, opts)
60
- end
59
+ def sub(opts = {})
60
+ create_socket_with_opts(ZMQ::SUB, opts)
61
+ end
61
62
 
62
- ## global context instance
63
+ ## global context instance
63
64
 
64
- @mutex = Mutex.new
65
+ @mutex = Mutex.new
65
66
 
66
- def self.instance
67
- @mutex.synchronize do
68
- @context ||= new
67
+ def self.instance
68
+ @mutex.synchronize do
69
+ @context ||= new
70
+ end
69
71
  end
70
- end
71
72
 
72
- def self.create_socket(type)
73
- instance.create_socket(type)
74
- end
73
+ def self.create_socket(type)
74
+ instance.create_socket(type)
75
+ end
75
76
 
76
- def self.destroy_socket(socket)
77
- instance.destroy_socket(socket)
78
- end
77
+ def self.destroy_socket(socket)
78
+ instance.destroy_socket(socket)
79
+ end
79
80
 
80
- # really incredible how many exceptions a simple shutdown can throw all over
81
- # the place. if it's one thing ZMQ did never get right it is the shutdown
82
- # logic ...
83
- def self.destroy
84
- instance.destroy
85
- rescue Java::JavaLang::IllegalStateException, Java::JavaLang::NullPointerException
86
- # ignore broken shutdown in zeromq
87
- end
81
+ # really incredible how many exceptions a simple shutdown can throw all over
82
+ # the place. if it's one thing ZMQ did never get right it is the shutdown
83
+ # logic ...
84
+ def self.destroy
85
+ instance.destroy
86
+ rescue Java::JavaLang::IllegalStateException, Java::JavaLang::NullPointerException
87
+ # ignore broken shutdown in zeromq
88
+ end
88
89
 
89
- DestroyExceptions = [
90
- Java::JavaNioChannels::AsynchronousCloseException,
91
- Java::JavaNioChannels::ClosedChannelException,
92
- Java::JavaNioChannels::ClosedSelectorException,
93
- ]
94
-
95
- Exceptions = DestroyExceptions + [
96
- Java::OrgZeromq::ZMQException,
97
- Java::Zmq::ZError::IOException,
98
- ]
99
-
100
- def self.destroy_exception?(e)
101
- return true if e.is_a?(Java::OrgZeromq::ZMQException) && ZMQ::Error::ETERM.getCode == e.getErrorCode
102
- return true if e.is_a?(Java::Zmq::ZError::IOException) && DestroyExceptions.include?(e.cause.class)
103
- return true if DestroyExceptions.include?(e.class)
104
- return false
105
- end
90
+ DestroyExceptions = [
91
+ Java::JavaNioChannels::AsynchronousCloseException,
92
+ Java::JavaNioChannels::ClosedChannelException,
93
+ Java::JavaNioChannels::ClosedSelectorException,
94
+ ]
95
+
96
+ Exceptions = DestroyExceptions + [
97
+ Java::OrgZeromq::ZMQException,
98
+ Java::Zmq::ZError::IOException,
99
+ ]
100
+
101
+ def self.destroy_exception?(e)
102
+ return true if e.is_a?(Java::OrgZeromq::ZMQException) && ZMQ::Error::ETERM.getCode == e.getErrorCode
103
+ return true if e.is_a?(Java::Zmq::ZError::IOException) && DestroyExceptions.include?(e.cause.class)
104
+ return true if DestroyExceptions.include?(e.class)
105
+ return false
106
+ end
106
107
 
107
- def self.router(opts = {})
108
- instance.router(opts)
109
- end
108
+ def self.router(opts = {})
109
+ instance.router(opts)
110
+ end
110
111
 
111
- def self.dealer(opts = {})
112
- instance.dealer(opts)
113
- end
112
+ def self.dealer(opts = {})
113
+ instance.dealer(opts)
114
+ end
114
115
 
115
- def self.push(opts = {})
116
- instance.push(opts)
117
- end
116
+ def self.push(opts = {})
117
+ instance.push(opts)
118
+ end
118
119
 
119
- def self.pull(opts = {})
120
- instance.pull(opts)
121
- end
120
+ def self.pull(opts = {})
121
+ instance.pull(opts)
122
+ end
122
123
 
123
- def self.pub(opts = {})
124
- instance.pub(opts)
125
- end
124
+ def self.pub(opts = {})
125
+ instance.pub(opts)
126
+ end
126
127
 
127
- def self.sub(opts = {})
128
- instance.sub(opts)
128
+ def self.sub(opts = {})
129
+ instance.sub(opts)
130
+ end
129
131
  end
130
132
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "liquid-ext"
5
- spec.version = "3.4.1"
5
+ spec.version = "3.4.2"
6
6
  spec.authors = ["LiquidM, Inc."]
7
7
  spec.email = ["opensource@liquidm.com"]
8
8
  spec.description = %q{Ruby core extensions and helper libraries}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - LiquidM, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport