### Install Gemsmith via CLI Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Commands to install the Gemsmith gem. Users can choose between a secure installation requiring a public certificate or a standard installation. ```bash # Secure installation gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem) gem install gemsmith --trust-policy HighSecurity # Standard installation gem install gemsmith ``` -------------------------------- ### Development Setup (Bash) Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Commands to clone the Gemsmith repository, navigate into the directory, and run the setup script for development. This prepares the project environment for making contributions. ```bash git clone https://github.com/bkuhlmann/gemsmith cd gemsmith bin/setup ``` -------------------------------- ### Install and Configure Gem Source: https://github.com/bkuhlmann/gemsmith/blob/main/spec/support/fixtures/readmes/minimum.adoc Provides commands to install the gem via RubyGems or Bundler, and the syntax to include the library in a Ruby project. ```bash gem install test ``` ```bash bundle add test ``` ```ruby require "test" ``` -------------------------------- ### Install GPG and Generate GPG Key Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Instructions for installing GnuPG (GPG) via Homebrew and generating a new GPG key for secure Git tag signing. Requires user input for key details. ```bash brew install gpg gpg --gen-key ``` -------------------------------- ### Install a local Gem Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Installs a gem into the local environment. Gemsmith can install any gem that contains a .gemspec file, regardless of the tool used to build it. ```bash # Implicit installation of current gem gemsmith --install # Explicit installation by name gemsmith --install demo ``` -------------------------------- ### Install Gem with High Security Trust Policy Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Demonstrates how to install a gem with a high security trust policy. This command is used to test the security of a newly created gem. ```bash gem install --trust-policy HighSecurity ``` -------------------------------- ### Gemsmith Security Configuration Example Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Example of how Gemsmith automatically configures security settings, specifically `signing_key` and `cert_chain`, within a `.gemspec` file when the `--security` option is used. ```ruby # Example .gemspec configuration generated by Gemsmith # s.signing_key = Gem.default_key_path # s.cert_chain = [Gem.default_cert_path] ``` -------------------------------- ### View Gem Documentation in Browser (Bash) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Opens an installed gem's documentation in your default web browser. This command can be used to view the documentation for any installed gem, including its homepage. ```bash gemsmith --view rails gemsmith --view sidekiq ``` -------------------------------- ### Example RubyGems Credentials File Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc This YAML snippet illustrates the structure of the RubyGems credentials file. It shows how to store credentials for both the public RubyGems server and a private server using URL strings as keys. ```yaml :rubygems_api_key: 2a0b460650e67d9b85a60e183defa376 https://private.example.com: Basic dXNlcjpwYXNzd29yZA== ``` -------------------------------- ### Install Local Gem for Testing (Bash) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Installs a locally built gem for development testing. This command automatically cleans previous artifacts, packages the gem, and installs it system-wide. ```bash gemsmith --install gemsmith --install demo gemsmith --install my_gem-0.1.0 ``` -------------------------------- ### Programmatic Gem Installation (Ruby) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Provides a programmatic interface for installing locally built gems using `Gemsmith::Tools::Installer`. This class handles the cleanup, packaging, and installation steps required for local gem deployment. ```ruby require "gemsmith" require "spek" # Load gem specification specification = Spek::Loader.call("my_gem.gemspec") # Create installer and execute installer = Gemsmith::Tools::Installer.new result = installer.call(specification) case result in Success(spec) puts "Installed: #{spec.package_name}" in Failure(message) puts "Error: #{message}" end ``` -------------------------------- ### Gemsmith Development Workflow Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc A standard workflow for building, testing, and installing a new gem using the Gemsmith CLI and Bundler. ```bash # Build gemsmith build --name demo # Design, Implement and Test. cd demo bundle exec rake # Install gemsmith --install ``` -------------------------------- ### Configure Git Signing Key Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Example of how to configure your GPG public key in the global Git configuration file. This enables automatic signing of Git tags. ```gitconfig [user] signingkey = ``` -------------------------------- ### Configure GitHub Packages for Private Gem Publishing Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc This example shows the gemspec metadata configuration for publishing a private gem to GitHub Packages. It specifies the GitHub Packages registry URL as the allowed push host. ```ruby spec.metadata = {"allowed_push_host" => "https://rubygems.pkg.github.com/alchemists"} ``` -------------------------------- ### Build Gem Project Skeleton (Bash) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Builds a new Ruby gem project skeleton with customizable options. Supports minimum, maximum, and CLI-enabled configurations, along with automatic Git initialization, bundler setup, and optional testing frameworks. ```bash gemsmith build --name my_awesome_gem gemsmith build --name demo --cli gemsmith build --name demo --min gemsmith build --name demo --max gemsmith build --name demo \ --cli \ --rspec \ --security \ --github \ --circle-ci \ --refinements \ --zeitwerk ``` -------------------------------- ### GitHub Actions Workflow for Gem Publishing (YAML) Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc This YAML defines a GitHub Actions workflow to automate the publishing of gems to GitHub Packages. It checks out the code, sets up Git credentials, installs gemsmith, and publishes the gem if a new version is detected on the main branch. It requires `GITHUB_TOKEN` with `packages: write` permissions. ```yaml name: Gemsmith on: push: branches: main jobs: build: runs-on: ubuntu-latest container: image: ruby:latest permissions: contents: write packages: write steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: '0' ref: ${{github.head_ref}} - name: Setup run: | git config user.email "engineering@example.com" git config user.name "Gemsmith Publisher" mkdir -p $HOME/.gem printf "%s\n" "https://rubygems.pkg.github.com/example: Bearer ${{secrets.GITHUB_TOKEN}}" > $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials - name: Install run: gem install gemsmith - name: Publish run: | if git describe --tags --abbrev=0 > /dev/null 2>&1; then gemsmith --publish else printf "%s\n" "First gem version must be manually created. Skipping." fi ``` -------------------------------- ### Edit Installed Gem Source Code (Bash) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Opens an installed gem's source code in your default editor for inspection or debugging. If multiple versions of a gem exist, it will prompt for the specific version to edit. ```bash gemsmith --edit rails gemsmith --edit nokogiri ``` -------------------------------- ### Add Private Gem to Gemfile (Ruby) Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc This Ruby code snippet shows how to specify a private gem source in your Gemfile. It uses a `source` block to point to the private gem server (e.g., GitHub Packages) and then declares the gem to be installed. ```ruby source "https://rubygems.pkg.github.com/alchemists" do gem "demo", ">~ 0.0" end ``` -------------------------------- ### Automated Gem Publishing GitHub Actions Workflow Source: https://context7.com/bkuhlmann/gemsmith/llms.txt This YAML snippet defines a GitHub Actions workflow for automatically publishing gems. It checks out the code, sets up Git configuration and credentials for private repositories, installs Gemsmith, and publishes the gem if a tag already exists. ```yaml name: Gemsmith on: push: branches: main jobs: build: runs-on: ubuntu-latest container: image: ruby:latest permissions: contents: write packages: write steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: '0' ref: ${{github.head_ref}} - name: Setup run: | git config user.email "bot@example.com" git config user.name "Gemsmith Publisher" mkdir -p $HOME/.gem printf "%s\n" "https://rubygems.pkg.github.com/myorg: Bearer ${{secrets.GITHUB_TOKEN}}" > $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials - name: Install run: gem install gemsmith - name: Publish run: | if git describe --tags --abbrev=0 > /dev/null 2>&1; then gemsmith --publish else printf "%s\n" "First gem version must be manually created. Skipping." fi ``` -------------------------------- ### Clone Repository Source: https://github.com/bkuhlmann/gemsmith/blob/main/spec/support/fixtures/readmes/minimum.adoc Standard commands to clone the project repository from version control and navigate into the project directory. ```bash git clone https://github.com/undefined/test cd test ``` -------------------------------- ### Open Gem Homepage with Gemsmith::Tools::Viewer Source: https://context7.com/bkuhlmann/gemsmith/llms.txt This snippet demonstrates opening a gem's homepage documentation in the default browser using Gemsmith::Tools::Viewer. It requires the 'gemsmith' and 'spek' libraries. The input is a gem specification, and the output is the gem's homepage opening in the default web browser. ```ruby require "gemsmith" require "spek" specification = Spek::Picker.call("rails").success viewer = Gemsmith::Tools::Viewer.new result = viewer.call(specification) # Opens gem homepage URL in default browser ``` -------------------------------- ### View Ruby Gem Documentation Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Opens the documentation for a specified gem in the default web browser. It handles multiple versions by prompting the user for selection. ```bash gemsmith --view ``` -------------------------------- ### Build and Add Gem Certificate Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Steps to create a public certificate for your gem, add it to your local registry, and copy it to a web server's public folder. Certificates have a validity period. ```bash cd ~/.gem gem cert build you@example.com --days 730 gem cert --add gem-public_cert.pem cp gem-public_cert.pem /gems.pem ``` -------------------------------- ### Run Test Suite Source: https://github.com/bkuhlmann/gemsmith/blob/main/spec/support/fixtures/readmes/minimum.adoc Executes the project's automated test suite using the Rake build tool. ```bash bin/rake ``` -------------------------------- ### Build a new Gem with CLI support Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Generates a new Ruby gem structure with integrated CLI support using the --cli flag. This creates a project with pre-configured namespaces and specs. ```bash gemsmith build --name demo --cli ``` -------------------------------- ### Configure Bundler for Private Gem Server (Bash) Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc This command configures Bundler globally to authenticate with a private gem server, such as GitHub Packages. It requires your GitHub handle and a Personal Access Token (PAT) with appropriate scopes. This setting is stored in `$HOME/.config/bundler/configuration.yml`. ```bash bundle config set --global rubygems.pkg.github.com : # Example: bundle config set --global rubygems.pkg.github.com jdoe:ghp_c5b8d394abefebbf45c7b27b379c74978923 ``` -------------------------------- ### Manage Gemsmith Configuration (Bash) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Manages Gemsmith's global configuration settings, which are stored in `$HOME/.config/gemsmith/configuration.yml`. This command allows viewing help, editing the configuration file, and viewing the current settings. ```bash gemsmith config gemsmith config --edit gemsmith config --view ``` -------------------------------- ### Build Gem Package with Gemsmith::Tools::Packager Source: https://context7.com/bkuhlmann/gemsmith/llms.txt This snippet demonstrates how to use Gemsmith::Tools::Packager to build a distributable .gem package from a gemspec file. It requires the 'gemsmith' and 'spek' libraries. The input is a Spek::Specification object, and the output is a .gem file in the 'pkg' directory. ```ruby require "gemsmith" require "spek" specification = Spek::Loader.call("my_gem.gemspec") packager = Gemsmith::Tools::Packager.new result = packager.call(specification) # Creates: pkg/my_gem-0.1.0.gem ``` -------------------------------- ### Retrieve GPG Public Key Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Command to list available GPG keys and filter for the public key. The output is used to obtain the key ID for Git configuration. ```bash gpg --list-keys | grep pub ``` -------------------------------- ### Configure Gem Signing Information Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc This snippet shows how to configure signing key and certificate chain for a gem specification. It utilizes default paths provided by RubyGems for signing. ```ruby Gem::Specification.new do |spec| # Truncated for brevity. spec.signing_key = Gem.default_key_path spec.cert_chain = [Gem.default_cert_path] end ``` -------------------------------- ### Publish Gem with Gemsmith Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Command to publish a gem using the Gemsmith tool. This is a straightforward command-line operation. ```bash gemsmith --publish ``` -------------------------------- ### Configure Private Gem Server Publishing Source: https://context7.com/bkuhlmann/gemsmith/llms.txt This snippet shows how to configure publishing to private gem servers. It includes two parts: a Ruby snippet for the gemspec metadata (`allowed_push_host`) and a YAML snippet for the `$HOME/.gem/credentials` file, specifying the API key or token for the private server. ```ruby # In your gemspec Gem::Specification.new do |spec| spec.metadata = { "allowed_push_host" => "https://rubygems.pkg.github.com/myorg" } end ``` ```yaml # In $HOME/.gem/credentials :rubygems_api_key: your_public_rubygems_key https://rubygems.pkg.github.com/myorg: Bearer ghp_your_github_token ``` -------------------------------- ### Publish a Ruby Gem using Gemsmith Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Publishes a Ruby gem to RubyGems. This process requires GPG signing and RubyGems MFA to be configured for secure deployment. ```bash gemsmith --publish demo ``` -------------------------------- ### Generate Gemspec with Security Settings Source: https://context7.com/bkuhlmann/gemsmith/llms.txt This Ruby snippet illustrates how a generated gemspec includes security settings when the `--security` flag is used. It shows how to configure the signing key, certificate chain, and enforce Multi-Factor Authentication (MFA) for gem publishing. ```ruby # Generated gemspec with security enabled Gem::Specification.new do |spec| spec.name = "my_gem" spec.version = "0.1.0" # Security: certificate signing spec.signing_key = Gem.default_key_path spec.cert_chain = [Gem.default_cert_path] # MFA requirement spec.metadata = { "rubygems_mfa_required" => "true" } end ``` -------------------------------- ### Open Gem Source Directory with Gemsmith::Tools::Editor Source: https://context7.com/bkuhlmann/gemsmith/llms.txt This snippet shows how to open a gem's source directory in the configured editor using Gemsmith::Tools::Editor. It depends on the 'gemsmith' and 'spek' libraries and requires the EDITOR environment variable to be set. The input is a gem specification, and the output is the gem's source directory opening in the default editor. ```ruby require "gemsmith" require "spek" # Requires EDITOR environment variable to be set specification = Spek::Picker.call("rails").success editor = Gemsmith::Tools::Editor.new result = editor.call(specification) # Opens gem source in $EDITOR ``` -------------------------------- ### Configure Private Gem Server in Gemspec Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc This Ruby code snippet shows how to add metadata to a gemspec file to specify a private gem server for publishing. The 'allowed_push_host' key links the gemspec to the corresponding credentials. ```ruby Gem::Specification.new do |spec| spec.metadata = {"allowed_push_host" => "https://private.example.com"} end ``` -------------------------------- ### Execute Gemsmith CLI Commands Programmatically (Ruby) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Demonstrates how to programmatically execute Gemsmith CLI commands using the `Gemsmith::CLI::Shell` class. This allows for scripting and automation of common Gemsmith tasks within a Ruby application. ```ruby require "gemsmith" # Create a new shell instance shell = Gemsmith::CLI::Shell.new # Execute commands programmatically shell.call %w[build --name my_gem --cli] shell.call %w[--install my_gem] shell.call %w[--publish] shell.call %w[--version] shell.call %w[--help] ``` -------------------------------- ### Configure Gemsmith Settings Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Defines the YAML configuration structure for Gemsmith, including build settings and project URI metadata for gemspec generation. ```yaml build: cli: false project: uri: # Add sub-key values here. ``` -------------------------------- ### Publish Gem to RubyGems (Bash) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Publishes a gem to RubyGems.org or a private gem server. It validates uncommitted changes, packages the gem, creates Git version tags, and pushes to the remote server, with optional YubiKey OTP authentication. ```bash gemsmith --publish gemsmith --publish demo # Publishing workflow (after building and testing) cd demo bundle exec rake # Run tests first gemsmith --publish ``` -------------------------------- ### Programmatic Gem Publishing Workflow (Ruby) Source: https://context7.com/bkuhlmann/gemsmith/llms.txt Orchestrates the complete gem publishing workflow using `Gemsmith::Tools::Publisher`. This includes validation, packaging, versioning, and pushing to gem servers, with support for optional YubiKey OTP authentication. ```ruby require "gemsmith" require "spek" # Load gem specification specification = Spek::Loader.call("my_gem.gemspec") # Create publisher and execute publisher = Gemsmith::Tools::Publisher.new result = publisher.call(specification) # Publisher runs these steps in order: # 1. Cleaner - removes old pkg/ artifacts and .gem files # 2. Validator - checks for uncommitted Git changes # 3. Packager - builds the .gem package # 4. Versioner - creates and pushes Git tags # 5. Pusher - uploads to RubyGems (with optional YubiKey OTP) case result in Success(spec) puts "Published: #{spec.package_name}" in Failure(message) puts "Publish failed: #{message}" end ``` -------------------------------- ### Edit a Local Ruby Gem Source: https://github.com/bkuhlmann/gemsmith/blob/main/README.adoc Opens an existing local gem in the system's default editor. If multiple versions exist, the user is prompted to select the target. ```bash gemsmith --edit ``` -------------------------------- ### Configure Gemsmith Global Settings Source: https://context7.com/bkuhlmann/gemsmith/llms.txt This YAML snippet shows how to configure global default settings for Gemsmith in the `$HOME/.config/gemsmith/configuration.yml` file. It allows setting build defaults, such as enabling CLI skeletons, and defining project metadata for the gemspec. ```yaml # Build defaults build: cli: false # Enable CLI skeleton by default # Project metadata for gemspec project: uri: home: "https://example.com/projects/%project_name%" source: "https://github.com/username/%project_name%" issues: "https://github.com/username/%project_name%/issues" versions: "https://example.com/projects/%project_name%/versions" funding: "https://github.com/sponsors/username" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.