掲題の通りで、bundlerのジェネレータで作成した雛形をベースにgemの開発を行っていました。自前のクラスを追加して(下記のclient.rb
)動かそうとしましたが、規則を守っているのになぜか読み込まれない、という状況でハマっていました。
.
└── test_gem
├── Gemfile
├── Gemfile.lock
├── README.md
├── Rakefile
├── bin
│ ├── console
│ └── setup
├── test_gem-0.1.0.gem
├── test_gem.gemspec
├── lib
│ ├── test_gem
│ │ ├── client.rb # 読み込まれない
│ │ ├── config.rb
│ │ └── version.rb
│ └── test_gem.rb
└── spec
├── test_gem_spec.rb
└── spec_helper.rb
以下のgemspec
ファイルを眺めていると、
test_gem.gemspec
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'test_gem/version'
Gem::Specification.new do |spec|
spec.name = "test_gem"
spec.version = TestGem::VERSION
spec.authors = ["Yuichi MINOWA @Unicast Inc."]
spec.email = ["yuichi.minowa@u-cast.com"]
spec.summary = %q{get properties data from XXX}
spec.description = %q{get properties data through XXX Search API}
spec.homepage = "http://www.unicast.ne.jp/"
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host.
#if spec.respond_to?(:metadata)
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
#else
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
#end
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.10"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec"
spec.add_development_dependency 'activesupport'
end
spec.files
の記述が目に止まりました(以下)。この設定だと、gitの管理下になっていないとNGですね。この設定を変えるか、client.rb
をリポジトリに追加すれば解決しますね。
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }