Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
3 changes: 2 additions & 1 deletion bundler/lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CLI < Thor
AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean].freeze
PARSEABLE_COMMANDS = %w[check config help exec platform show version].freeze
EXTENSIONS = ["c", "rust", "go"].freeze
COC_OPTIONS = %w[contributor-covenant ruby none].freeze

COMMAND_ALIASES = {
"check" => "c",
Expand Down Expand Up @@ -567,7 +568,7 @@ def viz

desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
method_option :exe, type: :boolean, default: false, aliases: ["--bin", "-b"], banner: "Generate a binary executable for your library."
method_option :coc, type: :boolean, banner: "Generate a code of conduct file. Set a default with `bundle config set --global gem.coc true`."
method_option :coc, type: :string, lazy_default: (COC_OPTIONS.include?(Bundler.settings["gem.coc"]) ? Bundler.settings["gem.coc"] : ""), enum: COC_OPTIONS, banner: "Generate a code of conduct file, either Contributor Covenant, Ruby, or none. Set a default with `bundle config set --global gem.coc (contributor-covenant|ruby|none)`"
method_option :edit, type: :string, aliases: "-e", required: false, lazy_default: [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? }, banner: "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
method_option :ext, type: :string, banner: "Generate the boilerplate for C extension code.", enum: EXTENSIONS
method_option :git, type: :boolean, default: true, banner: "Initialize a git repo inside your library."
Expand Down
74 changes: 67 additions & 7 deletions bundler/lib/bundler/cli/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,16 @@ def run
templates.merge!("LICENSE.txt.tt" => "LICENSE.txt")
end

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 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")
config[:coc] = ask_and_set_coc
case config[:coc]
when "contributor-covenant"
Bundler.ui.info "Contributor Covenant enabled in config"
templates.merge!("CONTRIBUTOR_COVENANT_CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
when "ruby"
Bundler.ui.info "Ruby Community Conduct Guideline enabled in config"
templates.merge!("RUBY_SRC_CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
when "none"
# Explicitly skip CODE_OF_CONDUCT.md generation
end

if ask_and_set(:changelog, "Do you want to include a changelog?",
Expand Down Expand Up @@ -387,6 +390,63 @@ def ask_and_set_ci
ci_template
end

def ask_and_set_coc
return "none" if skip?(:coc)
coc_template = options[:coc] || Bundler.settings["gem.coc"]

# Handle backwards compatibility: if the old boolean `false` value is set,
# silently migrate to the new `none` value and honor the setting
if coc_template.to_s == "false"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Bundler.settings.set_global("gem.coc", "none")
return "none"
end

# Handle backwards compatibility: if the old boolean `true` value is set,
# prompt the user to choose a specific code of conduct
if coc_template.to_s == "true"
Bundler.ui.info "\nYour gem.coc setting is configured to `true`, but `bundle gem` now supports " \
"multiple codes of conduct. Please select which code of conduct you'd like to use:\n" \
"* Contributor Covenant: https://www.contributor-covenant.org/\n" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just my personal preference, but I'd like the Ruby stuff to come first.

"* Ruby: https://www.ruby-lang.org/en/conduct/\n"
Bundler.ui.info "Your choice will update the global gem.coc setting."

result = Bundler.ui.ask "Enter a code of conduct. contributor-covenant/ruby/(none):"
if %w[contributor-covenant ruby].include?(result)
coc_template = result
else
Bundler.ui.info "Unrecognized input, skipping code of conduct" unless result.to_s.empty? || result == "none"
coc_template = "none"
end
Bundler.settings.set_global("gem.coc", coc_template)
elsif coc_template.to_s.empty?
Bundler.ui.info "\nDo 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 safe, respectful, productive, and collaborative spaces.\n" \
"Supported codes of conduct:\n" \
"* Contributor Covenant: https://www.contributor-covenant.org/\n" \
"* Ruby: https://www.ruby-lang.org/en/conduct/\n"
Bundler.ui.info hint_text("coc")

result = Bundler.ui.ask "Enter a code of conduct. contributor-covenant/ruby/(none):"
if %w[contributor-covenant ruby].include?(result)
coc_template = result
else
Bundler.ui.info "Unrecognized input, skipping code of conduct" unless result.to_s.empty? || result == "none"
coc_template = "none"
end

if Bundler.settings["gem.coc"].nil?
Bundler.settings.set_global("gem.coc", coc_template)
end
end

if options[:coc] && !options[:coc].empty? && options[:coc] == Bundler.settings["gem.coc"]
Bundler.ui.info "Using configured code of conduct: #{options[:coc]}"
end

coc_template
end

def ask_and_set_linter
return if skip?(:linter)
linter_template = options[:linter] || Bundler.settings["gem.linter"]
Expand Down
20 changes: 16 additions & 4 deletions bundler/lib/bundler/man/bundle-gem.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,22 @@ configuration file using the following names:
* `--no-exe`:
Do not create a binary (overrides `--exe` specified in the global config).

* `--coc`:
Add a `CODE_OF_CONDUCT.md` file to the root of the generated project. If
this option is unspecified, an interactive prompt will be displayed and the
answer will be saved in Bundler's global config for future `bundle gem` use.
* `--coc`, `--coc=contributor-covenant`, `--coc=ruby`, `--coc=none`:
Specify the code of conduct that Bundler should use when generating the
project. Acceptable values are `contributor-covenant`, `ruby`, and `none`.
A `CODE_OF_CONDUCT.md` file will be generated in the project directory
unless `none` is specified. Given no option is specified:

When Bundler is configured to generate a code of conduct, this defaults to
Bundler's global config setting `gem.coc`.

When Bundler is configured to not generate a code of conduct, an interactive
prompt will be displayed and the answer will be used for the current rubygem
project.

When Bundler is unconfigured, an interactive prompt will be displayed and
the answer will be saved in Bundler's global config for future `bundle gem`
use.

* `--no-coc`:
Do not create a `CODE_OF_CONDUCT.md` (overrides `--coc` specified in the
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Settings
force_ruby_platform
frozen
gem.changelog
gem.coc
gem.mit
gem.bundle
git.allow_insecure
Expand Down Expand Up @@ -60,6 +59,7 @@ class Settings
cache_path
console
gem.ci
gem.coc
gem.github_username
gem.linter
gem.rubocop
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Contributor Covenant 3.0 Code of Conduct

## Our Pledge

We pledge to make our community welcoming, safe, and equitable for all.

We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant.

## Encouraged Behaviors

While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language.

With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including:

1. Respecting the **purpose of our community**, our activities, and our ways of gathering.
2. Engaging **kindly and honestly** with others.
3. Respecting **different viewpoints** and experiences.
4. **Taking responsibility** for our actions and contributions.
5. Gracefully giving and accepting **constructive feedback**.
6. Committing to **repairing harm** when it occurs.
7. Behaving in other ways that promote and sustain the **well-being of our community**.


## Restricted Behaviors

We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct.

1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop.
2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people.
3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits.
4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community.
5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission.
6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group.
7. Behaving in other ways that **threaten the well-being** of our community.

### Other Restrictions

1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions.
2. **Failing to credit sources.** Not properly crediting the sources of content you contribute.
3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community.
4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors.


## Reporting an Issue

Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm.

When an incident does occur, it is important to report it promptly. To report a possible violation, contact us at [<%= config[:email] %>](mailto:<%= config[:email] %>).

Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution.


## Addressing and Repairing Harm

If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped.

1) Warning
1) Event: A violation involving a single incident or series of incidents.
2) Consequence: A private, written warning from the Community Moderators.
3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations.
2) Temporarily Limited Activities
1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation.
2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members.
3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over.
3) Temporary Suspension
1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation.
2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions.
3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted.
4) Permanent Ban
1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member.
2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior.
3) Repair: There is no possible repair in cases of this severity.

This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community.


## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other 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.


## Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/).

Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/)

For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion).
Loading
Loading