Skip to content

Commit

Permalink
empathy and bundler
Browse files Browse the repository at this point in the history
Using bundler config for all gem related stuff instead of hoe.

Replace strand with new empathy implementation for using zkruby with
eventmachine
  • Loading branch information
lwoggardner committed Jul 27, 2013
1 parent 98ff620 commit 3fd75da
Show file tree
Hide file tree
Showing 31 changed files with 988 additions and 1,021 deletions.
10 changes: 5 additions & 5 deletions .gitignore
@@ -1,11 +1,11 @@
#No hidden files (except for .gitignore)
.*
!.gitignore
!.yardopts
# Gems should not checking Gemfile.lock
Gemfile.lock
#Files generated by rake
*.gemspec
zk.out
zookeeper.out
lib/jute/
*.out
doc
pkg
#Jedit stupid default backup settings
*'`'
2 changes: 2 additions & 0 deletions .yardopts
@@ -0,0 +1,2 @@
-
History.txt
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in rfuse.gemspec
gemspec
39 changes: 0 additions & 39 deletions Manifest.txt

This file was deleted.

27 changes: 15 additions & 12 deletions README.rdoc
@@ -1,6 +1,6 @@
= zkruby

* https://github.com/lwoggardner/zkruby
* http://rubygems.org/gems/zkruby

== DESCRIPTION:

Expand All @@ -10,6 +10,9 @@ Pure ruby client for ZooKeeper (http://zookeeper.apache.org)

Supports full ZooKeeper API, synchronous or asynchronous style, watches etc.. with implementations over EventMachine or plain old Ruby IO/Threads

Other ruby libraries for zookeeper tend to use the underlying C/Java client libraries while zkruby
implements the zookeeper wire protocol directly.

Advantages:
* Rubyist API - with block is asynchronous, without block is synchronous
* Avoids conflicts between various Ruby threading models and the C/Java apis
Expand All @@ -18,9 +21,9 @@ Advantages:

Disadvantages:
* Duplicated code from Java/C libraries, particularly around herd effect protection
* Maintain in parallel with breaking changes in protocol which are possibly more likely
than breaking changes in the client API
* Probably not as optimised in terms of performance (but your client code is ruby anyway)
* Needs to keep up with changes in wire protocol which are possibly more likely
than changes in the client API
* Possibly not as optimised in terms of performance (but your client code is ruby anyway)
* Not production tested (yet- do you want to be the first?)

== SYNOPSIS:
Expand Down Expand Up @@ -77,27 +80,27 @@ Disadvantages:

== DEVELOPERS:

Checkout the zookeeper source from http://zookeeper.apache.org
Download ZooKeeper from http://zookeeper.apache.org

Checkout the zkruby source into the contrib directory
Create a conf/zoo.cfg file (copying sample.zoo.cfg is fine)

Install hoe
Checkout the zkruby source into the contrib directory

$ (sudo) gem install hoe
Copy (if different) src/zookeeper.jute to contrib/zkruby/src/zookeeper.jute

Install other dependencies
Get gem dependencies

$ rake check_extra_deps
$ bundle install

Generate docs and run the tests/specs

$ rake newb
$ rake

== LICENSE:

(The MIT License)

Copyright (c) 2011
Copyright (c) 2012 Grant Gardner

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
57 changes: 26 additions & 31 deletions Rakefile
@@ -1,39 +1,34 @@
# -*- ruby -*-
# hoe 2.12.5 goes looking for the plugins so we have to do it this way..
$LOAD_PATH.unshift File.dirname(__FILE__) + '/jute/lib'
#!/usr/bin/env rake
$:.unshift "jute/lib"

require 'rubygems'
require 'hoe'
require 'rake/clean'
require 'yard'
require './yard_ext/enum_handler.rb'
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
require 'jute/task'

begin
require './yard_ext/enum_handler'
rescue LoadError => err
warn "%p while trying to load yard extensions: %s" % [ err.class, err.message ]
RSpec::Core::RakeTask.new
RSpec::Core::RakeTask.new(:perf_spec) do |t|
t.rspec_opts = "--tag perf"
end


YARD::Rake::YardocTask.new

# Hoe.plugin :compiler
#Hoe.plugin :gem_prelude_sucks
Hoe.plugin :git
# Hoe.plugin :inline
# Hoe.plugin :racc
# Hoe.plugin :rubyforge
Hoe.plugin :yard
Hoe.plugin :jute

Hoe.spec 'zkruby' do
self.readme_file="README.rdoc"
developer('Grant Gardner', 'grant@lastweekend.com.au')
dependency 'slf4r' , '~> 0.4.2'
dependency 'eventmachine', '~> 0.12.10', :development
dependency 'strand', '~> 0.1.0', :development
dependency 'logging', '>= 1.4.1', :development
dependency 'rspec', '>=2.7.0', :development
dependency 'hoe-yard', '>=0.1.2', :development

self.jute_modules = {
Jute::Task.new() do |t|
t.modules = {
"org.apache.zookeeper.data" => "ZooKeeper::Data",
"org.apache.zookeeper.proto" => "ZooKeeper::Proto"}
end
# vim: syntax=ruby

task :perf_spec => :jute
task :spec => :jute
task :build => :jute
task :install => :jute
task :release => :jute
task :yard => :jute

task :default => [:spec,:yard]

CLEAN.include "*.out","Gemfile.lock",".yardoc/"
CLOBBER.include "doc/","pkg/","lib/jute"
56 changes: 0 additions & 56 deletions jute/lib/hoe/jute.rb

This file was deleted.

62 changes: 62 additions & 0 deletions jute/lib/jute/task.rb
@@ -0,0 +1,62 @@
# coding: utf-8
require 'rake/tasklib'
require 'jute'

class Jute::Task < Rake::TaskLib

attr_accessor :modules
attr_accessor :files
attr_accessor :pathmap

def initialize name = :jute

defaults

@name = name

yield self if block_given?

define_jute_tasks
end

def defaults
@files = "src/jute/*.jute"
@pathmap = "%{src,lib}X.rb"
end

def define_jute_tasks
desc "Compile jute files to ruby classes"
task jute_task_name

raise "modules hash must be defined" unless Hash === @modules
FileList.new(@files).each do | source |
target = source.pathmap(@pathmap)

target_dir = target.pathmap("%d")
directory target_dir

file target => [source,target_dir] do
compile_jute(source,target)
end
task jute_task_name => target
end
end

def jute_task_name
@name
end

def compile_jute(source,target)

@jute_compiler = ::Jute::Compiler.new() unless @jute_compiler

File.open(source) do |input|
File.open(target,"w") do |output|
puts "Compiling #{input.inspect} to #{output.inspect}"
@jute_compiler.compile(input,output,modules)
end
end
end
end


6 changes: 4 additions & 2 deletions lib/em_zkruby.rb
@@ -1,4 +1,6 @@
# This is the main require for standard ruby io/thread based binding

# This is the main require for the eventmachine based binding
# Only use this if all use of zkruby will be within the EM Reactor
require 'zkruby/zkruby'
require 'zkruby/eventmachine'

Empathy::EM.empathise(ZooKeeper)
2 changes: 0 additions & 2 deletions lib/jute/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion lib/zkruby.rb
@@ -1,4 +1,3 @@
# This is the main require for standard ruby io/thread based binding

require 'zkruby/zkruby'
require 'zkruby/rubyio'

0 comments on commit 3fd75da

Please sign in to comment.