安装自己的宝石

时间:2014-09-25 13:27:02

标签: ruby-on-rails

好的,我正在制作一个名为dogify的hello world gem,但我无法在我的演示项目中安装它。

这是我的gemspec,请询问任何其他文件:

# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'my_dogify/version'
Gem::Specification.new do |spec|
  spec.name          = "my_dogify"
  spec.version       = MyDogify::VERSION
  spec.authors       = ['me']
  spec.email         = ['me']
  spec.summary       = 'summmary'
  spec.description   = 'description'
  spec.homepage      = ""
  spec.license       = "MIT"

  spec.files         = `git ls-files -z`.split("\x0")
  spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
  spec.require_paths = ["lib"]

  spec.add_development_dependency "bundler", "~> 1.7"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency 'rspec'

  spec.add_dependency 'engtagger'
end

这是我的Gemfile

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'my_dogify'

命令行:

$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Could not find gem 'my_dogify (>= 0) ruby' in the gems available on this machine.

1 个答案:

答案 0 :(得分:3)

默认情况下,在RubyGems存储库中搜索gems。这意味着为了使用my_dogify,它必须是published on RubyGems

如果您不关心发布它而只想在本地使用它,那么use the path option指定gem的路径。

gem 'extracted_library', :path => './vendor/extracted_library'
相关问题