Code Monkey home page Code Monkey logo

sample-ruby-gem's Introduction

sample-ruby-gem

Sample Ruby Gem

publish gem as package to github and download it

You can certainly publish a gem into github package e.g.

https://github.com/users/xuan-cao-swi/packages/rubygems/package/hola-xuan

https://github.com/orgs/solarwinds/packages?ecosystem=rubygems

Through the simple process:

  1. create or edit a ~/.gem/credentials to include the following, replacing TOKEN with your personal access token.
---
:rubygems_api_key: rubygems_****************************
:github: Bearer ghp_****************************
  1. publish the gem
gem build GEM_NAME.gemspec
gem push --key github --host https://rubygems.pkg.github.com/xuan-cao-swi GEM_NAME-0.0.1.gem  # assume push to xuan-cao-swi

Download the gem require user authenticate to github first

# Install from the command line:
# $ gem install hola-xuan --version "0.0.1"

# Install via Gemfile:
source "https://rubygems.pkg.github.com/xuan-cao-swi" do
  gem "hola-xuan", "0.0.1"
end

However, github require the user who wish to download the gem from github package to be the github user and autheticate themselves first. The token could from any user but has to have the permission of read:packages (Download packages from GitHub Package Registry).

export BUNDLE_RUBYGEMS__PKG__GITHUB__COM=ghp_**************************** # this token could be any valid github user token

In irb or loading the application, user DOESN'T needs to do require 'bundler/setup'

notes: once the github package set to public, every new gem push to that package will be public

Use github as direct source of gems

Examples

# Use the http(s), ssh, or git protocol
gem 'foo', git: 'https://github.com/dideler/foo.git'
gem 'foo', git: '[email protected]:dideler/foo.git'
gem 'foo', git: 'git://github.com/dideler/foo.git'

# Specify a tag, ref, or branch to use
gem 'foo', git: '[email protected]:dideler/foo.git', tag: 'v2.1.0'
gem 'foo', git: '[email protected]:dideler/foo.git', ref: '4aded'
gem 'foo', git: '[email protected]:dideler/foo.git', branch: 'development'

# Shorthand for public repos on GitHub (supports all the :git options)
gem 'foo', github: 'dideler/foo'

In irb or loading the application, user needs to do require 'bundler/setup' first

require 'bundler/setup'
require 'the_gem_from_github'

To install from command line

gem install specific_install
gem specific_install https://github.com/githubsvnclone/rdoc.git 

sample-ruby-gem's People

Contributors

xuan-cao-swi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.