Navigation Menu

Skip to content

Commit

Permalink
Initial import!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
outcastgeek committed Dec 29, 2012
1 parent fb3ffac commit 6d64eb5
Show file tree
Hide file tree
Showing 20 changed files with 246 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
@@ -0,0 +1,3 @@
source :rubygems
edn
gemspec
Empty file added LICENSE
Empty file.
Empty file added Rakefile
Empty file.
3 changes: 3 additions & 0 deletions bin/jrzmq
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby

raise("JRubyZeroMQ only runs on JRuby.") unless (RUBY_PLATFORM =~ /java/)
48 changes: 48 additions & 0 deletions build.xml
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" ?>
<project name="JRubyZeroMQ" default="update" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">

<property name="ivy.install.version" value="2.2.0" />
<property name="ivy.lib.path" value="ivy" />
<property name="ivy.jar.file" value="${ivy.lib.path}/ivy-${ivy.install.version}.jar" />
<property name="deps.path" value="jars" />

<target name="-check">
<echo message="checking for local ivy installation..."/>
<condition property="skip.download">
<available file="${ivy.jar.file}" type="file"/>
</condition>
</target>

<target name="-download-ivy" depends="-check" unless="skip.download">
<echo message="installing ivy..."/>
<mkdir dir="${ivy.lib.path}" />
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>

<target name="-install-ivy" depends="-download-ivy" description="--> install ivy">
<path id="ivy.lib.path">
<fileset dir="${ivy.lib.path}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>

<target name="clean-ivy" description="--> clean the ivy installation">
<delete dir="${ivy.jar.dir}"/>
</target>

<target name="update" depends="-install-ivy" description="Download project dependencies">
<echo message="updating ivy dependencies..."/>
<ivy:settings file="ivysettings.xml" />
<!--<ivy:retrieve pattern="${deps.path}/[conf]/[artifact]-[revision].[ext]" />-->
<ivy:retrieve pattern="${deps.path}/[conf]/[artifact].[ext]" />
</target>

<target name="clean-deps" description="--> clean the dependencies">
<delete dir="${deps.path}"/>
</target>

<target name="clean" depends="clean-deps, clean-ivy" description="--> cleans the project directory">
<echo message="cleaning the project directory..."/>
</target>
</project>
26 changes: 26 additions & 0 deletions ivy.xml
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ivy-module version="2.0">
<info organisation="com.outcastgeek" module="jrzmq"/>

<configurations defaultconfmapping="compile->default">
<conf name="compile" description="Required to compile application"/>
<!-- <conf name="runtime" description="Additional run-time dependencies" extends="compile"/> -->
<!-- <conf name="test" description="Required for test only" extends="runtime"/> -->
</configurations>

<dependencies>
<!-- compile dependencies -->
<dependency org="org.jeromq" name="jeromq" rev="0.2.0"/>
<dependency org="ch.qos.logback" name="logback-core" rev="1.0.9"/>
<dependency org="ch.qos.logback" name="logback-classic" rev="1.0.9"/>
<dependency org="ch.qos.logback" name="logback-access" rev="1.0.9"/>
<dependency org="ch.qos.logback" name="logback-site" rev="1.0.9"/>

<!-- runtime dependencies -->
<!--<dependency org="org.slf4j" name="slf4j-simple" rev="1.6.6" conf="runtime->default"/>-->

<!-- test dependencies -->
<!--<dependency org="junit" name="junit" rev="4.10" conf="test->default"/>-->
</dependencies>

</ivy-module>
Binary file added ivy/ivy-2.2.0.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions ivysettings.xml
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ivysettings>
<settings defaultResolver="outcastgeek"/>
<resolvers>
<chain name="outcastgeek">
<ibiblio name="public" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
Binary file added jars/compile/jeromq.jar
Binary file not shown.
Binary file added jars/compile/logback-access.jar
Binary file not shown.
Binary file added jars/compile/logback-classic.jar
Binary file not shown.
Binary file added jars/compile/logback-core.jar
Binary file not shown.
Binary file added jars/compile/logback-site.jar
Binary file not shown.
Binary file added jars/compile/slf4j-api.jar
Binary file not shown.
29 changes: 29 additions & 0 deletions jrzmq.gemspec
@@ -0,0 +1,29 @@
$:.push File.expand_path("../lib/jrzmq", __FILE__)
require 'version'

Gem::Specification.new do |spec|
spec.name = "jrzmq"
spec.version = ZeroMQ::VERSION
spec.required_rubygems_version = Gem::Requirement.new(">= 1.2") \
if spec.respond_to?(:required_rubygems_version=)
spec.authors = [ "outcastgeek" ]
spec.description = 'ZeroMQ JRuby Bindings using JeroMQ.'
spec.summary = 'Provides JRuby Bindings to a Pure Java implementation of libzmq (ZeroMQ).'
spec.email = 'outcastgeek+JRubyZeroMQ@gmail.com'
spec.executables = [ "jrzmq" ]
# FIXME: Use Dir.glob for this
spec.files = %w(.gitignore
README.md
LICENSE
Rakefile
Gemfile
jrzmq.gemspec)
spec.files.concat(Dir['bin/*'])
spec.files.concat(Dir['lib/**/*.rb'])
spec.files.concat(Dir['jars/**/*.jar'])
spec.homepage = 'http://github.com/matadon/mizuno'
spec.has_rdoc = false
spec.require_paths = [ "lib" ]
spec.rubygems_version = '1.3.6'
spec.add_dependency('edn', '>= 1.0.0')
end
28 changes: 28 additions & 0 deletions lib/jrzmq.rb
@@ -0,0 +1,28 @@
require 'java'

module ZMQ

%w{../jars/compile jrzmq}.each do |dir|
path = File.expand_path(File.join(File.dirname(__FILE__), dir))
$LOAD_PATH << path
end

def ZMQ.initialize_logger
require_jars(%w(logback-access logback-classic logback-core logback-site slf4j-api))
rootLogger = Java::OrgSlf4j::LoggerFactory.getLogger(Java::ChQosLogbackClassic::Logger.java_class)
rootLoggerLogLevel = Java::ChQosLogbackClassic::Level::DEBUG
rootLogger.setLevel(rootLoggerLogLevel)
rootLogger.info "Root Logger Log Level was set to: #{rootLoggerLogLevel}"
end

def ZMQ.require_jars(*names)
names.flatten.each do |name|
require "#{name}.jar"
end
end
end

ZMQ.initialize_logger

require 'components'

85 changes: 85 additions & 0 deletions lib/jrzmq/components.rb
@@ -0,0 +1,85 @@

module ZMQ
require_jars(%w(jeromq))

java_import 'org.jeromq.ZMQ'

class Context < org.jeromq.ZMQ::Context
def initialize(ioThreads=java.lang.Runtime.getRuntime.availableProcessors)
super(ioThreads)
end
end

SNDMORE = org.jeromq.ZMQ::SNDMORE

DONTWAIT = org.jeromq.ZMQ::DONTWAIT

NOBLOCK = org.jeromq.ZMQ::NOBLOCK

PAIR = org.jeromq.ZMQ::PAIR

PUB = org.jeromq.ZMQ::PUB

SUB = org.jeromq.ZMQ::SUB

REQ = org.jeromq.ZMQ::REQ

REP = org.jeromq.ZMQ::REP

DEALER = org.jeromq.ZMQ::DEALER

XREQ = org.jeromq.ZMQ::XREQ

ROUTER = org.jeromq.ZMQ::ROUTER

XREP = org.jeromq.ZMQ::XREP

PULL = org.jeromq.ZMQ::PULL

PUSH = org.jeromq.ZMQ::PUSH

XPUB = org.jeromq.ZMQ::XPUB

XSUB = org.jeromq.ZMQ::XSUB

STREAMER = org.jeromq.ZMQ::STREAMER

FORWARDER = org.jeromq.ZMQ::FORWARDER

QUEUE = org.jeromq.ZMQ::QUEUE

UPSTREAM = org.jeromq.ZMQ::UPSTREAM

DOWNSTREAM = org.jeromq.ZMQ::DOWNSTREAM

POLLIN = org.jeromq.ZMQ::POLLIN

POLLOUT = org.jeromq.ZMQ::POLLOUT

POLLERR = org.jeromq.ZMQ::POLLERR
=begin
EVENT_CONNECTED = org.jeromq.ZMQ::EVENT_CONNECTED
EVENT_DELAYED = org.jeromq.ZMQ::EVENT_DELAYED
EVENT_RETRIED = org.jeromq.ZMQ::EVENT_RETRIED
EVENT_CONNECT_FAILED = org.jeromq.ZMQ::EVENT_CONNECT_FAILED
EVENT_LISTENING = org.jeromq.ZMQ::EVENT_LISTENING
EVENT_BIND_FAILED = org.jeromq.ZMQ::EVENT_BIND_FAILED
EVENT_ACCEPTED = org.jeromq.ZMQ::EVENT_ACCEPTED
EVENT_ACCEPT_FAILED = org.jeromq.ZMQ::EVENT_ACCEPT_FAILED
EVENT_CLOSED = org.jeromq.ZMQ::EVENT_CLOSED
EVENT_CLOSE_FAILED = org.jeromq.ZMQ::EVENT_CLOSE_FAILED
EVENT_DISCONNECTED = org.jeromq.ZMQ::EVENT_DISCONNECTED
EVENT_ALL = org.jeromq.ZMQ::EVENT_ALL
=end
end
3 changes: 3 additions & 0 deletions lib/jrzmq/version.rb
@@ -0,0 +1,3 @@
module ZeroMQ
VERSION = "1.0.0"
end
9 changes: 9 additions & 0 deletions spec/context_spec.rb
@@ -0,0 +1,9 @@
require 'spec_help'
require 'jrzmq/context'

describe ZeroMQ::Context do
it "instantiates a new ZeroMQ Context" do
ZeroMQ::Context.new
end
end

3 changes: 3 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,3 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'jrzmq'

0 comments on commit 6d64eb5

Please sign in to comment.