Commit 2bdb632b authored by Tony Arcieri's avatar Tony Arcieri Committed by GitHub

Merge pull request #23 from crypto-rb/rubocop

Add RuboCop
parents 5c254595 fb8bfb6f
AllCops:
TargetRubyVersion: 2.2
DisplayCopNames: true
#
# Layout
#
Layout/IndentHeredoc:
Enabled: false
#
# Metrics
#
Metrics/AbcSize:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Metrics/BlockLength:
Max: 100
Metrics/ClassLength:
Max: 100
Metrics/LineLength:
Max: 128
Metrics/MethodLength:
Max: 25
#
# Style
#
Style/FrozenStringLiteralComment:
Enabled: true
Style/StringLiterals:
EnforcedStyle: double_quotes
......@@ -8,5 +8,6 @@ group :development, :test do
gem "rake", ">= 10"
gem "rake-compiler", "~> 1.0"
gem "rake-compiler-dock", "~> 0.6"
gem "rspec", "~> 3"
gem "rspec", "~> 3.7"
gem "rubocop", "0.52.1"
end
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'rake/extensiontask'
require "rake/extensiontask"
RSpec::Core::RakeTask.new
task default: :spec
require "rubocop/rake_task"
RuboCop::RakeTask.new
MAKE = ENV['MAKE'] || ENV['make'] || "make"
RUBY_CC_VERSION = ENV['RUBY_CC_VERSION'] || '2.3.0'
task default: %w[spec rubocop]
MAKE = ENV["MAKE"] || ENV["make"] || "make"
RUBY_CC_VERSION = ENV["RUBY_CC_VERSION"] || "2.3.0"
desc "Build Windows binary packages"
task 'gem:windows' do
require 'rake_compiler_dock'
if File.exist? "vendor/libsodium/Makefile"
RakeCompilerDock.sh "cd vendor/libsodium && #{MAKE} clean"
end
sh "bundle package" # Avoid repeated downloads of gems by using gem files from the host.
task "gem:windows" do
require "rake_compiler_dock"
RakeCompilerDock.sh "cd vendor/libsodium && #{MAKE} clean" if File.exist? "vendor/libsodium/Makefile"
sh "bundle package" # Avoid repeated downloads of gems by using gem files from the host.
RakeCompilerDock.sh "bundle --local && RUBY_CC_VERSION=#{RUBY_CC_VERSION} rake cross native gem"
end
spec = Gem::Specification.load("rbnacl-libsodium.gemspec")
PLATFORMS = ['x86-mingw32', 'x64-mingw32']
PLATFORMS = ["x86-mingw32", "x64-mingw32"].freeze
Rake::ExtensionTask.new("fake_ext", spec) do |ext|
ext.ext_dir = 'ext/rbnacl'
ext.ext_dir = "ext/rbnacl"
ext.cross_compile = true
ext.cross_platform = PLATFORMS
ext.cross_config_options << {
'x86-mingw32' => '--with-host=i686-w64-mingw32',
'x64-mingw32' => '--with-host=x86_64-w64-mingw32'
"x86-mingw32" => "--with-host=i686-w64-mingw32",
"x64-mingw32" => "--with-host=x86_64-w64-mingw32"
}
ext.cross_compiling do |gem_spec|
gem_spec.files.reject! { |f| /lib\/fake_ext\.so\Z/ =~ f }
gem_spec.files.reject! { |f| %r{lib\/fake_ext\.so\Z} =~ f }
stage_path = "#{ext.tmp_dir}/#{gem_spec.platform}/stage"
gem_spec.files += Dir["#{stage_path}/vendor/libsodium/dist/**/*"].map do |stage|
gem_path = stage.sub(stage_path + "/", "")
......@@ -46,7 +47,5 @@ end
PLATFORMS.each do |platf|
copy_task = "copy:fake_ext:#{platf}:#{RUBY_CC_VERSION}"
if Rake::Task.task_defined?(copy_task)
Rake::Task[copy_task].clear_actions
end
Rake::Task[copy_task].clear_actions if Rake::Task.task_defined?(copy_task)
end
require 'mkmf'
# frozen_string_literal: true
require "mkmf"
def sys(cmd)
puts " -- #{cmd}"
unless ret = system(cmd)
raise "ERROR: '#{cmd}' failed"
end
ret = system(cmd)
raise "ERROR: '#{cmd}' failed" unless ret
ret
end
......@@ -17,20 +18,18 @@ clean:
MAKEFILE
HOST = arg_config("--host")
OPTIONS = []
if HOST
OPTIONS << "--host=#{HOST}"
end
OPTIONS = [].freeze
OPTIONS << "--host=#{HOST}" if HOST
CWD = File.expand_path(File.dirname(__FILE__))
LIBSODIUM_DIR = File.expand_path(File.join(CWD, '..', '..', 'vendor', 'libsodium'))
MAKE = ENV['MAKE'] || ENV['make'] || "make"
if HOST
# install to the stage directory for rake-compiler
DIST = File.expand_path(File.join(CWD, '..', '..', 'tmp', RUBY_PLATFORM, 'stage', 'vendor', 'libsodium', 'dist'))
else
DIST = "#{LIBSODIUM_DIR}/dist"
end
CWD = __dir__
LIBSODIUM_DIR = File.expand_path(File.join(CWD, "..", "..", "vendor", "libsodium"))
MAKE = ENV["MAKE"] || ENV["make"] || "make"
DIST = if HOST
# install to the stage directory for rake-compiler
File.expand_path(File.join(CWD, "..", "..", "tmp", RUBY_PLATFORM, "stage", "vendor", "libsodium", "dist"))
else
"#{LIBSODIUM_DIR}/dist".freeze
end
Dir.chdir(LIBSODIUM_DIR) do
# sh is required to run configure on Windows
......
require 'rbnacl/libsodium/version'
require "rbnacl/libsodium/version"
module RbNaCl
# Installer for the libsodium native library
module Libsodium
class << self
def sodiumlib_dir
sodiumlib32_dir = File.expand_path('../../../vendor/libsodium/dist/lib/', __FILE__)
sodiumlib64_dir = File.expand_path('../../../vendor/libsodium/dist/lib64/', __FILE__)
sodiumlib32_dir = File.expand_path("../../../vendor/libsodium/dist/lib/", __FILE__)
sodiumlib64_dir = File.expand_path("../../../vendor/libsodium/dist/lib64/", __FILE__)
[sodiumlib32_dir, sodiumlib64_dir].select { |dir| Dir.exist?(dir) }.first
end
def sodiumlib_glob
case RUBY_DESCRIPTION
when /darwin/ then 'libsodium*.dylib'
when /Windows|(win|mingw)32/ then '../bin/libsodium*.dll'
when /openbsd/ then 'libsodium*.so.*'
else 'libsodium*.so'
when /darwin/ then "libsodium*.dylib"
when /Windows|(win|mingw)32/ then "../bin/libsodium*.dll"
when /openbsd/ then "libsodium*.so.*"
else "libsodium*.so"
end
end
end
......@@ -23,4 +24,4 @@ module RbNaCl
end
end
require 'rbnacl'
require "rbnacl"
# frozen_string_literal: true
module RbNaCl
module Libsodium
VERSION = '1.0.16'
VERSION = "1.0.16".freeze
end
end
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rbnacl/libsodium/version'
require "rbnacl/libsodium/version"
Gem::Specification.new do |spec|
spec.name = "rbnacl-libsodium"
spec.version = RbNaCl::Libsodium::VERSION
spec.authors = ["Artiom Di", "Tony Arcieri"]
spec.date = Time.now.strftime('%Y-%m-%d')
spec.email = ["kron82@gmail.com", "bascule@gmail.com"]
spec.summary = %q{rbnacl with bundled libsodium}
spec.homepage = "https://github.com/crypto-rb/rbnacl-libsodium"
spec.summary = "rbnacl with bundled libsodium"
spec.homepage = "https://github.com/cryptosphere/rbnacl-libsodium"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
spec.files += Dir.glob("vendor/libsodium/**/*")
spec.files = `git ls-files -z`.split("\x0") + Dir.glob("vendor/libsodium/**/*")
spec.require_paths = ["lib"]
spec.extensions = ["ext/rbnacl/extconf.rb"]
spec.extensions = ['ext/rbnacl/extconf.rb']
spec.required_ruby_version = ">= 2.2.6"
spec.add_runtime_dependency "rbnacl", ">= 5.0.0"
spec.required_ruby_version = '>= 2.2.6'
spec.add_development_dependency "bundler", "~> 1.16"
end
# frozen_string_literal: true
RSpec.describe RbNaCl::Libsodium do
it "has a version number" do
expect(RbNaCl::Libsodium::VERSION).to be_a(String)
end
end
# frozen_string_literal: true
require "bundler/setup"
require "rbnacl/libsodium"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment