Skip to content

Commit

Permalink
clean up gem/rake/rdoc/rspec infrastructure using the Jeweler library
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Palmer committed Jan 6, 2010
1 parent e0cb153 commit 0062b18
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .document
@@ -0,0 +1,3 @@
README
lib/**/*.rb
LICENSE
11 changes: 7 additions & 4 deletions .gitignore
@@ -1,8 +1,11 @@
/*.pb.rb
/*.d
/*.proto
pkg/*
prof/*
tests/*
coverage
rdoc
pkg
prof
tests
d/*
doc/*
*.gemspec
tmp
74 changes: 51 additions & 23 deletions Rakefile
@@ -1,29 +1,57 @@
require 'rubygems'
require 'rake/gempackagetask'

spec = Gem::Specification.new do |s|
s.name = "ruby-protocol-buffers"
s.version = "0.1.0"
s.author = "Brian Palmer"
s.email = "brian@mozy.com"
s.homepage = "http://todo"
s.platform = Gem::Platform::RUBY
s.summary = "Ruby compiler and runtime for the google protocol buffers library. Currently includes a compiler that utilizes protoc."

s.required_ruby_version = ">=1.8.6"

s.files = FileList["{bin,lib,ext}/**/*"].to_a
s.require_path = 'lib'
s.executables << 'ruby-protoc'
# disabled to avoid needing to compile a C extension just to boost
# performance. TODO: is there a way to tell gems to make the extension
# optional?
# s.extensions << 'ext/extconf.rb'
require 'rake'

begin
require 'metric_fu'
rescue LoadError
end

begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "ruby-protocol-buffers"
gem.summary = %Q{Ruby compiler and runtime for the google protocol buffers library.}
# gem.description = %Q{description}
gem.email = "brian@mozy.com"
gem.homepage = "http://todo/"
gem.authors = ["Brian Palmer"]
gem.version = File.read('VERSION')
gem.add_development_dependency "rspec", ">= 1.2.9"
gem.required_ruby_version = ">=1.8.6"
gem.require_path = 'lib'
# disabled to avoid needing to compile a C extension just to boost
# performance. TODO: is there a way to tell gems to make the extension
# optional?
# s.extensions << 'ext/extconf.rb'
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end

require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'
spec.pattern = 'spec/**/*_spec.rb'
end

Rake::GemPackageTask.new(spec) do |pkg|
Spec::Rake::SpecTask.new(:rcov) do |spec|
spec.libs << 'lib' << 'spec'
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end

task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
puts "generated latest version"
task :spec => :check_dependencies

task :default => :spec

require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "ruby-protocol-buffers #{version}"
rdoc.rdoc_files.include('README*', 'LICENSE')
rdoc.rdoc_files.include('lib/**/*.rb')
end
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.0.0
0.8.0
File renamed without changes.
4 changes: 4 additions & 0 deletions lib/protocol_buffers.rb
@@ -1 +1,5 @@
module ProtocolBuffers
VERSION = File.read(File.join(File.dirname(__FILE__), "..", "VERSION")).chomp
end

require 'protocol_buffers/runtime/message'
2 changes: 1 addition & 1 deletion lib/protocol_buffers/compiler/file_descriptor_to_ruby.rb
Expand Up @@ -19,7 +19,7 @@ def write(io)
#!/usr/bin/env ruby
# Generated by the protocol buffer compiler. DO NOT EDIT!
require 'protocol_buffers/runtime/message'
require 'protocol_buffers'
HEADER
descriptor.dependency.each do |dep|
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol_buffers/runtime/message.rb
Expand Up @@ -419,7 +419,7 @@ def merge_field(tag, value, field = fields[tag]) # :nodoc:
end

def self.define_field(otype, type, name, tag, opts = {}) # :NODOC:
raise("gen_methods! already called! cannot add more fields") if @methods_generated
raise("gen_methods! already called, cannot add more fields") if @methods_generated
type = type.is_a?(Module) ? type : type.to_sym
name = name.to_sym
tag = tag.to_i
Expand Down
2 changes: 1 addition & 1 deletion spec/compiler_spec.rb 100755 → 100644
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'protocol_buffers'
Expand Down
6 changes: 3 additions & 3 deletions spec/fields_spec.rb
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

require 'stringio'

Expand Down Expand Up @@ -27,9 +27,9 @@ def mkfield(ftype)
pending("do UTF-8 validation") do
s1 = mkfield(:StringField)
proc { s1.check_valid("hello") }.should_not raise_error()
proc { s1.check_valid("\xff\xff") }.should raise_error(ArgumentError)
b1 = mkfield(:BytesField)
proc { b1.valid?("\xff\xff") }.should_not raise_error()
proc { s1.valid?("\xff\xff") }.should raise_error(ArgumentError)
proc { b1.check_valid("\xff\xff") }.should_not raise_error()
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/proto_files/featureful.proto
Expand Up @@ -8,7 +8,7 @@ message A {
};

optional string payload = 1;
required Payloads payload_type = 2;
required Payloads payload_type = 2 [default = P1];

message SubSub {
optional string subsub_payload = 1;
Expand Down
2 changes: 1 addition & 1 deletion spec/runtime_spec.rb 100755 → 100644
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

require 'stringio'

Expand Down
1 change: 1 addition & 0 deletions spec/spec.opts
@@ -0,0 +1 @@
--color
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,8 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'protocol_buffers'
require 'spec'
require 'spec/autorun'

Spec::Runner.configure do |config|
end

0 comments on commit 0062b18

Please sign in to comment.