Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--require spec_helper
--order rand
--color
--format documentation
24 changes: 22 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
version: ~> 1.0

dist: focal
os: linux
virt: lxd

language: ruby
cache:
- bundler

env:
- JRUBY_OPTS="--debug"
rvm:
- 2.7.0
- jruby
- 2.7
- 2.6
- 2.5

before_install:
- yes | gem update --system --force
- bundle config set without 'development debug'

notifications:
slack:
secure: fXYggrDRoLB/4yvyW0kWwyrV5yWa/GC0btPyGu7Hx6ZOaXDC+ejiXSfx7nRyY+uZBs5UF12O4gkUXwBbnWDT5JtQRxzZd5s0cyeGQfAakALexI+FuR2jDcV1prCCaYI4IYoUt61MlfDmuCYVm8hGZ3qsgk/GPHHPnZ8a1FBd2ls=
rooms:
- secure: fXYggrDRoLB/4yvyW0kWwyrV5yWa/GC0btPyGu7Hx6ZOaXDC+ejiXSfx7nRyY+uZBs5UF12O4gkUXwBbnWDT5JtQRxzZd5s0cyeGQfAakALexI+FuR2jDcV1prCCaYI4IYoUt61MlfDmuCYVm8hGZ3qsgk/GPHHPnZ8a1FBd2ls=
- secure: Q040tRLdHrElwYAcDkIBkuDFsF7Fql/QcJT9opMfMOUKkKNNXdCts911vhROu3gbgRrfvngPvza0iDNdRETmJM5lyrFw6IQp9FkrDInHDlymwwFx62bmtk4DE56CkNfgnmpKQH0hSmIipJcHYqgkCzSCv9fxzcX5wMO9yl5/Dao=
21 changes: 12 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# Changelog

All notable changes to this project will be documented in this
file. This project adheres to [Semantic Versioning](http://semver.org/).
All notable changes to this project will be documented in this file.

As this project is pre 1.0, breaking changes may happen for minor version
bumps. A breaking change will get clearly notified in this log.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/stellar/ruby-xdr/compare/v3.0.1...master)
## [Unreleased](https://github.com/stellar/ruby-xdr/compare/v3.0.2...master)

## [3.0.1](https://github.com/stellar/ruby-xdr/compare/v3.0.0...v3.0.1)
## [3.0.2](https://github.com/stellar/ruby-xdr/compare/v3.0.1...v3.0.2) - 2020-10-20
### Changed
- Relax lower bound for ActiveSupport dependency to support usage in Rails 4.2 ((#12)[https://github.com/stellar/ruby-xdr/pull/12])

### Fixed
- Fix non-bang arm accessors for XDR::Union ((#13)[https://github.com/stellar/ruby-xdr/pull/13])
- Fix .from_xdr encoding param to accept symbols ((#14)[https://github.com/stellar/ruby-xdr/pull/14])

## [3.0.1](https://github.com/stellar/ruby-xdr/compare/v3.0.0...v3.0.1) - 2020-06-10
### Added
- Add encoding parameter to Union#to_xdr ((#7)[https://github.com/stellar/ruby-xdr/pull/7]).

### Fixed
- Padding bytes are now properly validated when reading xdr values. According to the XDR spec, padding must be zeros.

## [1.0.0](https://github.com/stellar/ruby-xdr/compare/v0.1.0...v1.0.0)

## [1.0.0](https://github.com/stellar/ruby-xdr/compare/v0.1.0...v1.0.0) - 2015-10-02
### Added
- the `to_xdr` helpers can take a second parameter that will encode the resulting output to hex or base64 when requested.
- the `from_xdr` helpers can take a second parameter that will trigger a decode from hex or base64 of the provided string before decoding from xdr.

### Changed

- `from_xdr` raises an ArgumentError when the input data is not fully consumed
12 changes: 9 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in xdr.gemspec
gemspec
gemspec development_group: :test

group :development do
gem "break"
gem "guard-rspec"
gem "pry"
gem "yard"
end
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
guard :rspec, cmd: 'bundle exec rspec' do
guard :rspec, cmd: 'bin/rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ all of it's children by calling `load_all!` on the module.

## Code generation

ruby-xdr by itself does not have any ability to parse XDR IDL files and produce a parser for your custom data types. Instead, that is the responsibility of [xdrgen](http://github.com/stellar/xdrgen). xdrgen will take your .x files and produce a set of ruby files that target this library to allow for your own custom types.
ruby-xdr by itself does not have any ability to parse XDR IDL files and produce a parser for your custom
data types. Instead, that is the responsibility of [xdrgen](http://github.com/stellar/xdrgen). `xdrgen` will
take your `.x` files and produce a set of ruby files that target this library to allow for your own custom types.

See [ruby-stellar-base](http://github.com/stellar/ruby-stellar-base) for an example (check out the generated directory)
See [ruby-stellar-base](http://github.com/astroband/ruby-stellar-sdk/tree/master/base/generated) for an example.

## Contributing

Expand Down
12 changes: 6 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
rescue LoadError
end
task default: :spec

114 changes: 114 additions & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'bundle' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "rubygems"

m = Module.new do
module_function

def invoked_as_script?
File.expand_path($0) == File.expand_path(__FILE__)
end

def env_var_version
ENV["BUNDLER_VERSION"]
end

def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1
update_index = i
end
bundler_version
end

def gemfile
gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?

File.expand_path("../../Gemfile", __FILE__)
end

def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
end

def lockfile_version
return unless File.file?(lockfile)
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Regexp.last_match(1)
end

def bundler_version
@bundler_version ||=
env_var_version || cli_arg_version ||
lockfile_version
end

def bundler_requirement
return "#{Gem::Requirement.default}.a" unless bundler_version

bundler_gem_version = Gem::Version.new(bundler_version)

requirement = bundler_gem_version.approximate_recommendation

return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")

requirement += ".a" if bundler_gem_version.prerelease?

requirement
end

def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile

activate_bundler
end

def activate_bundler
gem_error = activation_error_handling do
gem "bundler", bundler_requirement
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
end
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end

def activation_error_handling
yield
nil
rescue StandardError, LoadError => e
e
end
end

m.load_bundler!

if m.invoked_as_script?
load Gem.bin_path("bundler", "bundle")
end
10 changes: 10 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "break"

require "bundler/setup"
require "xdr"

require "pry"
Pry.start

29 changes: 29 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'rake' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("rake", "rake")
29 changes: 29 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("rspec-core", "rspec")
8 changes: 8 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
2 changes: 1 addition & 1 deletion lib/xdr/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module XDR
VERSION = "3.0.1"
VERSION = "3.0.2"
end
15 changes: 7 additions & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
require 'bundler/setup'
Bundler.setup
require 'simplecov'
SimpleCov.start
# frozen_string_literal: true

require 'pry'
require 'xdr'
require "simplecov"
SimpleCov.start do
enable_coverage :branch
end

__dir__ = File.dirname(__FILE__)
require "xdr"

Dir["#{__dir__}/support/**/*.rb"].each { |f| require f }
Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }

RSpec.configure do |config|

Expand Down
40 changes: 22 additions & 18 deletions xdr.gemspec
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'xdr/version'
# frozen_string_literals: true
require_relative "lib/xdr/version"

Gem::Specification.new do |spec|
spec.name = "xdr"
spec.version = XDR::VERSION
spec.authors = ["Scott Fleckenstein"]
spec.email = ["scott@stellar.org"]
spec.summary = %q{XDR Helper Library}
spec.summary = "XDR Helper Library"
spec.homepage = "https://github.com/stellar/ruby-xdr"
spec.license = "Apache 2.0"
spec.required_ruby_version = '>= 2.2.0'
spec.license = "Apache-2.0"

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_dependency "activesupport", ">= 5.2.0"
spec.add_dependency "activemodel", ">= 5.2.0"
spec.files = Dir["lib/**/*"]
spec.extra_rdoc_files += Dir["README*", "LICENSE*", "CHANGELOG*"]
spec.bindir = "exe"

spec.add_development_dependency "bundler", "~> 2"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.1"
spec.add_development_dependency "guard-rspec"
spec.add_development_dependency "simplecov"
spec.metadata = {
"bug_tracker_uri" => "https://github.com/stellar/ruby-xdr/issues",
"changelog_uri" => "https://github.com/stellar/ruby-xdr/blob/v#{spec.version}/CHANGELOG.md",
"documentation_uri" => "https://rubydoc.info/gems/xdr/#{spec.version}/",
"source_code_uri" => "https://github.com/stellar/ruby-xdr/tree/v#{spec.version}"
}

spec.required_ruby_version = ">= 2.4.0"

spec.add_dependency "activesupport", ">= 4.2", "< 7.0"
spec.add_dependency "activemodel", ">= 4.2", "< 7.0"

spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "simplecov", "~> 0.19"
end