Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/bundler/cli/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,8 @@ def run

if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?",
"Codes of conduct can increase contributions to your project by contributors who " \
"prefer collaborative, safe spaces. You can read more about the code of conduct at " \
"contributor-covenant.org. Having a code of conduct means agreeing to the responsibility " \
"of enforcing it, so be sure that you are prepared to do that. Be sure that your email " \
"address is specified as a contact in the generated code of conduct so that people know " \
"who to contact in case of a violation. For suggestions about " \
"how to enforce codes of conduct, see https://bit.ly/coc-enforcement.")
"prefer safe, respectful, productive, and collaborative spaces. \n" \
"See https://github.com/ruby/rubygems/blob/master/CODE_OF_CONDUCT.md")
config[:coc] = true
Bundler.ui.info "Code of conduct enabled in config"
templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
Expand Down
136 changes: 7 additions & 129 deletions lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt
Original file line number Diff line number Diff line change
@@ -1,132 +1,10 @@
# Contributor Covenant Code of Conduct
# Code of Conduct

## Our Pledge
<%= config[:name].inspect %> follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.
* Participants will be tolerant of opposing views.
* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
* When interpreting the words and actions of others, participants should always assume good intentions.
* Behaviour which can be reasonably considered harassment will not be tolerated.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders 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, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official email address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[INSERT CONTACT METHOD].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
If you have any concerns about behaviour within this project, please contact us at [<%= config[:email].inspect %>](mailto:<%= config[:email].inspect %>).
6 changes: 1 addition & 5 deletions lib/rubygems/commands/install_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,7 @@ def install_gems # :nodoc:
# Loads post-install hooks

def load_hooks # :nodoc:
if options[:install_as_default]
require_relative "../install_default_message"
else
require_relative "../install_message"
end
require_relative "../install_message"
require_relative "../rdoc"
end

Expand Down
8 changes: 5 additions & 3 deletions lib/rubygems/commands/setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,18 @@ def install_default_bundler_gem(bin_dir)
Dir.chdir("bundler") do
built_gem = Gem::Package.build(new_bundler_spec)
begin
Gem::Installer.at(
installer = Gem::Installer.at(
built_gem,
env_shebang: options[:env_shebang],
format_executable: options[:format_executable],
force: options[:force],
install_as_default: true,
bin_dir: bin_dir,
install_dir: default_dir,
wrappers: true
).install
)
installer.install
File.delete installer.spec_file
installer.write_default_spec
ensure
FileUtils.rm_f built_gem
end
Expand Down
3 changes: 0 additions & 3 deletions lib/rubygems/dependency_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Gem::DependencyInstaller
wrappers: true,
build_args: nil,
build_docs_in_background: false,
install_as_default: false,
}.freeze

##
Expand Down Expand Up @@ -87,7 +86,6 @@ def initialize(options = {})
@wrappers = options[:wrappers]
@build_args = options[:build_args]
@build_docs_in_background = options[:build_docs_in_background]
@install_as_default = options[:install_as_default]
@dir_mode = options[:dir_mode]
@data_mode = options[:data_mode]
@prog_mode = options[:prog_mode]
Expand Down Expand Up @@ -240,7 +238,6 @@ def install(dep_or_name, version = Gem::Requirement.default)
user_install: @user_install,
wrappers: @wrappers,
build_root: @build_root,
install_as_default: @install_as_default,
dir_mode: @dir_mode,
data_mode: @data_mode,
prog_mode: @prog_mode,
Expand Down
13 changes: 0 additions & 13 deletions lib/rubygems/install_default_message.rb

This file was deleted.

3 changes: 1 addition & 2 deletions lib/rubygems/install_update_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,9 @@ def add_install_update_options
options[:without_groups].concat v.map(&:intern)
end

add_option(:"Install/Update", "--default",
add_option(:Deprecated, "--default",
"Add the gem's full specification to",
"specifications/default and extract only its bin") do |v,_o|
options[:install_as_default] = v
end

add_option(:"Install/Update", "--explain",
Expand Down
39 changes: 15 additions & 24 deletions lib/rubygems/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,7 @@ def install
run_pre_install_hooks

# Set loaded_from to ensure extension_dir is correct
if @options[:install_as_default]
spec.loaded_from = default_spec_file
else
spec.loaded_from = spec_file
end
spec.loaded_from = spec_file

# Completely remove any previous gem files
FileUtils.rm_rf gem_dir
Expand All @@ -287,24 +283,17 @@ def install
dir_mode = options[:dir_mode]
FileUtils.mkdir_p gem_dir, mode: dir_mode && 0o755

if @options[:install_as_default]
extract_bin
write_default_spec
else
extract_files
extract_files

build_extensions
write_build_info_file
run_post_build_hooks
end
build_extensions
write_build_info_file
run_post_build_hooks

generate_bin
generate_plugins

unless @options[:install_as_default]
write_spec
write_cache_file
end
write_spec
write_cache_file

File.chmod(dir_mode, gem_dir) if dir_mode

Expand Down Expand Up @@ -409,12 +398,18 @@ def spec_file
File.join gem_home, "specifications", "#{spec.full_name}.gemspec"
end

def default_spec_dir
dir = File.join(gem_home, "specifications", "default")
FileUtils.mkdir_p dir
dir
end

##
# The location of the default spec file for default gems.
#

def default_spec_file
File.join gem_home, "specifications", "default", "#{spec.full_name}.gemspec"
File.join default_spec_dir, "#{spec.full_name}.gemspec"
end

##
Expand Down Expand Up @@ -889,11 +884,7 @@ def pre_install_checks

ensure_loadable_spec

if options[:install_as_default]
Gem.ensure_default_gem_subdirectories gem_home
else
Gem.ensure_gem_subdirectories gem_home
end
Gem.ensure_gem_subdirectories gem_home

return true if @force

Expand Down
13 changes: 12 additions & 1 deletion spec/bundler/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,20 @@ def install_gem(path, install_dir, default = false)
raise "OMG `#{path}` does not exist!" unless File.exist?(path)

args = "--no-document --ignore-dependencies --verbose --local --install-dir #{install_dir}"
args += " --default" if default

gem_command "install #{args} '#{path}'"

if default
gem = Pathname.new(path).basename.to_s.match(/(.*)\.gem/)[1]

# Revert Gem::Installer#write_spec and apply Gem::Installer#write_default_spec
FileUtils.mkdir_p File.join(install_dir, "specifications", "default")
File.rename File.join(install_dir, "specifications", gem + ".gemspec"),
File.join(install_dir, "specifications", "default", gem + ".gemspec")

# Revert Gem::Installer#write_cache_file
File.delete File.join(install_dir, "cache", gem + ".gem")
end
end

def with_built_bundler(version = nil, opts = {}, &block)
Expand Down
4 changes: 4 additions & 0 deletions test/json/json_encoding_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def test_generate_shared_string
assert_equal '"234567890"', JSON.dump(s[2..-1])
s = '01234567890123456789"a"b"c"d"e"f"g"h'
assert_equal '"\"a\"b\"c\"d\"e\"f\"g\""', JSON.dump(s[20, 15])
s = "0123456789001234567890012345678900123456789001234567890"
assert_equal '"23456789001234567890012345678900123456789001234567890"', JSON.dump(s[2..-1])
s = "0123456789001234567890012345678900123456789001234567890"
assert_equal '"567890012345678900123456789001234567890012345678"', JSON.dump(s[5..-3])
end

def test_unicode
Expand Down
Loading