From 59c8d50653480bef3f24517296e6ddf937fdf6bc Mon Sep 17 00:00:00 2001 From: hsbt Date: Fri, 2 Nov 2018 23:07:56 +0000 Subject: Added bundler as default gems. Revisit [Feature #12733] * bin/*, lib/bundler/*, lib/bundler.rb, spec/bundler, man/*: Merge from latest stable branch of bundler/bundler repository and added workaround patches. I will backport them into upstream. * common.mk, defs/gmake.mk: Added `test-bundler` task for test suite of bundler. * tool/sync_default_gems.rb: Added sync task for bundler. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt | 74 ++++++++++++++++++++++ lib/bundler/templates/newgem/Gemfile.tt | 6 ++ lib/bundler/templates/newgem/LICENSE.txt.tt | 21 ++++++ lib/bundler/templates/newgem/README.md.tt | 47 ++++++++++++++ lib/bundler/templates/newgem/Rakefile.tt | 29 +++++++++ lib/bundler/templates/newgem/bin/console.tt | 14 ++++ lib/bundler/templates/newgem/bin/setup.tt | 8 +++ lib/bundler/templates/newgem/exe/newgem.tt | 3 + .../templates/newgem/ext/newgem/extconf.rb.tt | 3 + .../templates/newgem/ext/newgem/newgem.c.tt | 9 +++ .../templates/newgem/ext/newgem/newgem.h.tt | 6 ++ lib/bundler/templates/newgem/gitignore.tt | 20 ++++++ lib/bundler/templates/newgem/lib/newgem.rb.tt | 13 ++++ .../templates/newgem/lib/newgem/version.rb.tt | 7 ++ lib/bundler/templates/newgem/newgem.gemspec.tt | 55 ++++++++++++++++ lib/bundler/templates/newgem/rspec.tt | 3 + .../templates/newgem/spec/newgem_spec.rb.tt | 9 +++ .../templates/newgem/spec/spec_helper.rb.tt | 14 ++++ .../templates/newgem/test/newgem_test.rb.tt | 11 ++++ .../templates/newgem/test/test_helper.rb.tt | 4 ++ lib/bundler/templates/newgem/travis.yml.tt | 7 ++ 21 files changed, 363 insertions(+) create mode 100644 lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt create mode 100644 lib/bundler/templates/newgem/Gemfile.tt create mode 100644 lib/bundler/templates/newgem/LICENSE.txt.tt create mode 100644 lib/bundler/templates/newgem/README.md.tt create mode 100644 lib/bundler/templates/newgem/Rakefile.tt create mode 100644 lib/bundler/templates/newgem/bin/console.tt create mode 100644 lib/bundler/templates/newgem/bin/setup.tt create mode 100644 lib/bundler/templates/newgem/exe/newgem.tt create mode 100644 lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt create mode 100644 lib/bundler/templates/newgem/ext/newgem/newgem.c.tt create mode 100644 lib/bundler/templates/newgem/ext/newgem/newgem.h.tt create mode 100644 lib/bundler/templates/newgem/gitignore.tt create mode 100644 lib/bundler/templates/newgem/lib/newgem.rb.tt create mode 100644 lib/bundler/templates/newgem/lib/newgem/version.rb.tt create mode 100644 lib/bundler/templates/newgem/newgem.gemspec.tt create mode 100644 lib/bundler/templates/newgem/rspec.tt create mode 100644 lib/bundler/templates/newgem/spec/newgem_spec.rb.tt create mode 100644 lib/bundler/templates/newgem/spec/spec_helper.rb.tt create mode 100644 lib/bundler/templates/newgem/test/newgem_test.rb.tt create mode 100644 lib/bundler/templates/newgem/test/test_helper.rb.tt create mode 100644 lib/bundler/templates/newgem/travis.yml.tt (limited to 'lib/bundler/templates/newgem') diff --git a/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt b/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt new file mode 100644 index 0000000000..a3833d29d7 --- /dev/null +++ b/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at <%= config[:email] %>. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/lib/bundler/templates/newgem/Gemfile.tt b/lib/bundler/templates/newgem/Gemfile.tt new file mode 100644 index 0000000000..c114bd6665 --- /dev/null +++ b/lib/bundler/templates/newgem/Gemfile.tt @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +# Specify your gem's dependencies in <%= config[:name] %>.gemspec +gemspec diff --git a/lib/bundler/templates/newgem/LICENSE.txt.tt b/lib/bundler/templates/newgem/LICENSE.txt.tt new file mode 100644 index 0000000000..76ef4b0191 --- /dev/null +++ b/lib/bundler/templates/newgem/LICENSE.txt.tt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) <%= Time.now.year %> <%= config[:author] %> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/lib/bundler/templates/newgem/README.md.tt b/lib/bundler/templates/newgem/README.md.tt new file mode 100644 index 0000000000..868a0afe67 --- /dev/null +++ b/lib/bundler/templates/newgem/README.md.tt @@ -0,0 +1,47 @@ +# <%= config[:constant_name] %> + +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/<%= config[:namespaced_path] %>`. To experiment with that code, run `bin/console` for an interactive prompt. + +TODO: Delete this and the text above, and describe your gem + +## Installation + +Add this line to your application's Gemfile: + +```ruby +gem '<%= config[:name] %>' +``` + +And then execute: + + $ bundle + +Or install it yourself as: + + $ gem install <%= config[:name] %> + +## Usage + +TODO: Write usage instructions here + +## Development + +After checking out the repo, run `bin/setup` to install dependencies.<% if config[:test] %> Then, run `rake <%= config[:test].sub('mini', '').sub('rspec', 'spec') %>` to run the tests.<% end %> You can also run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the gem in this directory, ignoring other installed copies of this gem.<% end %> + +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 tags, 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/<%= config[:github_username] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.<% end %> +<% if config[:mit] -%> + +## License + +The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). +<% end -%> +<% if config[:coc] -%> + +## Code of Conduct + +Everyone interacting in the <%= config[:constant_name] %> project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md). +<% end -%> diff --git a/lib/bundler/templates/newgem/Rakefile.tt b/lib/bundler/templates/newgem/Rakefile.tt new file mode 100644 index 0000000000..099da6f3ec --- /dev/null +++ b/lib/bundler/templates/newgem/Rakefile.tt @@ -0,0 +1,29 @@ +require "bundler/gem_tasks" +<% if config[:test] == "minitest" -%> +require "rake/testtask" + +Rake::TestTask.new(:test) do |t| + t.libs << "test" + t.libs << "lib" + t.test_files = FileList["test/**/*_test.rb"] +end + +<% elsif config[:test] == "rspec" -%> +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +<% end -%> +<% if config[:ext] -%> +require "rake/extensiontask" + +task :build => :compile + +Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext| + ext.lib_dir = "lib/<%= config[:namespaced_path] %>" +end + +task :default => [:clobber, :compile, :<%= config[:test_task] %>] +<% else -%> +task :default => :<%= config[:test_task] %> +<% end -%> diff --git a/lib/bundler/templates/newgem/bin/console.tt b/lib/bundler/templates/newgem/bin/console.tt new file mode 100644 index 0000000000..a27f82430f --- /dev/null +++ b/lib/bundler/templates/newgem/bin/console.tt @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "<%= config[:namespaced_path] %>" + +# 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/lib/bundler/templates/newgem/bin/setup.tt b/lib/bundler/templates/newgem/bin/setup.tt new file mode 100644 index 0000000000..dce67d860a --- /dev/null +++ b/lib/bundler/templates/newgem/bin/setup.tt @@ -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/lib/bundler/templates/newgem/exe/newgem.tt b/lib/bundler/templates/newgem/exe/newgem.tt new file mode 100644 index 0000000000..a8339bb79f --- /dev/null +++ b/lib/bundler/templates/newgem/exe/newgem.tt @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +require "<%= config[:namespaced_path] %>" diff --git a/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt b/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt new file mode 100644 index 0000000000..8cfc828f94 --- /dev/null +++ b/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt @@ -0,0 +1,3 @@ +require "mkmf" + +create_makefile(<%= config[:makefile_path].inspect %>) diff --git a/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt b/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt new file mode 100644 index 0000000000..8177c4d202 --- /dev/null +++ b/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt @@ -0,0 +1,9 @@ +#include "<%= config[:underscored_name] %>.h" + +VALUE rb_m<%= config[:constant_array].join %>; + +void +Init_<%= config[:underscored_name] %>(void) +{ + rb_m<%= config[:constant_array].join %> = rb_define_module(<%= config[:constant_name].inspect %>); +} diff --git a/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt b/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt new file mode 100644 index 0000000000..c6e420b66e --- /dev/null +++ b/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt @@ -0,0 +1,6 @@ +#ifndef <%= config[:underscored_name].upcase %>_H +#define <%= config[:underscored_name].upcase %>_H 1 + +#include "ruby.h" + +#endif /* <%= config[:underscored_name].upcase %>_H */ diff --git a/lib/bundler/templates/newgem/gitignore.tt b/lib/bundler/templates/newgem/gitignore.tt new file mode 100644 index 0000000000..b1c9f9986c --- /dev/null +++ b/lib/bundler/templates/newgem/gitignore.tt @@ -0,0 +1,20 @@ +/.bundle/ +/.yardoc +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ +<%- if config[:ext] -%> +*.bundle +*.so +*.o +*.a +mkmf.log +<%- end -%> +<%- if config[:test] == "rspec" -%> + +# rspec failure tracking +.rspec_status +<%- end -%> diff --git a/lib/bundler/templates/newgem/lib/newgem.rb.tt b/lib/bundler/templates/newgem/lib/newgem.rb.tt new file mode 100644 index 0000000000..fae6337c3e --- /dev/null +++ b/lib/bundler/templates/newgem/lib/newgem.rb.tt @@ -0,0 +1,13 @@ +require "<%= config[:namespaced_path] %>/version" +<%- if config[:ext] -%> +require "<%= config[:namespaced_path] %>/<%= config[:underscored_name] %>" +<%- end -%> + +<%- config[:constant_array].each_with_index do |c, i| -%> +<%= " " * i %>module <%= c %> +<%- end -%> +<%= " " * config[:constant_array].size %>class Error < StandardError; end +<%= " " * config[:constant_array].size %># Your code goes here... +<%- (config[:constant_array].size-1).downto(0) do |i| -%> +<%= " " * i %>end +<%- end -%> diff --git a/lib/bundler/templates/newgem/lib/newgem/version.rb.tt b/lib/bundler/templates/newgem/lib/newgem/version.rb.tt new file mode 100644 index 0000000000..389daf5048 --- /dev/null +++ b/lib/bundler/templates/newgem/lib/newgem/version.rb.tt @@ -0,0 +1,7 @@ +<%- config[:constant_array].each_with_index do |c, i| -%> +<%= " " * i %>module <%= c %> +<%- end -%> +<%= " " * config[:constant_array].size %>VERSION = "0.1.0" +<%- (config[:constant_array].size-1).downto(0) do |i| -%> +<%= " " * i %>end +<%- end -%> diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt new file mode 100644 index 0000000000..faf6f7bbc5 --- /dev/null +++ b/lib/bundler/templates/newgem/newgem.gemspec.tt @@ -0,0 +1,55 @@ +<%- if RUBY_VERSION < "2.0.0" -%> +# coding: utf-8 +<%- end -%> + +lib = File.expand_path("../lib", __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require "<%= config[:namespaced_path] %>/version" + +Gem::Specification.new do |spec| + spec.name = <%= config[:name].inspect %> + spec.version = <%= config[:constant_name] %>::VERSION + spec.authors = [<%= config[:author].inspect %>] + spec.email = [<%= config[:email].inspect %>] + + 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." +<%- if config[:mit] -%> + spec.license = "MIT" +<%- end -%> + + # 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.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] +<%- if config[:ext] -%> + spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"] +<%- end -%> + + spec.add_development_dependency "bundler", "~> <%= config[:bundler_version] %>" + spec.add_development_dependency "rake", "~> 10.0" +<%- if config[:ext] -%> + spec.add_development_dependency "rake-compiler" +<%- end -%> +<%- if config[:test] -%> + spec.add_development_dependency "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>" +<%- end -%> +end diff --git a/lib/bundler/templates/newgem/rspec.tt b/lib/bundler/templates/newgem/rspec.tt new file mode 100644 index 0000000000..34c5164d9b --- /dev/null +++ b/lib/bundler/templates/newgem/rspec.tt @@ -0,0 +1,3 @@ +--format documentation +--color +--require spec_helper diff --git a/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt b/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt new file mode 100644 index 0000000000..c63b487830 --- /dev/null +++ b/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt @@ -0,0 +1,9 @@ +RSpec.describe <%= config[:constant_name] %> do + it "has a version number" do + expect(<%= config[:constant_name] %>::VERSION).not_to be nil + end + + it "does something useful" do + expect(false).to eq(true) + end +end diff --git a/lib/bundler/templates/newgem/spec/spec_helper.rb.tt b/lib/bundler/templates/newgem/spec/spec_helper.rb.tt new file mode 100644 index 0000000000..805cf57e01 --- /dev/null +++ b/lib/bundler/templates/newgem/spec/spec_helper.rb.tt @@ -0,0 +1,14 @@ +require "bundler/setup" +require "<%= config[:namespaced_path] %>" + +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 diff --git a/lib/bundler/templates/newgem/test/newgem_test.rb.tt b/lib/bundler/templates/newgem/test/newgem_test.rb.tt new file mode 100644 index 0000000000..f2af9f90e0 --- /dev/null +++ b/lib/bundler/templates/newgem/test/newgem_test.rb.tt @@ -0,0 +1,11 @@ +require "test_helper" + +class <%= config[:constant_name] %>Test < Minitest::Test + def test_that_it_has_a_version_number + refute_nil ::<%= config[:constant_name] %>::VERSION + end + + def test_it_does_something_useful + assert false + end +end diff --git a/lib/bundler/templates/newgem/test/test_helper.rb.tt b/lib/bundler/templates/newgem/test/test_helper.rb.tt new file mode 100644 index 0000000000..725e3e4647 --- /dev/null +++ b/lib/bundler/templates/newgem/test/test_helper.rb.tt @@ -0,0 +1,4 @@ +$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) +require "<%= config[:namespaced_path] %>" + +require "minitest/autorun" diff --git a/lib/bundler/templates/newgem/travis.yml.tt b/lib/bundler/templates/newgem/travis.yml.tt new file mode 100644 index 0000000000..7a3381a889 --- /dev/null +++ b/lib/bundler/templates/newgem/travis.yml.tt @@ -0,0 +1,7 @@ +--- +sudo: false +language: ruby +cache: bundler +rvm: + - <%= RUBY_VERSION %> +before_install: gem install bundler -v <%= Bundler::VERSION %> -- cgit v1.2.3