Refactor enough to run RSpec through jruby-gradle tooling

This commit is contained in:
R. Tyler Croy 2014-10-15 15:09:46 -07:00
parent 16bdc5300f
commit dd01a908ff
8 changed files with 66 additions and 21 deletions

View File

@ -1,34 +1,18 @@
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath group: 'com.github.jruby-gradle',
name: 'jruby-gradle-plugin',
version: '0.1.3-SNAPSHOT'
}
}
plugins {
//id "com.github.jruby-gradle.base" version "0.1.2"
id "com.github.jruby-gradle.jar" version '0.1.1'
id "com.github.jruby-gradle.jar" version "0.1.2"
id "com.github.johnrengelman.shadow" version "1.1.2"
}
apply plugin: 'java'
import com.github.jrubygradle.JRubyExec
// There appear to be issues with 1.7.16:
// <https://gist.github.com/rtyler/dd1f1df58d4712a9e63d>
project.jruby.execVersion = '1.7.15'
dependencies {
compile group: 'org.jruby', name: 'jruby-complete', version: '1.7.15'
gems group: 'rubygems', name: 'protobuf', version: '3.0.+'
gems group: 'rubygems', name: 'concurrent-ruby', version: '0.7.+'
jrubyExec group: 'rubygems', name: 'rspec', version: '3.1.+'
jrubyExec group: 'rubygems', name: 'rspec-its', version: '1.+'
jrubyExec group: 'rubygems', name: 'pry', version: '0.10.+'
}
configurations {
@ -67,4 +51,15 @@ task spec(type: JRubyExec) {
scriptArgs '--color', '--order', 'random'
}
// XXX: Currently this does not work properly because stdin is not being
// delegated properly
task console(type: JRubyExec) {
group 'JRuby'
description 'Execute a Pry-based console in JRuby'
jrubyArgs '-S', 'pry'
scriptArgs '-I', './lib'
standardInput System.in
standardOutput System.out
}
// vim: ft=groovy

View File

@ -1,6 +1,11 @@
require 'singleton'
require 'blick/transport'
module Blick
class Emitter
include Singleton
# Emit is a instance-wide helper method for emitting protobuf messages
# "upstream" for whatever "upstream" means for this particualr instance of
# Blick.
@ -9,8 +14,15 @@ module Blick
# emitted
# @return [Boolean[ success of the emit operation
def self.emit(protobuf)
puts "Emitting #{protobuf.inspect}"
return true
return self.instance.emit(protobuf)
end
def initialize(*args)
@transport = Blick::Transport::Stdout.new
end
def emit(protobuf)
@transport.emit(protobuf)
end
end
end

View File

@ -2,3 +2,8 @@ module Blick
module Transport
end
end
Dir["#{File.expand_path(File.dirname(__FILE__))}/transport/**/*.rb"].each do |f|
require f
end

View File

@ -0,0 +1,13 @@
require 'blick/transport/base'
module Blick
module Transport
class Noop < Base
TITLE = 'No-op'.freeze
def title
return TITLE
end
end
end
end

View File

@ -3,6 +3,17 @@ require 'blick/transport/base'
module Blick
module Transport
class Stdout < Base
TITLE = 'Standard Out'.freeze
def title
return TITLE
end
def emit(message)
puts "Emitting #{message.inspect}"
STDOUT.flush
return true
end
end
end
end

View File

@ -1,4 +1,5 @@
require 'rspec'
require 'rspec/its'
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))

View File

@ -0,0 +1,6 @@
require 'spec_helper'
require 'blick/transport/noop'
describe Blick::Transport::Noop do
it_behaves_like 'a transport class'
end

View File

@ -3,4 +3,6 @@ require 'blick/transport/stdout'
describe Blick::Transport::Stdout do
it_behaves_like 'a transport class'
its(:title) { should eql 'Standard Out' }
end