Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Rename messages to cucumber-messaged
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Sep 15, 2018
0 parents commit e4a77f6
Show file tree
Hide file tree
Showing 20 changed files with 786 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PLEASE DO NOT CREATE ISSUES IN THIS REPO.
THIS REPO IS A READ-ONLY MIRROR.

Create your issue in the Cucumber monorepo instead:
https://github.com/cucumber/cucumber/issues
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PLEASE DO NOT CREATE PULL REAUESTS IN THIS REPO.
THIS REPO IS A READ-ONLY MIRROR.

Create your pull request in the Cucumber monorepo instead:
https://github.com/cucumber/cucumber/pulls
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage/
Gemfile.lock
pkg/
.tested
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
4 changes: 4 additions & 0 deletions .rsync
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
../../LICENSE LICENSE
../../.templates/github/ .github/
../../.templates/ruby/ .
../messages.proto messages.proto
1 change: 1 addition & 0 deletions .subrepo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cucumber/cucumber-messages-ruby
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sudo: false
language: ruby

rvm:
- "2.5.1"
- "2.4.4"
- "2.3.7"
- "2.2.10"
- "jruby-9.1.17.0"

script: make default

matrix:
allow_failures:
- rvm: "jruby-9.1.17.0"
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Cucumber Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include default.mk

.deps: lib/cucumber/messages_pb.rb

lib/cucumber/messages_pb.rb: messages.proto
protoc --ruby_out lib/cucumber $<

clean:
rm -f lib/cucumber/messages_pb.rb
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Cucumber Messages for Ruby (Protocol Buffers)

[![Build Status](https://travis-ci.org/cucumber/cucumber-messages-ruby.svg?branch=master)](https://travis-ci.org/cucumber/cucumber-messages-ruby)
23 changes: 23 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# encoding: utf-8
require 'rubygems'
require 'bundler'
Bundler::GemHelper.install_tasks

$:.unshift File.expand_path("../lib", __FILE__)

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec) do |t|
t.ruby_opts = %w[-r./spec/coverage -w]
end

require_relative 'spec/capture_warnings'
include CaptureWarnings
namespace :spec do
task :warnings do
report_warnings do
Rake::Task['spec'].invoke
end
end
end

task default: ['spec:warnings']
34 changes: 34 additions & 0 deletions cucumber-messages.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'cucumber-messages'
s.version = '1.0.0'
s.authors = ["Aslak Hellesøy"]
s.description = "Protocol Buffer messages for Cucumber's inter-process communication"
s.summary = "cucumber-messages-#{s.version}"
s.email = 'cukes@googlegroups.com'
s.homepage = "https://github.com/cucumber/cucumber-messages-ruby#readme"
s.platform = Gem::Platform::RUBY
s.license = "MIT"
s.required_ruby_version = ">= 1.9.3"

# As of this writing (28 June 2018), the latest version is
# 3.6.0, which doesn't works with JRuby.
# See https://github.com/google/protobuf/issues/1594
# 3.1.0 works with JRuby, but fails with MRI 2.4.4 and above.
# There doesn't seem to be a version that works with all rubies,
# so we're picking the version that works with the most recent MRIs.
s.add_dependency 'google-protobuf', '3.6.1'

s.add_development_dependency 'bundler'
s.add_development_dependency 'rake', '~> 12.3'
s.add_development_dependency 'rspec', '~> 3.7'

# For coverage reports
s.add_development_dependency 'coveralls'

s.rubygems_version = ">= 1.6.1"
s.files = `git ls-files`.split("\n").reject {|path| path =~ /\.gitignore$/ }
s.test_files = `git ls-files -- spec/*`.split("\n")
s.rdoc_options = ["--charset=UTF-8"]
s.require_path = "lib"
end
33 changes: 33 additions & 0 deletions default.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
SHELL := /usr/bin/env bash
RUBY_SOURCE_FILES = $(shell find . -name "*.rb")
GEMSPECS = $(shell find . -name "*.gemspec")

ifdef TRAVIS_BRANCH
LIBRARY_VERSION=$(TRAVIS_BRANCH)
endif
ifdef TRAVIS_TAG
LIBRARY_VERSION=$(TRAVIS_TAG)
endif
ifndef LIBRARY_VERSION
LIBRARY_VERSION=$(shell git rev-parse --abbrev-ref HEAD)
endif

default: .tested
.PHONY: default

.deps: Gemfile.lock

Gemfile.lock: Gemfile $(GEMSPECS)
bundle install
touch $@

.tested: .deps $(RUBY_SOURCE_FILES)
bundle exec rspec --color
touch $@

clean: clean-ruby
.PHONY: clean

clean-ruby:
rm -f .deps .linked .tested Gemfile.lock
.PHONY: clean-ruby
36 changes: 36 additions & 0 deletions lib/cucumber/messages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'cucumber/messages_pb'

module Cucumber
module Messages
module Varint
def decode_varint(io)
# https://github.com/ruby-protobuf/protobuf/blob/master/lib/protobuf/varint_pure.rb
value = index = 0
begin
byte = io.readbyte
value |= (byte & 0x7f) << (7 * index)
index += 1
end while (byte & 0x80).nonzero?
value
end

# https://www.rubydoc.info/gems/ruby-protocol-buffers/1.2.2/ProtocolBuffers%2FVarint.encode
def encode_varint(io, int_val)
if int_val < 0
# negative varints are always encoded with the full 10 bytes
int_val = int_val & 0xffffffff_ffffffff
end
loop do
byte = int_val & 0x7f
int_val >>= 7
if int_val == 0
io << byte.chr
break
else
io << (byte | 0x80).chr
end
end
end
end
end
end
Loading

0 comments on commit e4a77f6

Please sign in to comment.