pax_global_header00006660000000000000000000000064140116134200014502gustar00rootroot0000000000000052 comment=92ad9c5c3fff591b8383ada8b93c3da1279d24ad ruby2_keywords-0.0.5/000077500000000000000000000000001401161342000144765ustar00rootroot00000000000000ruby2_keywords-0.0.5/.github/000077500000000000000000000000001401161342000160365ustar00rootroot00000000000000ruby2_keywords-0.0.5/.github/workflows/000077500000000000000000000000001401161342000200735ustar00rootroot00000000000000ruby2_keywords-0.0.5/.github/workflows/test.yml000066400000000000000000000024561401161342000216040ustar00rootroot00000000000000name: test on: [push, pull_request] jobs: build: name: build (${{ matrix.ruby }} / ${{ matrix.os }}) strategy: matrix: ruby: [ '3.0', 2.7, 2.6, 2.1, head, truffleruby-head ] os: [ ubuntu-latest, macos-latest, windows-latest ] exclude: - { os: windows-latest, ruby: truffleruby-head } runs-on: ${{ matrix.os }} steps: - name: git config run: | git config --global core.autocrlf false git config --global core.eol lf git config --global advice.detachedHead 0 - uses: actions/checkout@master - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: Install id: bundle run: | bundle install echo "::set-output name=exec::bundle exec" if: "matrix.ruby <= '2.1'" - name: Run test run: ${{steps.bundle.outputs.exec}} rake test - id: build run: | rake build echo "::set-output name=pkg::${GITHUB_REPOSITORY#*/}-${RUNNING_OS%-*}" env: RUNNING_OS: ${{matrix.os}} if: "matrix.ruby == '3.0'" shell: bash - name: Upload package uses: actions/upload-artifact@v2 with: path: pkg/*.gem name: ${{steps.build.outputs.pkg}} if: steps.build.outputs.pkg ruby2_keywords-0.0.5/.gitignore000066400000000000000000000000341401161342000164630ustar00rootroot00000000000000ChangeLog logs/ gems.locked ruby2_keywords-0.0.5/LICENSE000066400000000000000000000024211401161342000155020ustar00rootroot00000000000000Copyright 2019-2020 Nobuyoshi Nakada, Yusuke Endoh Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ruby2_keywords-0.0.5/README.md000066400000000000000000000030141401161342000157530ustar00rootroot00000000000000# ruby2_keywords Provides empty `Module#ruby2_keywords` method, for the forward source-level compatibility against ruby2.7 and ruby3. ## Installation Add this line to your application's Gemfile: ```ruby gem 'ruby2_keywords' ``` And then execute: $ bundle Or install it yourself as: $ gem install ruby2_keywords ## Usage For class/module instance methods: ```ruby require 'ruby2_keywords' module YourModule ruby2_keywords def delegating_method(*args) other_method(*args) end end ``` For global methods: ```ruby require 'ruby2_keywords' ruby2_keywords def oldstyle_keywords(options = {}) end ``` You can do the same for a method defined by `Module#define_method`: ```ruby define_method :delegating_method do |*args, &block| other_method(*args, &block) end ruby2_keywords :delegating_method ``` ## Contributing Bug reports and pull requests are welcome on [GitHub] or [Ruby Issue Tracking System]. ## Development After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rake test` to run the tests. To test on older Ruby versions, you can use docker. E.g. to test on Ruby 2.0, use `docker-compose run ruby-2.0`. ## License The gem is available as open source under the terms of the [Ruby License] or the [2-Clause BSD License]. [GitHub]: https://github.com/ruby/ruby2_keywords/ [Ruby Issue Tracking System]: https://bugs.ruby-lang.org [Ruby License]: https://www.ruby-lang.org/en/about/license.txt [2-Clause BSD License]: https://opensource.org/licenses/BSD-2-Clause ruby2_keywords-0.0.5/Rakefile000066400000000000000000000004211401161342000161400ustar00rootroot00000000000000require "bundler/gem_tasks" require "rake/testtask" Rake::TestTask.new(:test) do |t| t.test_files = FileList["test/**/test_*.rb"] end task :default => :test task "bump:minor" do raise "can't bump up minor" end task "bump:major" do raise "can't bump up major" end ruby2_keywords-0.0.5/docker-compose.yml000066400000000000000000000024061401161342000201350ustar00rootroot00000000000000version: '3.0' services: ruby-2.0: image: ruby:2.0 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby-2.1: image: ruby:2.1 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby-2.2: image: ruby:2.2 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby-2.3: image: ruby:2.3 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby-2.4: image: ruby:2.4 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby-2.5: image: ruby:2.5 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby-2.6: image: ruby:2.6 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby-2.7: image: ruby:2.7 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby-3.0: image: ruby:3.0 volumes: - .:/app command: bash -c 'cd /app && bundle install && bundle exec rake test' ruby2_keywords-0.0.5/gems.rb000066400000000000000000000001531401161342000157550ustar00rootroot00000000000000source 'https://rubygems.org' gemspec group :development do gem "test-unit", ">= 2.2" gem "rake" end ruby2_keywords-0.0.5/lib/000077500000000000000000000000001401161342000152445ustar00rootroot00000000000000ruby2_keywords-0.0.5/lib/ruby2_keywords.rb000066400000000000000000000021321401161342000205610ustar00rootroot00000000000000class Module unless private_method_defined?(:ruby2_keywords) private # call-seq: # ruby2_keywords(method_name, ...) # # Does nothing. def ruby2_keywords(name, *) # nil end end end main = TOPLEVEL_BINDING.eval('self') unless main.respond_to?(:ruby2_keywords, true) # call-seq: # ruby2_keywords(method_name, ...) # # Does nothing. def main.ruby2_keywords(name, *) # nil end end class Proc unless method_defined?(:ruby2_keywords) # call-seq: # proc.ruby2_keywords -> proc # # Does nothing and just returns the receiver. def ruby2_keywords self end end end class << Hash unless method_defined?(:ruby2_keywords_hash?) # call-seq: # Hash.ruby2_keywords_hash?(hash) -> false # # Returns false. def ruby2_keywords_hash?(hash) false end end unless method_defined?(:ruby2_keywords_hash) # call-seq: # Hash.ruby2_keywords_hash(hash) -> new_hash # # Duplicates a given hash and returns the new hash. def ruby2_keywords_hash(hash) hash.dup end end end ruby2_keywords-0.0.5/rakelib/000077500000000000000000000000001401161342000161075ustar00rootroot00000000000000ruby2_keywords-0.0.5/rakelib/changelogs.rake000066400000000000000000000021171401161342000210660ustar00rootroot00000000000000task "build" => "changelogs" changelog = proc do |output, ver = nil, prev = nil| ver &&= Gem::Version.new(ver) range = [[prev], [ver, "HEAD"]].map {|ver, branch| ver ? "v#{ver.to_s}" : branch}.compact.join("..") IO.popen(%W[git log --format=fuller --topo-order --no-merges #{range}]) do |log| line = log.gets FileUtils.mkpath(File.dirname(output)) File.open(output, "wb") do |f| f.print "-*- coding: utf-8 -*-\n\n", line log.each_line do |line| line.sub!(/^(?!:)(?:Author|Commit)?(?:Date)?: /, ' \&') line.sub!(/ +$/, '') f.print(line) end end end end tags = IO.popen(%w[git tag -l v[0-9]*]).grep(/v(.*)/) {$1} tags.sort_by! {|tag| tag.scan(/\d+/).map(&:to_i)} tags.inject(nil) do |prev, tag| task("logs/ChangeLog-#{tag}") {|t| changelog[t.name, tag, prev]} tag end desc "Make ChangeLog" task "ChangeLog", [:ver, :prev] do |t, ver: nil, prev: tags.last| changelog[t.name, ver, prev] end changelogs = ["ChangeLog", *tags.map {|tag| "logs/ChangeLog-#{tag}"}] task "changelogs" => changelogs CLOBBER.concat(changelogs) << "logs" ruby2_keywords-0.0.5/rakelib/epoch.rake000066400000000000000000000002261401161342000200510ustar00rootroot00000000000000task "build" => "date_epoch" task "date_epoch" do ENV["SOURCE_DATE_EPOCH"] = IO.popen(%W[git -C #{__dir__} log -1 --format=%ct], &:read).chomp end ruby2_keywords-0.0.5/rakelib/version.rake000066400000000000000000000016331401161342000204430ustar00rootroot00000000000000class << (helper = Bundler::GemHelper.instance) def update_gemspec path = gemspec.loaded_from File.open(path, "r+b") do |f| d = f.read if d.sub!(/^(_VERSION\s*=\s*)".*"/) {$1 + gemspec.version.to_s.dump} f.rewind f.truncate(0) f.print(d) end end end def commit_bump sh(%W[git -C #{__dir__} commit -m bump\ up\ to\ #{gemspec.version} #{gemspec.loaded_from}]) end def version=(v) gemspec.version = v update_gemspec commit_bump end end major, minor, teeny = helper.gemspec.version.segments task "bump:teeny" do helper.version = Gem::Version.new("#{major}.#{minor}.#{teeny+1}") end task "bump:minor" do helper.version = Gem::Version.new("#{major}.#{minor+1}.0") end task "bump:major" do helper.version = Gem::Version.new("#{major+1}.0.0") end task "bump" => "bump:teeny" task "tag" do helper.__send__(:tag_version) end ruby2_keywords-0.0.5/ruby2_keywords.gemspec000066400000000000000000000012461401161342000210400ustar00rootroot00000000000000_VERSION = "0.0.5" abort "Version must not reach 1" if _VERSION[/\d+/].to_i >= 1 Gem::Specification.new do |s| s.name = "ruby2_keywords" s.version = _VERSION s.summary = "Shim library for Module#ruby2_keywords" s.homepage = "https://github.com/ruby/ruby2_keywords" s.licenses = ["Ruby", "BSD-2-Clause"] s.authors = ["Nobuyoshi Nakada"] s.require_paths = ["lib"] s.rdoc_options = ["--main", "README.md"] s.extra_rdoc_files = [ "LICENSE", "README.md", "ChangeLog", *Dir.glob("#{__dir__}/logs/ChangeLog-*[^~]").map {|path| path[(__dir__.size+1)..-1]}, ] s.files = [ "lib/ruby2_keywords.rb", ] s.required_ruby_version = '>= 2.0.0' end ruby2_keywords-0.0.5/test/000077500000000000000000000000001401161342000154555ustar00rootroot00000000000000ruby2_keywords-0.0.5/test/test_keyword.rb000066400000000000000000000022621401161342000205270ustar00rootroot00000000000000require 'test/unit' LOADING_RUBY2_KEYWORDS = (RUBY_VERSION.scan(/\d+/).map(&:to_i) <=> [2, 7]) < 0 if LOADING_RUBY2_KEYWORDS require 'ruby2_keywords' end class TestKeywordArguments < Test::Unit::TestCase def test_loaded_features list = $LOADED_FEATURES.grep(%r[/ruby2_keywords\.rb\z]) if LOADING_RUBY2_KEYWORDS assert_not_empty(list) assert_not_include($LOADED_FEATURES, "ruby2_keywords.rb") else assert_empty(list) assert_include($LOADED_FEATURES, "ruby2_keywords.rb") end end def test_module_ruby2_keywords assert_send([Module, :private_method_defined?, :ruby2_keywords]) assert_operator(Module.instance_method(:ruby2_keywords).arity, :<, 0) end def test_toplevel_ruby2_keywords main = TOPLEVEL_BINDING.eval('self') assert_send([main, :respond_to?, :ruby2_keywords, true]) assert_operator(main.method(:ruby2_keywords).arity, :<, 0) end def test_proc_ruby2_keywords assert_respond_to(Proc.new {}, :ruby2_keywords) end def test_hash_ruby2_keywords_hash? assert_false(Hash.ruby2_keywords_hash?({})) end def test_hash_ruby2_keywords_hash assert_equal({}, Hash.ruby2_keywords_hash({}.freeze)) end end