Reputation: 2886
I have created a custom gem using bundler and checked it in a git repo.
custom_gem.rb
require "custom_gem/version"
require "custom_gem/custom_class"
module CustomGem
# Your code goes here...
end
custom_class.rb
require 'typhoeus'
module CustomGem
class CustomClass
def self.custom_method
#do stuff with typhoeus
end
end
end
Added it as a dependency to another project and installed it via bundler.
gem 'custom_gem', :git => '[email protected]:dir/repo.git'
After that I try to use it by calling
CustomGem::CustomClass.custom_method
and I get the following error:
uninitialized constant CustomGem::CustomClass
Any suggestions?
Might be a small thing but just starting out with ruby so any advice would be great.
Upvotes: 0
Views: 310
Reputation: 31726
The file custom_gem.rb should be in lib/custom_gem.rb, and the file custom_class.rb should be in lib/custom_gem/custom_class.rb
lib/custom_gem/custom_class.rb
\_/ \________________________/
| |
| \_ comes from your code: `require "custom_gem/custom_class"`
|
|
\_ comes from custom_gem.gempsec (the line `s.require_paths = ["lib"]`)
For more about the load path, file hierarchy and naming, check out this gem guide.
Upvotes: 1
Reputation: 7714
Two things to check :
Upvotes: 1