Skip to content

Commit

Permalink
Add configuration option for allowing unknown dependencies
Browse files Browse the repository at this point in the history
Useful if you want to host your own internal/custom gems, but not
mirror their whole dependency tree which is available from RubyGems.org
  • Loading branch information
brynary committed Aug 7, 2010
1 parent 6e8450c commit 3bb83d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/models/dependency.rb
Expand Up @@ -13,6 +13,12 @@ class Dependency < ActiveRecord::Base

attr_accessor :gem_dependency

cattr_writer :allow_unknown

def self.allow_unknown
@@allow_unknown ||= false
end

def name
rubygem.name
end
Expand Down Expand Up @@ -42,6 +48,8 @@ def use_gem_dependency
end

def use_existing_rubygem
return true if self.class.allow_unknown

self.rubygem = Rubygem.find_by_name(gem_dependency.name)

if rubygem.blank?
Expand Down
5 changes: 3 additions & 2 deletions config/initializers/rubygems_config.rb
@@ -1,7 +1,8 @@
$rubygems_config = YAML.load_file(Rails.root.join("config", "rubygems.yml"))[Rails.env].symbolize_keys

HOST = $rubygems_config[:host]
Hostess.local = $rubygems_config[:local_storage]
HOST = $rubygems_config[:host]
Hostess.local = $rubygems_config[:local_storage]
Dependency.allow_unknown = $rubygems_config[:allow_unknown_dependencies]

Gemcutter::Application.configure do
config.action_mailer.default_url_options = { :host => HOST }
Expand Down
5 changes: 5 additions & 0 deletions config/rubygems.yml.example
@@ -1,22 +1,27 @@
development:
host: localhost
local_storage: true
allow_unknown_dependencies: false

test: &TEST
host: www.example.com
local_storage: true
allow_unknown_dependencies: false

cucumber:
<<: *TEST

staging:
host: staging.rubygems.org
local_storage: false
allow_unknown_dependencies: false

production:
host: rubygems.org
local_storage: false
allow_unknown_dependencies: false

maintenance:
host: rubygems.org
local_storage: false
allow_unknown_dependencies: false

0 comments on commit 3bb83d4

Please sign in to comment.