diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..77dd162 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,48 @@ +# Ruby CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-ruby/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/ruby:2.4.1-node-browsers + + working_directory: ~/repo + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "Gemfile.lock" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: + name: install dependencies + command: | + bundle install --jobs=4 --retry=3 --path vendor/bundle + - save_cache: + paths: + - ./vendor/bundle + key: v1-dependencies-{{ checksum "Gemfile.lock" }} + + # run tests! + - run: + name: run tests + command: | + mkdir /tmp/test-results + TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)" + bundle exec rspec --format progress \ + --out /tmp/test-results/rspec.xml \ + --format progress \ + $TEST_FILES + # collect reports + - store_test_results: + path: /tmp/test-results + - store_artifacts: + path: /tmp/test-results + destination: test-results diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 08783da..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -sudo: false -language: ruby -cache: bundler -rvm: - - 2.5.5 -before_install: gem install bundler -v 2.0.1 diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..2985d1a --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,35 @@ +PATH + remote: . + specs: + simple-redis-lock (0.1.0) + +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.3) + rake (10.5.0) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.0) + rspec-support (~> 3.9.0) + rspec-expectations (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.0) + +PLATFORMS + ruby + +DEPENDENCIES + bundler (~> 2.0) + rake (~> 10.0) + rspec (~> 3.0) + simple-redis-lock! + +BUNDLED WITH + 2.0.1 diff --git a/lib/simple_redis_lock/redis_lock.rb b/lib/simple_redis_lock/redis_lock.rb index 45e3ca7..133358e 100644 --- a/lib/simple_redis_lock/redis_lock.rb +++ b/lib/simple_redis_lock/redis_lock.rb @@ -5,7 +5,7 @@ module SimpleRedisLock class RedisLock DEFAULT_RETRY_COUNT = 25 - DEFAULT_TTL = 5.seconds + # DEFAULT_TTL = 5.seconds # TODO: add active support? UNLOCK_SCRIPT = <<~LUA if redis.call("get",KEYS[1]) == ARGV[1] then return redis.call("del",KEYS[1]) diff --git a/lib/simple_redis_lock/version.rb b/lib/simple_redis_lock/version.rb new file mode 100644 index 0000000..6f87267 --- /dev/null +++ b/lib/simple_redis_lock/version.rb @@ -0,0 +1,3 @@ +module SimpleRedisLock + VERSION = '0.1.0'.freeze +end diff --git a/simple-redis-lock.gemspec b/simple-redis-lock.gemspec index 6e2d33c..95f8a47 100644 --- a/simple-redis-lock.gemspec +++ b/simple-redis-lock.gemspec @@ -1,42 +1,23 @@ -lib = File.expand_path("../lib", __FILE__) +lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "simple/redis/lock/version" +require 'simple_redis_lock/version' Gem::Specification.new do |spec| - spec.name = "simple-redis-lock" - spec.version = Simple::Redis::Lock::VERSION - spec.authors = ["MaicolBen"] - spec.email = ["maicol.bentancor@gmail.com"] + spec.name = 'simple-redis-lock' + spec.version = SimpleRedisLock::VERSION + spec.authors = ['Hint'] + spec.email = ['maicol.bentancor@gmail.com'] - spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.} - spec.description = %q{TODO: Write a longer description or delete this line.} - spec.homepage = "TODO: Put your gem's website or public repo URL here." - spec.license = "MIT" + spec.summary = 'Simple redis lock' + spec.license = 'MIT' - # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' - # to allow pushing to a single host or delete this section to allow pushing to any host. - if spec.respond_to?(:metadata) - spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" - - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." - spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." - else - raise "RubyGems 2.0 or newer is required to protect against " \ - "public gem pushes." - end - - # Specify which files should be added to the gem when it is released. - # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - end - spec.bindir = "exe" + spec.files = Dir['lib/**/*.rb'] + spec.bindir = 'exe' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.add_development_dependency "bundler", "~> 2.0" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency 'bundler', '~> 2.0' + spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'rspec', '~> 3.0' end diff --git a/spec/simple/redis/lock_spec.rb b/spec/simple/redis/lock_spec.rb deleted file mode 100644 index 4043e03..0000000 --- a/spec/simple/redis/lock_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -RSpec.describe Simple::Redis::Lock do - it "has a version number" do - expect(Simple::Redis::Lock::VERSION).not_to be nil - end - - it "does something useful" do - expect(false).to eq(true) - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e3cf646..5d5dc03 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,9 @@ -require "bundler/setup" -require "simple/redis/lock" +require 'bundler/setup' +require 'simple_redis_lock/redis_lock' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" + config.example_status_persistence_file_path = '.rspec_status' # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching!