Skip to content

Commit

Permalink
Merge a797192 into 65e0a24
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsliwa committed Aug 8, 2022
2 parents 65e0a24 + a797192 commit 8c6d362
Show file tree
Hide file tree
Showing 202 changed files with 15,223 additions and 14,933 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check.yml
Expand Up @@ -21,6 +21,8 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run standardrb
run: bundle exec standardrb --config .standard.yml
- name: 'Run ${{ matrix.type }} tests on ruby ${{ matrix.ruby }} (${{ matrix.protocol }} protocol)'
env:
PARALLEL_TEST_PROCESSORS: 2
Expand Down
7 changes: 7 additions & 0 deletions .standard.yml
@@ -0,0 +1,7 @@
parallel: true
format: progress
ruby_version: 2.7

ignore:
- 'lib/submodules/**/*'
- 'vendor/**/*'
4 changes: 3 additions & 1 deletion Gemfile
@@ -1,4 +1,6 @@
source 'https://rubygems.org'
# frozen_string_literal: true

source "https://rubygems.org"

# Specify your gem's dependencies in ably.gemspec
gemspec
66 changes: 34 additions & 32 deletions Rakefile
@@ -1,62 +1,64 @@
require 'rubygems'
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'json'
# frozen_string_literal: true

require 'yard'
require "rubygems"
require "bundler/setup"
require "bundler/gem_tasks"
require "json"

require "yard"
YARD::Rake::YardocTask.new

begin
require 'rspec/core/rake_task'
require "rspec/core/rake_task"

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

task :default => :spec
task default: :spec

namespace :doc do
desc 'Generate Markdown Specification from the RSpec public API tests'
desc "Generate Markdown Specification from the RSpec public API tests"
task :spec do
ENV['PROTOCOL'] = 'json'
ENV["PROTOCOL"] = "json"

rspec_task.rspec_opts = %w(
rspec_task.rspec_opts = %w[
--require ./spec/support/markdown_spec_formatter
--order defined
--tag ~api_private
--format documentation
--format Ably::RSpec::MarkdownSpecFormatter
).join(' ')
].join(" ")

Rake::Task[:spec].invoke
end
end

desc 'Generate error code constants from ably-common: https://github.com/ably/ably-common/issues/32'
desc "Generate error code constants from ably-common: https://github.com/ably/ably-common/issues/32"
task :generate_error_codes do
errors_json_path = File.join(File.dirname(__FILE__), 'lib/submodules/ably-common/protocol/errors.json')
module_path = File.join(File.dirname(__FILE__), 'lib/ably/modules/exception_codes.rb')
errors_json_path = File.join(File.dirname(__FILE__), "lib/submodules/ably-common/protocol/errors.json")
module_path = File.join(File.dirname(__FILE__), "lib/ably/modules/exception_codes.rb")
max_length = 0

errors = JSON.parse(File.read(errors_json_path)).each_with_object({}) do |(key, val), hash|
hash[key] = val.split(/\s+/).map { |d| d.upcase.gsub(/[^a-zA-Z]+/, '') }.join('_')
end.each do |code, const_name|
errors = JSON.parse(File.read(errors_json_path)).transform_values do |val|
val.split(/\s+/).map { |d| d.upcase.gsub(/[^a-zA-Z]+/, "") }.join("_")
end.each do |_code, const_name|
max_length = [const_name.length, max_length].max
end.map do |code, const_name|
" #{const_name.ljust(max_length, ' ')} = #{code}"
" #{const_name.ljust(max_length, " ")} = #{code}"
end.join("\n")
module_content = <<-EOF
# This file is generated by running `rake :generate_error_codes`
# Do not manually modify this file
# Generated at: #{Time.now.utc}
#
module Ably
module Exceptions
module Codes
#{errors}
end
end
end
EOF
File.open(module_path, 'w') { |file| file.write module_content }
module_content = <<~MODULE_CONTENT
# This file is generated by running `rake :generate_error_codes`
# Do not manually modify this file
# Generated at: #{Time.now.utc}
#
module Ably
module Exceptions
module Codes
#{errors}
end
end
end
MODULE_CONTENT
File.write(module_path, module_content)

puts "Error code constants have been generated into #{module_path}"
puts "Warning: Search for any constants referenced in this library if their name has changed as a result of this constant generation!"
Expand Down
86 changes: 44 additions & 42 deletions ably.gemspec
@@ -1,50 +1,52 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

require "English"
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'ably/version'
require "ably/version"

Gem::Specification.new do |spec|
spec.name = 'ably'
spec.version = Ably::VERSION
spec.authors = ['Lewis Marshall', "Matthew O'Riordan"]
spec.email = ['lewis@lmars.net', 'matt@ably.io']
spec.description = %q{A Ruby client library for ably.io realtime messaging}
spec.summary = %q{A Ruby client library for ably.io realtime messaging implemented using EventMachine}
spec.homepage = 'http://github.com/ably/ably-ruby'
spec.license = 'Apache-2.0'
spec.required_ruby_version = ">= 2.7"

spec.name = "ably"
spec.version = Ably::VERSION
spec.authors = ["Lewis Marshall", "Matthew O'Riordan"]
spec.email = ["lewis@lmars.net", "matt@ably.io"]
spec.description = "A Ruby client library for ably.io realtime messaging"
spec.summary = "A Ruby client library for ably.io realtime messaging implemented using EventMachine"
spec.homepage = "http://github.com/ably/ably-ruby"
spec.license = "Apache-2.0"

spec.files = `git ls-files`.split($/)
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.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_runtime_dependency 'eventmachine', '~> 1.2.6'
spec.add_runtime_dependency 'em-http-request', '~> 1.1'
spec.add_runtime_dependency 'statesman', '~> 9.0'
spec.add_runtime_dependency 'faraday', '~> 2.2'
spec.add_runtime_dependency 'faraday-typhoeus', '~> 0.2.0'
spec.add_runtime_dependency 'typhoeus', '~> 1.4'
spec.add_runtime_dependency 'json'
spec.add_runtime_dependency 'websocket-driver', '~> 0.7'
spec.add_runtime_dependency 'msgpack', '>= 1.3.0'
spec.add_runtime_dependency 'addressable', '>= 2.0.0'
spec.add_runtime_dependency "addressable", ">= 2.0.0"
spec.add_runtime_dependency "em-http-request", "~> 1.1"
spec.add_runtime_dependency "eventmachine", "~> 1.2.6"
spec.add_runtime_dependency "faraday", "~> 2.2"
spec.add_runtime_dependency "faraday-typhoeus", "~> 0.2.0"
spec.add_runtime_dependency "json"
spec.add_runtime_dependency "msgpack", ">= 1.3.0"
spec.add_runtime_dependency "statesman", "~> 9.0"
spec.add_runtime_dependency "typhoeus", "~> 1.4"
spec.add_runtime_dependency "websocket-driver", "~> 0.7"

spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'redcarpet', '~> 3.3'
spec.add_development_dependency 'rspec', '~> 3.11.0'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.5.1'
spec.add_development_dependency 'rspec-retry', '~> 0.6'
spec.add_development_dependency 'yard', '~> 0.9'
spec.add_development_dependency 'rspec-instafail', '~> 1.0'
spec.add_development_dependency 'bundler', '>= 1.3.0'
spec.add_development_dependency 'webmock', '~> 3.11'
spec.add_development_dependency 'simplecov', '~> 0.21.2'
spec.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
spec.add_development_dependency 'parallel_tests', '~> 3.8'
spec.add_development_dependency 'pry', '~> 0.14.1'
spec.add_development_dependency 'pry-byebug', '~> 3.8.0'
spec.add_development_dependency "bundler", ">= 1.3.0"
spec.add_development_dependency "parallel_tests", "~> 3.8"
spec.add_development_dependency "pry", "~> 0.14.1"
spec.add_development_dependency "pry-byebug", "~> 3.8.0"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "redcarpet", "~> 3.3"
spec.add_development_dependency "rspec", "~> 3.11.0"
spec.add_development_dependency "rspec-instafail", "~> 1.0"
spec.add_development_dependency "rspec_junit_formatter", "~> 0.5.1"
spec.add_development_dependency "rspec-retry", "~> 0.6"
spec.add_development_dependency "standard", "~> 1.14.0"
spec.add_development_dependency "simplecov", "~> 0.21.2"
spec.add_development_dependency "simplecov-lcov", "~> 0.8.0"
spec.add_development_dependency "webmock", "~> 3.11"
spec.add_development_dependency "yard", "~> 0.9"

if RUBY_VERSION.match(/^3\./)
spec.add_development_dependency 'webrick', '~> 1.7.0'
end
spec.add_development_dependency "webrick", "~> 1.7.0" if RUBY_VERSION.match?(/^3\./)
end
20 changes: 11 additions & 9 deletions lib/ably.rb
@@ -1,16 +1,18 @@
require 'addressable/uri'
# frozen_string_literal: true

require 'ably/version'
require 'ably/agent'
require "addressable/uri"

%w(modules util).each do |namespace|
require "ably/version"
require "ably/agent"

%w[modules util].each do |namespace|
Dir.glob(File.expand_path("ably/#{namespace}/*.rb", File.dirname(__FILE__))).sort.each do |file|
require file
end
end

require 'ably/auth'
require 'ably/exceptions'
require 'ably/logger'
require 'ably/realtime'
require 'ably/rest'
require "ably/auth"
require "ably/exceptions"
require "ably/logger"
require "ably/realtime"
require "ably/rest"
2 changes: 2 additions & 0 deletions lib/ably/agent.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Ably
AGENT = "ably-ruby/#{Ably::VERSION} ruby/#{RUBY_VERSION}"
end

0 comments on commit 8c6d362

Please sign in to comment.