Skip to content

Commit

Permalink
Merge c0f51b0 into 65e0a24
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsliwa committed Jul 19, 2022
2 parents 65e0a24 + c0f51b0 commit 33d88f9
Show file tree
Hide file tree
Showing 202 changed files with 9,176 additions and 8,841 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 rubocop
run: bundle exec rubocop --config .rubocop.yml --parallel
- name: 'Run ${{ matrix.type }} tests on ruby ${{ matrix.ruby }} (${{ matrix.protocol }} protocol)'
env:
PARALLEL_TEST_PROCESSORS: 2
Expand Down
47 changes: 47 additions & 0 deletions .rubocop.yml
@@ -0,0 +1,47 @@
AllCops:
TargetRubyVersion: 2.7
Exclude:
- 'lib/submodules/**/*'
- 'vendor/**/*'
SuggestExtensions: false
NewCops: disable
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Layout/LineLength:
Enabled: false
Naming/VariableNumber:
Enabled: false
Lint/ConstantDefinitionInBlock:
Enabled: false
Metrics/MethodLength:
Enabled: false
Style/MultilineBlockChain:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Lint/HashCompareByIdentity:
Enabled: false
Style/Alias:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Naming/PredicateName:
Enabled: false
Naming/AccessorMethodName:
Enabled: false
Lint/UselessMethodDefinition:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Naming/MethodName:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Gemspec/RubyVersionGlobalsUsage:
Enabled: false
Style/SymbolProc:
Enabled: false
2 changes: 2 additions & 0 deletions Gemfile
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in ably.gemspec
Expand Down
42 changes: 22 additions & 20 deletions Rakefile
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rubygems'
require 'bundler/setup'
require 'bundler/gem_tasks'
Expand All @@ -11,20 +13,20 @@ begin

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'
task :spec do
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
Expand All @@ -36,30 +38,30 @@ begin
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}"
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
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.open(module_path, 'w') { |file| file.write 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!"
puts 'Warning: Search for any constants referenced in this library if their name has changed as a result of this constant generation!'
end
rescue LoadError
# RSpec not available
Expand Down
43 changes: 23 additions & 20 deletions ably.gemspec
@@ -1,50 +1,53 @@
# 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'

Gem::Specification.new do |spec|
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 = %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.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.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
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_runtime_dependency 'eventmachine', '~> 1.2.6'
spec.add_runtime_dependency 'addressable', '>= 2.0.0'
spec.add_runtime_dependency 'em-http-request', '~> 1.1'
spec.add_runtime_dependency 'statesman', '~> 9.0'
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 '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 'statesman', '~> 9.0'
spec.add_runtime_dependency 'typhoeus', '~> 1.4'
spec.add_runtime_dependency 'websocket-driver', '~> 0.7'

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 '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 'rubocop', '~> 1.31'
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 '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
4 changes: 3 additions & 1 deletion lib/ably.rb
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require 'addressable/uri'

require 'ably/version'
require 'ably/agent'

%w(modules util).each do |namespace|
%w[modules util].each do |namespace|
Dir.glob(File.expand_path("ably/#{namespace}/*.rb", File.dirname(__FILE__))).sort.each do |file|
require file
end
Expand Down
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 33d88f9

Please sign in to comment.