ruby - Developing Multiple Rails Plugins with Dependencies -


i'm starting build series of plugins , engines in project i'm developing , i've run issue of having list paths dependencies in of gemfiles main application , plugins/engines if want rake work.

rake works fine main application because it's gemfile lists relative paths plugins/engines want, when plugin/engine dependent on , not have relative paths listed, using rake rdoc i'll error following (presumably i'll same error trying run tests/the dummy application/etc):

bundler not find compatible versions gem "user":   in gemfile:     auth (>= 0) ruby depends on       user (>= 0) ruby not find gem 'user (>= 0) ruby', required gem 'auth (>= 0) ruby', in of sources. 

rather having use paths, i've tried specifying git repository in plugins/engines so:

# user engine gem 'user', git: 'https://localhost/git/project/user.git', branch: 'master' 

and using bundler config local.user /path/to/local/repo command make point local repository development. appeared work perfectly... until change version of plugin in local repo, spits out error in dependent plugin/engine/application:

could not find user-0.0.1 in of sources run `bundle install` install missing gems. 

whilst isn't of issue-- version number changed @ end anyway --it turns out throw following error if you're on branch in local repo instead of master:

local override user @ /path/to/local/repo using branch deleteme gemfile specifies master 

and omitting branch option gemfile leaves me error:

cannot use local override user @ /path/to/local/repo because :branch not specified in gemfile. specify branch or use `bundle config --delete` remove local override 

so stuck having , path: "../local-repo-directory" strewn of gemfiles plugins/engines dependencies on 1 whilst in development or there way of developing multiple interdependent plugins/engines rails @ same time doesn't use sloppy/inelegant solution?

i'm drawing blanks on other ways this, appreciated. hope i've explained enough, if there's else can clarify, let me know.

thanks!

stick specifying git repositories in gemfile , using bundle local overrides work on them.

possible problems solutions: 1. local override user @ /path/to/local/repo using branch deleteme gemfile specifies master if gemfile specifies branch "master" local override should have branch "master" checked out. because goal of local override can work on gem in local folder while running , testing application. in production check out branch , revision specified in gemfile , gemfile.lock , should offcourse running local override.

2. not find user-0.0.1 in of sources run `bundle install` install missing gems. when run bundle install places version number each gem in gemfile.lock. file added git other developers , production server runs same versions of gems do. gemfile.lock needs specify same version of gem returned in local override gemspec file. if incremented version number in local override need run "bundle update gemname" in application uses updates gemfile.lock. note bundler caches in gemspec file until increment version. can't add new dependencies or change dependency versions in gemspec if don't increase version number in gemspec.

the git-bundle gem

if use git repository in gemfile local overrides bundler store git revision hashes in gemfile.lock mentioned above. example:

gemfile: gem 'example', git: 'https://github.com/your_name/example.git', branch: :master

bundle config shell command: bundle config local.example /path/to/local/git/repository

gemfile.lock (auto generated): git remote: https://github.com/your_name/example.git revision: b9270e61abb89e1ff77fb8cfacb463e4d04388ad branch: master

after commit in local override repository need run bundle install on main application rebuilds gemfile.lock include new revision hash , commit it. recommend using gem below automates process , aids in other scenarios. see gem page exact detail.

https://github.com/epi-use-labs/git-bundle

the activesupport-decorators gem

as sidenote, when need extend classes between gems can use decorator pattern implemented elegantly activesupport-decorators gem:

https://github.com/epi-use-labs/activesupport-decorators


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -