adva-user 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/app/controllers/admin/base_controller_slice.rb +5 -0
  2. data/app/controllers/installations_controller_slice.rb +9 -0
  3. data/app/controllers/user/confirmations_controller.rb +3 -0
  4. data/app/controllers/user/passwords_controller.rb +3 -0
  5. data/app/controllers/user/registrations_controller.rb +3 -0
  6. data/app/controllers/user/sessions_controller.rb +7 -0
  7. data/app/controllers/user/unlocks_controller.rb +3 -0
  8. data/app/models/account_slice.rb +4 -0
  9. data/app/models/user.rb +12 -0
  10. data/app/views/layouts/admin/_header_slice.rb +16 -0
  11. data/app/views/layouts/user.rb +2 -0
  12. data/app/views/mailer/confirmation_instructions.html.erb +5 -0
  13. data/app/views/mailer/reset_password_instructions.html.erb +8 -0
  14. data/app/views/mailer/unlock_instructions.html.erb +7 -0
  15. data/app/views/user/confirmations/new.html.rb +16 -0
  16. data/app/views/user/form.rb +67 -0
  17. data/app/views/user/passwords/edit.html.rb +18 -0
  18. data/app/views/user/passwords/new.html.rb +16 -0
  19. data/app/views/user/registrations/edit.html.rb +18 -0
  20. data/app/views/user/registrations/new.html.rb +18 -0
  21. data/app/views/user/sessions/new.html.rb +26 -0
  22. data/app/views/user/unlocks/new.html.rb +16 -0
  23. data/config/locales/en.yml +87 -0
  24. data/config/routes.rb +3 -0
  25. data/lib/adva-user.rb +1 -0
  26. data/lib/adva/user.rb +42 -0
  27. data/lib/adva_user/version.rb +3 -0
  28. data/lib/testing/factories.rb +11 -0
  29. data/lib/testing/paths.rb +14 -0
  30. data/lib/testing/step_definitions.rb +23 -0
  31. data/public/stylesheets/adva-user/user.css +30 -0
  32. metadata +35 -5
  33. data/lib/bundler/repository.rb +0 -118
@@ -0,0 +1,5 @@
1
+ require 'admin/base_controller'
2
+
3
+ Admin::BaseController.class_eval do
4
+ before_filter :authenticate_user!
5
+ end
@@ -0,0 +1,9 @@
1
+ require 'installations_controller'
2
+
3
+ InstallationsController.class_eval do
4
+ before_filter :set_admin_params, :only => :create
5
+
6
+ def set_admin_params
7
+ params[:site][:account_attributes][:users_attributes] ||= [{ :email => 'admin@admin.org', :password => 'admin!' }]
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ class User::ConfirmationsController < Devise::ConfirmationsController
2
+ layout 'user'
3
+ end
@@ -0,0 +1,3 @@
1
+ class User::PasswordsController < Devise::PasswordsController
2
+ layout 'user'
3
+ end
@@ -0,0 +1,3 @@
1
+ class User::RegistrationsController < Devise::RegistrationsController
2
+ layout 'user'
3
+ end
@@ -0,0 +1,7 @@
1
+ class User::SessionsController < Devise::SessionsController
2
+ layout 'user'
3
+
4
+ def after_sign_in_path_for(resource)
5
+ params[:return_to] || '/'
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ class User::UnlocksController < Devise::UnlocksController
2
+ layout 'user'
3
+ end
@@ -0,0 +1,4 @@
1
+ Account.class_eval do
2
+ has_many :users, :dependent => :destroy
3
+ accepts_nested_attributes_for :users
4
+ end
@@ -0,0 +1,12 @@
1
+ require 'devise'
2
+
3
+ class User < ActiveRecord::Base
4
+ devise :database_authenticatable, :registerable, :rememberable, :confirmable,
5
+ :recoverable, :validatable, :trackable
6
+
7
+ serialize :roles, Array
8
+
9
+ def roles
10
+ read_attribute(:roles) || []
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require_dependency 'layouts/admin'
2
+ require_dependency 'layouts/admin/_header'
3
+
4
+ module Layouts::Admin::Header::User
5
+ def right
6
+ login_status
7
+ super
8
+ end
9
+
10
+ def login_status
11
+ link_to t('.sign_out', :user => current_user.email), destroy_user_session_path
12
+ self << '&middot;'.html_safe
13
+ end
14
+
15
+ Layouts::Admin::Header.send(:include, self)
16
+ end
@@ -0,0 +1,2 @@
1
+ class Layouts::User < Layouts::Simple
2
+ end
@@ -0,0 +1,5 @@
1
+ <p>Welcome <%= @resource.email %>!</p>
2
+
3
+ <p>You can confirm your account through the link below:</p>
4
+
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
@@ -0,0 +1,8 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Someone has requested a link to change your password, and you can do this through the link below.</p>
4
+
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
6
+
7
+ <p>If you didn't request this, please ignore this email.</p>
8
+ <p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,7 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
4
+
5
+ <p>Click the link below to unlock your account:</p>
6
+
7
+ <p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
@@ -0,0 +1,16 @@
1
+ class User::Confirmations::New < User::Form
2
+ include do
3
+ def to_html
4
+ h2 :'.title'
5
+ super
6
+ end
7
+
8
+ def fields
9
+ form.input :email
10
+ end
11
+
12
+ def form_arguments
13
+ [resource, { :as => resource_name, :url => confirmation_path(resource_name) }]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,67 @@
1
+ class User::Form < Adva::View::Form
2
+ include do
3
+ def fields
4
+ devise_error_messages!
5
+ super
6
+ end
7
+
8
+ def button_group
9
+ super
10
+ links
11
+ end
12
+
13
+ def buttons
14
+ form.submit t(:'.submit')
15
+ end
16
+
17
+ def links
18
+ ul :class => 'links user' do
19
+ li { sign_in_link } if sign_in?
20
+ li { sign_up_link } if sign_up?
21
+ li { forgot_password_link } if forgot_password?
22
+ li { resend_confirmation_link } if resend_confirmation?
23
+ li { resend_unlock_link } if resend_unlock?
24
+ end
25
+ end
26
+
27
+ def sign_in?
28
+ controller_name != 'sessions'
29
+ end
30
+
31
+ def sign_up?
32
+ devise_mapping.registerable? && controller_name != 'registrations'
33
+ end
34
+
35
+ def forgot_password?
36
+ devise_mapping.recoverable? && controller_name != 'passwords'
37
+ end
38
+
39
+ def resend_confirmation?
40
+ devise_mapping.confirmable? && controller_name != 'confirmations'
41
+ end
42
+
43
+ def resend_unlock?
44
+ devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
45
+ end
46
+
47
+ def sign_in_link
48
+ capture { link_to(:'user.links.sign_in', new_session_path(resource_name), :class => :sign_in) }
49
+ end
50
+
51
+ def sign_up_link
52
+ capture { link_to(:'user.links.sign_up', new_registration_path(resource_name), :class => :sign_up) }
53
+ end
54
+
55
+ def forgot_password_link
56
+ capture { link_to(:'user.links.forgot_password', new_password_path(resource_name), :class => :forgot_password) }
57
+ end
58
+
59
+ def resend_confirmation_link
60
+ capture { link_to(:'user.links.resend_confirmation', new_confirmation_path(resource_name), :class => :resend_confirmation) }
61
+ end
62
+
63
+ def resend_unlock_link
64
+ capture { link_to(:'user.links.resend_unlock', new_unlock_path(resource_name), :class => :resend_unlock) }
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,18 @@
1
+ class User::Passwords::Edit < User::Form
2
+ include do
3
+ def to_html
4
+ h2 :'.title'
5
+ super
6
+ end
7
+
8
+ def fields
9
+ form.hidden_field :reset_password_token
10
+ form.input :password
11
+ form.input :password_confirmation
12
+ end
13
+
14
+ def form_arguments
15
+ [resource, { :as => resource_name, :url => password_path(resource_name), :html => { :method => :put } }]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ class User::Passwords::New < User::Form
2
+ include do
3
+ def to_html
4
+ h2 :'.title'
5
+ super
6
+ end
7
+
8
+ def fields
9
+ form.input :email
10
+ end
11
+
12
+ def form_arguments
13
+ [resource, { :as => resource_name, :url => password_path(resource_name) }]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ class User::Registrations::Edit < User::Form
2
+ include do
3
+ def to_html
4
+ h2 :'.title'
5
+ super
6
+ end
7
+
8
+ def fields
9
+ form.input :email
10
+ form.input :password
11
+ form.input :password_confirmation
12
+ end
13
+
14
+ def form_arguments
15
+ [resource, { :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put } }]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class User::Registrations::New < User::Form
2
+ include do
3
+ def to_html
4
+ h2 :'.title'
5
+ super
6
+ end
7
+
8
+ def fields
9
+ form.input :email
10
+ form.input :password
11
+ form.input :password_confirmation
12
+ end
13
+
14
+ def form_arguments
15
+ [resource, { :as => resource_name, :url => registration_path(resource_name) }]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ class User::Sessions::New < User::Form
2
+ include do
3
+ def to_html
4
+ h2 :'.title'
5
+ super
6
+ end
7
+
8
+ def fields
9
+ pass_return_to
10
+ form.input :email
11
+ form.input :password
12
+ remember_me if devise_mapping.rememberable?
13
+ end
14
+
15
+ def form_arguments
16
+ [resource, { :as => resource_name, :url => session_path(resource_name) }]
17
+ end
18
+
19
+ def remember_me
20
+ div :class => :checkbox_group do
21
+ form.check_box :remember_me
22
+ form.label :remember_me, :class => :inline
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ class User::Unlocks::New < User::Form
2
+ include do
3
+ def to_html
4
+ h2 :'.title'
5
+ super
6
+ end
7
+
8
+ def fields
9
+ form.input :email
10
+ end
11
+
12
+ def form_arguments
13
+ [resource, { :as => resource_name, :url => unlock_path(resource_name) }]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,87 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ not_found: "not found"
5
+ already_confirmed: "was already confirmed"
6
+ not_locked: "was not locked"
7
+
8
+ user:
9
+ links:
10
+ sign_in: Sign in
11
+ sign_up: Sign up
12
+ forgot_password: Forgot password?
13
+ resend_confirmation: Resend confirmation
14
+ resend_unlock: Resend unlock
15
+ sessions:
16
+ new:
17
+ title: Sign in
18
+ submit: Sign in
19
+ registrations:
20
+ new:
21
+ title: Sign up
22
+ submit: Sign up
23
+ edit:
24
+ title: Edit account
25
+ submit: Update account
26
+ current_password_required: "We need your current password to confirm your changes."
27
+ confirmations:
28
+ new:
29
+ title: Resend confirmation instructions
30
+ submit: Resend instructions
31
+ passwords:
32
+ new:
33
+ title: Forgot your password?
34
+ submit: Send instructions
35
+ edit:
36
+ title: Change your password
37
+ submit: Change password
38
+ unlocks:
39
+ new:
40
+ title: Resend unlock instructions
41
+ submit: Send instructions
42
+
43
+ devise:
44
+ failure:
45
+ unauthenticated: 'You need to sign in or sign up before continuing.'
46
+ unconfirmed: 'You have to confirm your account before continuing.'
47
+ locked: 'Your account is locked.'
48
+ invalid: 'Invalid email or password.'
49
+ invalid_token: 'Invalid authentication token.'
50
+ timeout: 'Your session expired, please sign in again to continue.'
51
+ inactive: 'Your account was not activated yet.'
52
+ sessions:
53
+ signed_in: 'Signed in successfully.'
54
+ signed_out: 'Signed out successfully.'
55
+ passwords:
56
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
57
+ updated: 'Your password was changed successfully. You are now signed in.'
58
+ confirmations:
59
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
60
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
61
+ registrations:
62
+ signed_up: 'You have signed up successfully. A confirmation was sent to your e-mail.'
63
+ updated: 'You updated your account successfully.'
64
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
65
+ unlocks:
66
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
67
+ unlocked: 'Your account was successfully unlocked. You are now signed in.'
68
+ mailer:
69
+ confirmation_instructions:
70
+ subject: 'Confirmation instructions'
71
+ reset_password_instructions:
72
+ subject: 'Reset password instructions'
73
+ unlock_instructions:
74
+ subject: 'Unlock Instructions'
75
+
76
+ layouts:
77
+ default:
78
+ signed_in_as: "Signed in as %{user}"
79
+ sign_in: Sign in
80
+ sign_up: Sign up
81
+ sign_out: Sign out
82
+
83
+ admin:
84
+ header:
85
+ sign_in: Sign in
86
+ sign_up: Sign up
87
+ sign_out: Sign out %{user}
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ devise_for :user, :module => 'user'
3
+ end
data/lib/adva-user.rb ADDED
@@ -0,0 +1 @@
1
+ require 'adva/user'
data/lib/adva/user.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'adva/core'
2
+ require 'devise'
3
+
4
+ module Adva
5
+ class User < ::Rails::Engine
6
+ include Adva::Engine
7
+
8
+ # TODO [config] should probably happen in the client app
9
+ # for more devise options see http://bit.ly/bwxrGg
10
+ initializer 'adva-user.devise_setup' do |app|
11
+
12
+ # FIXME [config]
13
+ app.config.action_mailer.default_url_options = { :host => 'www.example.com' }
14
+
15
+ Devise.setup do |config|
16
+ require 'devise/orm/active_record'
17
+ config.mailer_sender = 'please-change-me@config-initializers-devise.com'
18
+ config.encryptor = :bcrypt
19
+ config.password_length = 5..20
20
+ end
21
+
22
+ Devise::FailureApp.class_eval do
23
+ def redirect
24
+ flash[:alert] = i18n_message unless flash[:notice]
25
+ redirect_to send(:"new_#{scope}_session_path", :return_to => attempted_path)
26
+ end
27
+ end
28
+ end
29
+
30
+ initializer 'adva-user.register_asset_expansions' do
31
+ ActionView::Helpers::AssetTagHelper.register_javascript_expansion(
32
+ :user => %w()
33
+ )
34
+
35
+ ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion(
36
+ :user => %w( adva-core/default/forms
37
+ adva-core/admin/common
38
+ adva-user/user )
39
+ )
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module AdvaUser
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,11 @@
1
+ Factory.define :user, :class => User do |f|
2
+ f.sequence(:email) { |n| "user-#{n}@example.com" }
3
+ f.password 'password'
4
+ f.after_build { |user| User.deactivate_callbacks }
5
+ f.after_create { |user| user.confirm!; User.activate_callbacks }
6
+ end
7
+
8
+ Factory.define :admin, :parent => :user do |f|
9
+ f.email { User.find_by_email('admin@admin.org') ? 'admin-2@admin.org' : 'admin@admin.org' }
10
+ f.password 'admin!'
11
+ end
@@ -0,0 +1,14 @@
1
+ module Adva::User::Paths
2
+ def path_to(page)
3
+ case page
4
+ when /^the sign in page$/
5
+ new_user_session_path
6
+ when /^the new registration page$/
7
+ new_user_registration_path
8
+ else
9
+ super
10
+ end
11
+ end
12
+ end
13
+
14
+ World(Adva::User::Paths)
@@ -0,0 +1,23 @@
1
+ Given /^I am signed in with "([^"]*)" and "([^"]*)"$/ do |email, password|
2
+ post user_session_path, :user => { :email => email, :password => password }
3
+ end
4
+
5
+ # This step should only be used for testing the login itself (login.feature)
6
+ # Please, use the step 'Given I am signed in with "admin@admin.org" and "admin!"' in all
7
+ # other features for performance reasons.
8
+ Given /^I sign in with "([^"]*)" and "([^"]*)"$/ do |email, password|
9
+ get new_user_session_path
10
+ fill_in 'Email', :with => email
11
+ fill_in 'Password', :with => password
12
+ click_button 'Sign in'
13
+ end
14
+
15
+ Given /a confirmed user with email "([^"]+)" and password "([^"]+)"/ do |email, password|
16
+ user = User.without_callbacks.create!(:email => email, :password => password)
17
+ user.confirm!
18
+ end
19
+
20
+ Then 'I should be signed in' do
21
+ When 'I go to the sign in page'
22
+ Then 'I should be on the homepage'
23
+ end
@@ -0,0 +1,30 @@
1
+ body {
2
+ font-size: 11pt;
3
+ }
4
+ #page {
5
+ border-top: 5px solid #c22222;
6
+ }
7
+ .main {
8
+ width: 400px;
9
+ margin: 0 auto;
10
+ padding-top: 0px;
11
+ }
12
+ #content {
13
+ padding: 20px 30px 30px 30px;
14
+ }
15
+
16
+ .links {
17
+ display: block !important;
18
+ margin-top: 30px;
19
+ }
20
+ .links li:first-child:before {
21
+ content: '';
22
+ }
23
+ .links .sign_in,
24
+ .links .sign_up,
25
+ .links .forgot_password,
26
+ .links .resend_confirmation,
27
+ .links .resend_unlock {
28
+ font-size: 9pt;
29
+ color: #999;
30
+ }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adva-user
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ingo Weiss
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-19 00:00:00 +01:00
19
+ date: 2010-12-03 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -58,7 +58,37 @@ extensions: []
58
58
  extra_rdoc_files: []
59
59
 
60
60
  files:
61
- - lib/bundler/repository.rb
61
+ - app/controllers/user/passwords_controller.rb
62
+ - app/controllers/user/sessions_controller.rb
63
+ - app/controllers/user/unlocks_controller.rb
64
+ - app/controllers/user/confirmations_controller.rb
65
+ - app/controllers/user/registrations_controller.rb
66
+ - app/controllers/installations_controller_slice.rb
67
+ - app/controllers/admin/base_controller_slice.rb
68
+ - app/views/layouts/user.rb
69
+ - app/views/layouts/admin/_header_slice.rb
70
+ - app/views/user/unlocks/new.html.rb
71
+ - app/views/user/sessions/new.html.rb
72
+ - app/views/user/passwords/edit.html.rb
73
+ - app/views/user/passwords/new.html.rb
74
+ - app/views/user/form.rb
75
+ - app/views/user/confirmations/new.html.rb
76
+ - app/views/user/registrations/edit.html.rb
77
+ - app/views/user/registrations/new.html.rb
78
+ - app/views/mailer/confirmation_instructions.html.erb
79
+ - app/views/mailer/unlock_instructions.html.erb
80
+ - app/views/mailer/reset_password_instructions.html.erb
81
+ - app/models/user.rb
82
+ - app/models/account_slice.rb
83
+ - config/routes.rb
84
+ - config/locales/en.yml
85
+ - lib/adva-user.rb
86
+ - lib/adva_user/version.rb
87
+ - lib/adva/user.rb
88
+ - lib/testing/factories.rb
89
+ - lib/testing/paths.rb
90
+ - lib/testing/step_definitions.rb
91
+ - public/stylesheets/adva-user/user.css
62
92
  has_rdoc: true
63
93
  homepage: http://github.com/svenfuchs/adva-cms2
64
94
  licenses: []
@@ -1,118 +0,0 @@
1
- require 'pathname'
2
-
3
- # Bundler gemfile support for local/remote workspaces/repositories for work in
4
- # development teams.
5
- #
6
- # Usage:
7
- #
8
- # # define paths to be searched for repositories:
9
- # workspace '~/.projects ~/Development/{projects,work}'
10
- #
11
- # # define developer preferences for using local or remote repositories (uses ENV['user']):
12
- # developer :sven, :prefer => :local
13
- #
14
- # # define repositories to be used for particular gems:
15
- # adva_cms = repository('adva-cms2', :git => 'git@github.com:svenfuchs/adva-cms2.git', :ref => 'c2af0de')
16
- # adva_shop = repository('adva-shop', :source => :local)
17
- #
18
- # # now use repositories to define gems:
19
- # adva_cms.gem 'adva-core'
20
- # adva_shop.gem 'adva-catalog'
21
- #
22
- # # The gem definition will now be proxied to Bundler with arguments according
23
- # # to the setup defined earlier. E.g. as:
24
- #
25
- # gem 'adva-core', :path => 'Development/projects/adva-cms2/adva-core' # for developer 'sven'
26
- # gem 'adva-core', :git => 'git@github.com:svenfuchs/adva-cms2.git', :ref => 'c2af0de' # for other developers
27
- # gem 'adva-catalog', :path => 'Development/projects/adva-shop/adva-catalog' # for all developers
28
- #
29
- # One can also set an environment variable FORCE_REMOTE which will force remote
30
- # repositories to be used *except* when a repository was defined with :source => :local
31
- # which always forces the local repository to be used.
32
- #
33
- class Repository
34
- class << self
35
- def paths
36
- @paths ||= []
37
- end
38
-
39
- def path(*paths)
40
- paths.join(' ').split(' ').each do |path|
41
- self.paths.concat(Pathname.glob(File.expand_path(path)))
42
- end
43
- end
44
-
45
- def developer(name, preferences)
46
- developers[name] = preferences
47
- workspaces(preferences[:workspace])
48
- end
49
-
50
- def current_developer
51
- developers[ENV['USER'].to_sym] || {}
52
- end
53
-
54
- def developers(developers = nil)
55
- @developers ||= {}
56
- end
57
- end
58
-
59
- class Gem < Array
60
- def initialize(name, repository)
61
- if repository.local?
62
- sub_path = repository.path.join(name)
63
- super([name, { :path => sub_path.exist? ? sub_path.to_s : repository.path.to_s }])
64
- else
65
- super([name, repository.options.dup])
66
- end
67
- end
68
- end
69
-
70
- attr_reader :bundler, :name, :options, :source
71
-
72
- def initialize(bundler, name, options)
73
- @bundler = bundler
74
- @name = name
75
- @source = options.delete(:source)
76
- @options = options
77
- end
78
-
79
- def gem(name)
80
- bundler.gem(*Gem.new(name, self))
81
- end
82
-
83
- def local?
84
- source == :local # && path
85
- end
86
-
87
- def source
88
- @source ||= forced_source || preferred_source || :remote
89
- end
90
-
91
- def forced_source
92
- :remote if ENV['FORCE_REMOTE']
93
- end
94
-
95
- def preferred_source
96
- self.class.current_developer[:prefer] || self.class.current_developer[name.to_sym]
97
- end
98
-
99
- def path
100
- @path ||= begin
101
- path = self.class.paths.detect { |path| path.join(name).exist? }
102
- path ? path.join(name) : Pathname.new('.')
103
- end
104
- end
105
- end
106
-
107
- def workspace(*paths)
108
- Repository.path(*paths)
109
- end
110
- alias :workspaces :workspace
111
-
112
- def developer(name, preferences)
113
- Repository.developer(name, preferences)
114
- end
115
-
116
- def repository(*args)
117
- Repository.new(self, *args)
118
- end