mastodon/mastodon-api

The "require" declaration for develop

noraworld opened this issue · 1 comments

I apologize first that this issue isn't directly related to this library, but I have a question about developing the Ruby library.

At the latest of Ruby, we have to specify a relative path or an absolute path when loading a Ruby file from a current directory by require, like this:

- require 'mastodon'
+ require './mastodon'

In fact, require declaration exists not only in a Ruby file of library-using-side but also in the Ruby files in this library. And not all files will be loaded from a current directory, for example:

require 'json'             # not require './json'
require '../lib/mastodon'  # in spec/spec_helper.rb:7

Do I have to change require path in all files when developing this library? Does it have any better solution?

I added the following code to a library-using-side file, and it worked successfully.

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Btw, another error occurred in my environment, so I resolved this by installing the missing Gem.

gem install buftok

I am so sorry for the inconvenience.