ruby - Where should I put my gem in my developing gem? -



ruby - Where should I put my gem in my developing gem? -

i trying understand gems should go. wrote ruby script trying convert gem. used bundler create skeleton gem.

now got 2 files 'gemfile' , 'mygem.gemspec'.

in gemfile got 2 lines saying:

source 'https://rubygems.org' # specify gem's dependencies in cudruby.gemspec gemspec

..and in 'mygem.gemspec' got:

# coding: utf-8 lib = file.expand_path('../lib', __file__) $load_path.unshift(lib) unless $load_path.include?(lib) require 'mygem/version' gem::specification.new |spec| spec.name = "mygem" spec.version = mygem::version spec.authors = ["mygem"] spec.email = ["mygem@gmail.com"] spec.summary = %q{mygem} spec.description = %q{mygem} spec.homepage = "http://www.mygem.com" spec.license = "mit" spec.files = dir["{lib}/**/*.rb", "bin/*", "license", "*.md"] 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.6" spec.add_development_dependency "rake" end

now ruby script used rely on 3 gems, 'facter','debugger','json'.

where add together these? , how?

i found : http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/

now guy says (from link):

"when developing gem, utilize gemspec method in gemfile avoid duplication. in general, gem’s gemfile should contain rubygems source , single gemspec line..."

so left gemspec file was..

i checked facter's official repository , gemfile is: https://github.com/puppetlabs/facter/blob/master/gemfile

..and gemspec is: https://github.com/puppetlabs/facter/blob/master/.gemspec

now why have gems in gemfile, , nil in gemspec? doing opposite of read.

could create clear me please?

thanks!

one of import detail gemfile , mygem.gemspec ruby files. means have lot of flexibility, , can create things work in many different ways, provided bundle , gem info need. however, worth next standard examples recent documentation, code cleaner , easier follow.

the method gemspec in gemfile convenient way of telling bundler "this project uses list of gems defined in gemspec" - i.e. avoids needing list dependencies twice - enable bundle install , allow gem auto-install dependencies.

where add together dependencies? @ end of gemspec, so:

spec.add_development_dependency "rake" # illustration of 1 of dependencies spec.add_dependency "facter", ">= 2.3.0" end

ideally should refer minimum version work bug free gem.

you should not utilize facter gem template or example, there non-standard going on there. start .gemspec link not facter's gemspec used build gem. @ to the lowest degree in part comes long history of gem, 10 years old. when first written, toolkit of bundler , gem nil now.

this not straight asked, worth noting completeness:

the dependency listings bundler (in gemfile) , gem building/installation (in .gemspec). not automatically include dependency gems in code. still need add together require statements ruby source before.

ruby gem bundler

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -