From c67a500204e70e0c9c3e214a90804f80a7140e1d Mon Sep 17 00:00:00 2001 From: delano Date: Tue, 17 Jan 2023 17:40:44 -0800 Subject: [PATCH] Modernize gemspec --- .github/workflows/main.yml | 27 +++++++++++++++++ .gitignore | 10 +++++-- .rubocop.yml | 13 ++++++++ CHANGES.txt | 6 ++++ Gemfile | 10 +++++++ LICENSE.txt | 4 ++- README.md | 35 ++++++++++++++++++++++ Rakefile | 61 ++++---------------------------------- bin/console | 15 ++++++++++ bin/setup | 8 +++++ {bin => exe}/redis-dump | 0 {bin => exe}/redis-load | 0 {bin => exe}/redis-report | 0 lib/redis/dump.rb | 7 ++++- lib/redis/dump/version.rb | 7 +++++ redis-dump.gemspec | 39 ++++++++++++++++++++++++ sig/redis/dump.rbs | 6 ++++ 17 files changed, 188 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 .rubocop.yml create mode 100644 Gemfile create mode 100644 README.md create mode 100755 bin/console create mode 100755 bin/setup rename {bin => exe}/redis-dump (100%) rename {bin => exe}/redis-load (100%) rename {bin => exe}/redis-report (100%) create mode 100644 lib/redis/dump/version.rb create mode 100644 sig/redis/dump.rbs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..4beaac3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,27 @@ +name: Ruby + +on: + push: + branches: + - master + + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + name: Ruby ${{ matrix.ruby }} + strategy: + matrix: + ruby: + - '3.1.2' + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run the default task + run: bundle exec rake diff --git a/.gitignore b/.gitignore index 29ca08b..9106b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ -.DS_Store -pkg +/.bundle/ +/.yardoc +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3620847 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,13 @@ +AllCops: + TargetRubyVersion: 2.7.5 + +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +Style/StringLiteralsInInterpolation: + Enabled: true + EnforcedStyle: double_quotes + +Layout/LineLength: + Max: 120 diff --git a/CHANGES.txt b/CHANGES.txt index 6fc6f5a..da12bb9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,11 @@ REDIS-DUMP, CHANGES +#### 1.0.0 (2023-01-17) ############################### + +* ADDED: Timeout support for redis connections +* CHANGED: uri-redis dependency to 1.0.0 + + #### 0.4.0 (2017-11-23) ############################### * ADDED: support for redis >= 4.0 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..f2ea9f7 --- /dev/null +++ b/Gemfile @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +# Specify your gem's dependencies in redis-dump.gemspec +gemspec + +gem "rake", "~> 13.0" + +gem "rubocop", "~> 1.21" diff --git a/LICENSE.txt b/LICENSE.txt index bc42d13..d3da527 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,6 @@ -Copyright (c) 2010-2017 Solutious Inc, Delano Mandelbaum +The MIT License (MIT) + +Copyright (c) 2023 delano Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md new file mode 100644 index 0000000..0bad41a --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# Redis::Dump + +TODO: Delete this and the text below, and describe your gem + +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/redis/dump`. To experiment with that code, run `bin/console` for an interactive prompt. + +## Installation + +TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. + +Install the gem and add to the application's Gemfile by executing: + + $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG + +If bundler is not being used to manage dependencies, install the gem by executing: + + $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG + +## Usage + +TODO: Write usage instructions here + +## Development + +After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment. + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/redis-dump. + +## License + +The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). diff --git a/Rakefile b/Rakefile index 91f620a..1924143 100644 --- a/Rakefile +++ b/Rakefile @@ -1,59 +1,8 @@ -require "rubygems" -require "rake" -require "rake/clean" -require "rdoc/task" +# frozen_string_literal: true -task :default => ["build"] -CLEAN.include [ 'pkg', 'rdoc' ] -name = "redis-dump" - -$:.unshift File.join(File.dirname(__FILE__), 'lib') -require "redis/dump" -version = Redis::Dump::VERSION.to_s - -begin - require "jeweler" - Jeweler::Tasks.new do |s| - s.version = version - s.name = name - s.summary = "Backup and restore your Redis data to and from JSON." - s.description = s.summary - s.email = "delano@solutious.com" - s.homepage = "http://github.com/delano/redis-dump" - s.authors = ["Delano Mandelbaum"] - - s.add_dependency("yajl-ruby", ">= 0.1") - s.add_dependency("redis", ">= 4.0") - s.add_dependency("uri-redis", ">= 0.4.0") - s.add_dependency("drydock", ">= 0.6.9") - - s.license = "MIT" - - s.signing_key = File.join('/mnt/gem/', 'gem-private_key.pem') - s.cert_chain = ['gem-public_cert.pem'] - end - Jeweler::GemcutterTasks.new -rescue LoadError - puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler" -end - -require 'rake/testtask' -Rake::TestTask.new do |t| - t.libs = ["lib", "test"] -end - -extra_files = %w[LICENSE.txt THANKS.txt CHANGES.txt ] -RDoc::Task.new do |rdoc| - rdoc.rdoc_dir = "rdoc" - rdoc.title = "#{name} #{version}" - rdoc.generator = 'hanna' # gem install hanna-nouveau - rdoc.main = 'README.rdoc' - rdoc.rdoc_files.include("README*") - rdoc.rdoc_files.include("bin/*.rb") - rdoc.rdoc_files.include("lib/**/*.rb") - extra_files.each { |file| - rdoc.rdoc_files.include(file) if File.exists?(file) - } -end +require "bundler/gem_tasks" +require "rubocop/rake_task" +RuboCop::RakeTask.new +task default: :rubocop diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..e196a33 --- /dev/null +++ b/bin/console @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "bundler/setup" +require "redis/dump" + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +# (If you use this, don't forget to add pry to your Gemfile!) +# require "pry" +# Pry.start + +require "irb" +IRB.start(__FILE__) diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000..dce67d8 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install + +# Do any other automated setup that you need to do here diff --git a/bin/redis-dump b/exe/redis-dump similarity index 100% rename from bin/redis-dump rename to exe/redis-dump diff --git a/bin/redis-load b/exe/redis-load similarity index 100% rename from bin/redis-load rename to exe/redis-load diff --git a/bin/redis-report b/exe/redis-report similarity index 100% rename from bin/redis-report rename to exe/redis-report diff --git a/lib/redis/dump.rb b/lib/redis/dump.rb index 0f1d111..e4510e4 100644 --- a/lib/redis/dump.rb +++ b/lib/redis/dump.rb @@ -1,12 +1,17 @@ +# frozen_string_literal: true + unless defined?(RD_HOME) RD_HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..') ) end require 'redis' -require 'uri/redis' require 'yajl' require 'base64' +require 'uri/redis' + +require_relative "dump/version" + class Redis class Dump unless defined?(Redis::Dump::VALID_TYPES) diff --git a/lib/redis/dump/version.rb b/lib/redis/dump/version.rb new file mode 100644 index 0000000..ae4bb22 --- /dev/null +++ b/lib/redis/dump/version.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Redis + class Dump + VERSION = "1.0.0" + end +end diff --git a/redis-dump.gemspec b/redis-dump.gemspec index e69de29..95d1fd1 100644 --- a/redis-dump.gemspec +++ b/redis-dump.gemspec @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative "lib/redis/dump/version" + +Gem::Specification.new do |spec| + spec.name = "redis-dump" + spec.version = Redis::Dump::VERSION + spec.authors = ["delano"] + spec.email = "delano@solutious.com" + + spec.summary = "Backup and restore your Redis data to and from JSON." + spec.description = "Backup and restore your Redis data to and from JSON by database, key, or key pattern." + spec.homepage = "https://rubygems.org/gems/redis-dump" + spec.license = "MIT" + spec.required_ruby_version = ">= 2.7.5" + + spec.metadata["allowed_push_host"] = "https://rubygems.org/" + + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = "https://github.com/delano/redis-dump" + spec.metadata["changelog_uri"] = "https://github.com/delano/redis-dump/blob/main/CHANGES.txt" + + # 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(__dir__) do + `git ls-files -z`.split("\x0").reject do |f| + (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)}) + end + end + spec.bindir = "bin" + spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + spec.add_dependency("yajl-ruby", ">= 0.1") + spec.add_dependency("oj", ">= 3.13.14") + spec.add_dependency("redis", ">= 4.0") + spec.add_dependency("uri-redis", ">= 1.0.0") + spec.add_dependency("drydock", ">= 0.6.9") +end diff --git a/sig/redis/dump.rbs b/sig/redis/dump.rbs new file mode 100644 index 0000000..7b31fa5 --- /dev/null +++ b/sig/redis/dump.rbs @@ -0,0 +1,6 @@ +module Redis + module Dump + VERSION: String + # See the writing guide of rbs: https://github.com/ruby/rbs#guides + end +end