Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubocop #7

Merged
merged 4 commits into from
Aug 31, 2020
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
11 changes: 11 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
AllCops:
TargetRubyVersion: 1.9
Exclude:
- 'aws-crt/native/aws-common-runtime/**/*.rb'

Style/HashSyntax:
Exclude:
- 'aws-crt/Rakefile'

Metrics/LineLength:
Max: 80
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ group :test do
gem 'rspec'
end

group :development do
gem 'rubocop', '0.50.0', require: false # latest version to support Ruby 1.9
end

11 changes: 7 additions & 4 deletions aws-crt/Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'rake/clean'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

CLEAN.include 'tmp'
CLEAN.include 'pkg'
Expand All @@ -12,9 +13,7 @@ task :compile do
build_dir = File.expand_path('build', native_dir)
FileUtils.mkdir_p(build_dir)
Dir.chdir(build_dir) do
if !File.exist?('CMakeCache.txt')
sh "cmake #{native_dir}"
end
sh "cmake #{native_dir}" unless File.exist?('CMakeCache.txt')
sh "cmake --build #{build_dir}"
end
end
Expand Down Expand Up @@ -90,7 +89,7 @@ task 'gem:jruby' => 'bin:all' do
require 'fileutils'

platform = 'universal-java'

root = File.dirname(__FILE__)
pkgs = File.join(root, 'pkg')
bins = File.join(root, 'bin')
Expand Down Expand Up @@ -118,3 +117,7 @@ end
RSpec::Core::RakeTask.new(:spec)
task :spec => :bin

RuboCop::RakeTask.new(:rubocop) do |t|
config_file = File.join(File.dirname(__FILE__), '..', '.rubocop.yml')
t.options = ['-E', '-S', '-c', config_file]
end
4 changes: 2 additions & 2 deletions aws-crt/aws-crt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Gem::Specification.new do |spec|
spec.files += Dir['lib/**/*.rb']
spec.platform = Gem::Platform::RUBY
spec.add_dependency 'ffi'
spec.add_development_dependency "rspec"
end
spec.add_development_dependency 'rspec'
end
6 changes: 3 additions & 3 deletions aws-crt/ext/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'mkmf'

abort 'Missing cmake' unless find_executable 'cmake'

# create a dummy makefile
create_makefile ''

Expand All @@ -9,9 +11,7 @@
Dir.chdir('../') do
native_dir = File.expand_path('./native')
build_dir = File.expand_path('build', native_dir)
if !Dir.exist?(build_dir)
Dir.mkdir(build_dir)
end
Dir.mkdir(build_dir) unless Dir.exist?(build_dir)
Dir.chdir(build_dir) do
system "cmake #{native_dir}"
system "cmake --build #{build_dir}"
Expand Down
9 changes: 4 additions & 5 deletions aws-crt/lib/aws-crt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ class Error < StandardError
end

module Errors

@const_set_mutex = Mutex.new

def self.raise_last_error
error_code = Aws::Crt::aws_last_error
error_name = Aws::Crt::aws_error_name(error_code)
raise error_class(error_name), Aws::Crt::aws_error_debug_str(error_code)
error_code = Aws::Crt.aws_last_error
error_name = Aws::Crt.aws_error_name(error_code)
raise error_class(error_name), Aws::Crt.aws_error_debug_str(error_code)
end

# Get the error class for a given error_name
Expand All @@ -65,7 +64,7 @@ def self.error_class(error_name)
# This requires filtering non-safe characters from the constant
# name and ensuring it begins with an uppercase letter.
def self.error_class_constant(error_name)
constant = error_name.to_s.gsub(/AWS_ERROR_/, '').split('_').map{|e| e.capitalize}.join
constant = error_name.to_s.gsub(/AWS_ERROR_/, '').split('_').map(&:capitalize).join
end

def self.set_error_constant(constant)
Expand Down
20 changes: 10 additions & 10 deletions aws-crt/lib/aws-crt/platforms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ def host_string

# @return [String] host cpu, even on jruby
def host_cpu
case RbConfig::CONFIG["host_cpu"]
case RbConfig::CONFIG['host_cpu']
when /86_64/
"x86_64"
'x86_64'
when /86/
"x86"
'x86'
else
RbConfig::CONFIG["host_cpu"]
RbConfig::CONFIG['host_cpu']
end
end

# @return [String] host os, even on jruby
def host_os
case RbConfig::CONFIG["host_os"]
case RbConfig::CONFIG['host_os']
when /darwin/
"darwin"
'darwin'
when /linux/
"linux"
'linux'
when /mingw|mswin/
"mingw32"
'mingw32'
else
RbConfig::CONFIG["host_os"]
RbConfig::CONFIG['host_os']
end
end
end
2 changes: 1 addition & 1 deletion aws-crt/native/aws-common-runtime/aws-c-common
Submodule aws-c-common updated 800 files
2 changes: 1 addition & 1 deletion aws-crt/spec/crt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
end.to raise_error(Aws::Crt::Error)
end
end
end
end