adva-blog 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/blogs_controller.rb +3 -0
- data/app/controllers/admin/posts_controller.rb +4 -0
- data/app/controllers/posts_controller.rb +20 -0
- data/app/models/blog.rb +6 -0
- data/app/models/post.rb +25 -0
- data/app/models/site_slice.rb +3 -0
- data/app/views/admin/blogs/_form.html.rb +17 -0
- data/app/views/admin/blogs/_menu.html.rb +25 -0
- data/app/views/admin/blogs/edit.html.rb +8 -0
- data/app/views/admin/blogs/new.html.rb +9 -0
- data/app/views/admin/blogs/show.html.rb +41 -0
- data/app/views/admin/categories/_menu_slice.html.rb +22 -0
- data/app/views/admin/posts/_form.html.rb +18 -0
- data/app/views/admin/posts/_menu.html.rb +10 -0
- data/app/views/admin/posts/edit.html.rb +8 -0
- data/app/views/admin/posts/index.html.rb +42 -0
- data/app/views/admin/posts/new.html.rb +8 -0
- data/app/views/posts/_meta.html.rb +13 -0
- data/app/views/posts/index.html.rb +22 -0
- data/app/views/posts/show.html.rb +11 -0
- data/config/locales/en.yml +38 -0
- data/config/redirects.rb +8 -0
- data/config/routes.rb +22 -0
- data/lib/adva/blog.rb +29 -0
- data/lib/adva-blog.rb +1 -0
- data/lib/adva_blog/version.rb +3 -0
- data/lib/testing/factories.rb +9 -0
- data/lib/testing/paths.rb +19 -0
- data/public/stylesheets/adva-blog/default/styles.css +19 -0
- metadata +33 -5
- data/lib/bundler/repository.rb +0 -118
@@ -0,0 +1,20 @@
|
|
1
|
+
class PostsController < BaseController
|
2
|
+
nested_belongs_to :blog
|
3
|
+
before_filter :set_id, :only => :show
|
4
|
+
|
5
|
+
filtered_attributes :post if Adva.engine?(:markup)
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def collection
|
10
|
+
# FIXME [reference tracking] how can we remove this?
|
11
|
+
@_references << [blog, :posts] if @_references
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_id
|
16
|
+
blog = site.blogs.find(params[:blog_id])
|
17
|
+
permalink = params[:permalink].split('/')
|
18
|
+
params[:id] = blog.posts.by_permalink(*permalink).first.try(:id)
|
19
|
+
end
|
20
|
+
end
|
data/app/models/blog.rb
ADDED
data/app/models/post.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class Post < Content
|
2
|
+
has_slug :scope => :section_id
|
3
|
+
|
4
|
+
before_validation { |r| r.published_at = Time.now.to_datetime unless r.published_at }
|
5
|
+
|
6
|
+
validates_presence_of :title
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def by_permalink(year, month, day, slug)
|
10
|
+
by_archive(year, month, day).where(:slug => slug)
|
11
|
+
end
|
12
|
+
|
13
|
+
def by_archive(*args)
|
14
|
+
where("DATE(contents.published_at) = ?", Date.new(*args.map(&:to_i)).to_formatted_s(:db))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def permalink
|
19
|
+
"#{published_at.year}/#{published_at.month}/#{published_at.day}/#{slug}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_param(name)
|
23
|
+
name == :permalink ? permalink : super()
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Admin::Blogs::Form < Adva::View::Form
|
2
|
+
include do
|
3
|
+
def fields
|
4
|
+
form.hidden_field :type
|
5
|
+
|
6
|
+
fieldset do
|
7
|
+
column do
|
8
|
+
form.input :name
|
9
|
+
end
|
10
|
+
|
11
|
+
column do
|
12
|
+
form.input :slug
|
13
|
+
end unless params[:action] == 'new'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_dependency 'admin/sections/_menu.html'
|
2
|
+
|
3
|
+
class Admin::Blogs::Menu < Admin::Sections::Menu
|
4
|
+
include do
|
5
|
+
def main
|
6
|
+
super
|
7
|
+
categories if persisted? && Adva.engine?(:categories)
|
8
|
+
end
|
9
|
+
|
10
|
+
def right
|
11
|
+
new_item if persisted?
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def show
|
18
|
+
item(:'.posts', index_path(:posts))
|
19
|
+
end
|
20
|
+
|
21
|
+
def new_item
|
22
|
+
item(:'.new_post', new_path(:post))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Admin::Blogs::Show < Minimal::Template
|
2
|
+
include do
|
3
|
+
def to_html
|
4
|
+
table_for resource.posts do |t|
|
5
|
+
t.column :post, :comments, :published, :author, :actions
|
6
|
+
|
7
|
+
t.row do |r, post|
|
8
|
+
r.cell link_to_post(post)
|
9
|
+
r.cell ''.html_safe # post.accept_comments? && post.comments.present? ? link_to(post.comments.size, admin_comments_path) : t(:"adva.common.none")
|
10
|
+
r.cell ''.html_safe # published_at_formatted(post)
|
11
|
+
r.cell link_to_author(post)
|
12
|
+
r.cell links_to_actions([:view, :edit, :destroy], post)
|
13
|
+
end
|
14
|
+
|
15
|
+
t.foot.row do |r|
|
16
|
+
# r.cell will_paginate(@posts), :class => :pagination, :colspan => :all
|
17
|
+
end
|
18
|
+
|
19
|
+
t.empty :p, :class => 'posts list empty' do
|
20
|
+
self.t(:'.empty', :link => capture { link_to(:'.create_item', new_path(:post)) }).html_safe
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def link_to_post(post)
|
26
|
+
status(post) + capture { link_to_edit(post.title, post) } # , :class => post.state
|
27
|
+
end
|
28
|
+
|
29
|
+
def link_to_author(post)
|
30
|
+
''.html_safe # link_to(post.author_name, admin_site_user_path(@site, post.author))
|
31
|
+
end
|
32
|
+
|
33
|
+
def link_to_view(post)
|
34
|
+
capture { link_to(options[:text] || :'.view', public_url_for([post.section, post]), :class => :view) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def status(post)
|
38
|
+
capture { span(t(:'.published'), :title => t(:'.published'), :class => 'status published') }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_dependency 'admin/categories/_menu.html'
|
2
|
+
|
3
|
+
Admin::Categories::Menu.class_eval do
|
4
|
+
include do
|
5
|
+
def main
|
6
|
+
super
|
7
|
+
posts if blog?
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def posts
|
13
|
+
item(:'.posts', index_parent_path(:posts), :before => :'.categories')
|
14
|
+
end
|
15
|
+
|
16
|
+
def blog?
|
17
|
+
resource.section.is_a?(Blog)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Admin::Posts::Form < Adva::View::Form
|
2
|
+
include do
|
3
|
+
def fields
|
4
|
+
fieldset do
|
5
|
+
form.input :title
|
6
|
+
form.input :body
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def sidebar
|
11
|
+
categories_tab(blog.categories) if Adva.engine?(:categories)
|
12
|
+
|
13
|
+
tab :options do
|
14
|
+
form.input :slug
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Admin::Posts::Index < Minimal::Template
|
2
|
+
include do
|
3
|
+
def to_html
|
4
|
+
table_for collection do |t|
|
5
|
+
t.column :post, :comments, :published, :author, :actions
|
6
|
+
|
7
|
+
t.row do |r, post|
|
8
|
+
r.cell link_to_post(post)
|
9
|
+
r.cell ''.html_safe # post.accept_comments? && post.comments.present? ? link_to(post.comments.size, admin_comments_path) : t(:"adva.common.none")
|
10
|
+
r.cell ''.html_safe # published_at_formatted(post)
|
11
|
+
r.cell link_to_author(post)
|
12
|
+
r.cell links_to_actions([:view, :edit, :destroy], post)
|
13
|
+
end
|
14
|
+
|
15
|
+
t.foot.row do |r|
|
16
|
+
# r.cell will_paginate(@posts), :class => :pagination, :colspan => :all
|
17
|
+
end
|
18
|
+
|
19
|
+
t.empty :p, :class => 'posts list empty' do
|
20
|
+
self.t(:'.empty', :link => capture { link_to(:'.create_item', new_path) }).html_safe
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def link_to_post(post)
|
26
|
+
status(post) + capture { link_to_edit(post.title, post) } # , :class => post.state
|
27
|
+
end
|
28
|
+
|
29
|
+
def link_to_author(post)
|
30
|
+
''.html_safe # link_to(post.author_name, admin_site_user_path(@site, post.author))
|
31
|
+
end
|
32
|
+
|
33
|
+
def link_to_view(post)
|
34
|
+
capture { link_to(options[:text] || :'.actions.view', public_url_for([blog, post]), :class => :view) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def status(post)
|
38
|
+
capture { span(t(:'.status.published'), :title => t(:'.status.published'), :class => 'status published') }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Posts::Meta < Minimal::Template
|
2
|
+
include do
|
3
|
+
def to_html
|
4
|
+
div :class => :meta do
|
5
|
+
self << t(:'.info_html', :date => published_at, :author => nil)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def published_at
|
10
|
+
capture { content_tag(:abbr, l(post.published_at, :format => :post), :title => post.published_at, :class => 'updated') }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Posts::Index < Minimal::Template
|
2
|
+
include do
|
3
|
+
def to_html
|
4
|
+
ul :class => 'blog posts' do
|
5
|
+
collection.each do |post|
|
6
|
+
li :class => 'post hentry' do
|
7
|
+
h2 do
|
8
|
+
link_to(post.title, [post.section, post], :class => 'entry-title', :rel => 'bookmark')
|
9
|
+
end
|
10
|
+
render :partial => 'posts/meta', :locals => { :post => post }
|
11
|
+
div truncate_html(post.body, :length => 500, :omission => ' …'), :class => 'entry-content'
|
12
|
+
p do
|
13
|
+
link_to(:'.continue', [post.section, post], :class => :continue)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Posts::Show < Minimal::Template
|
2
|
+
include do
|
3
|
+
def to_html
|
4
|
+
div :class => resource.class.name.underscore do
|
5
|
+
h2 { link_to(resource.title, resources, :class => 'entry-title', :rel => 'bookmark') }
|
6
|
+
render :partial => 'posts/meta', :locals => { :post => resource }
|
7
|
+
self << resource.body.html_safe
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
en:
|
2
|
+
time:
|
3
|
+
formats:
|
4
|
+
post: "%a, %d %b %Y"
|
5
|
+
|
6
|
+
section:
|
7
|
+
types:
|
8
|
+
blog: Blog
|
9
|
+
|
10
|
+
menu:
|
11
|
+
posts: Posts
|
12
|
+
new_post: New Post
|
13
|
+
|
14
|
+
columns:
|
15
|
+
post: Post
|
16
|
+
comments: Comments
|
17
|
+
|
18
|
+
posts:
|
19
|
+
index:
|
20
|
+
continue: Read the rest of this post
|
21
|
+
meta:
|
22
|
+
info_html: "posted on %{date}"
|
23
|
+
|
24
|
+
admin:
|
25
|
+
blogs:
|
26
|
+
new:
|
27
|
+
title: Create a New Section
|
28
|
+
edit:
|
29
|
+
title: Settings
|
30
|
+
posts:
|
31
|
+
index:
|
32
|
+
empty: "There are no posts. %{link}"
|
33
|
+
create_item: "Create one now »"
|
34
|
+
new:
|
35
|
+
title: Write a new blog post
|
36
|
+
edit:
|
37
|
+
title: Edit Post
|
38
|
+
delete: Delete
|
data/config/redirects.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Adva::Registry.set :redirect, {
|
2
|
+
'admin/blogs#create' => lambda { |c| c.index_path(:posts) },
|
3
|
+
'admin/blogs#update' => lambda { |c| c.edit_url },
|
4
|
+
|
5
|
+
'admin/posts#create' => lambda { |c| c.edit_url },
|
6
|
+
'admin/posts#update' => lambda { |c| c.edit_url },
|
7
|
+
'admin/posts#destroy' => lambda { |c| c.index_url }
|
8
|
+
}
|
data/config/routes.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
# overwrite admin/blog#show to point to admin/posts#index instead
|
3
|
+
# can this be simplified? haven't had any luck putting it into the resource block
|
4
|
+
get 'admin/sites/:site_id/blogs/:blog_id', :to => 'admin/posts#index', :as => 'admin_site_blog'
|
5
|
+
|
6
|
+
namespace :admin do
|
7
|
+
resources :sites do
|
8
|
+
resources :blogs do
|
9
|
+
resources :posts
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
constraints :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/ do
|
15
|
+
get 'blogs/:blog_id(/:year(/:month(/:day)))', :to => 'posts#index', :as => :blog
|
16
|
+
end
|
17
|
+
|
18
|
+
constraints :permalink => %r(\d{4}/\d{1,2}/\d{1,2}/w+) do
|
19
|
+
get 'blogs/:blog_id/*permalink.:format', :to => "posts#show"
|
20
|
+
get 'blogs/:blog_id/*permalink', :to => "posts#show", :as => :blog_post
|
21
|
+
end
|
22
|
+
end
|
data/lib/adva/blog.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'adva/core'
|
2
|
+
require 'adva/engine'
|
3
|
+
|
4
|
+
require 'routing_filter'
|
5
|
+
require 'adva/routing_filters/section_root'
|
6
|
+
|
7
|
+
require 'action_controller' # really should be in truncate_html
|
8
|
+
require 'truncate_html'
|
9
|
+
|
10
|
+
module Adva
|
11
|
+
class Blog < ::Rails::Engine
|
12
|
+
include Adva::Engine
|
13
|
+
|
14
|
+
initializer 'adva-blog.require_section_types' do
|
15
|
+
config.to_prepare { require_dependency 'blog' }
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer 'adva-blog.configure_routing_filters' do
|
19
|
+
RoutingFilter::SectionRoot.anchors << '\d{4}'
|
20
|
+
end
|
21
|
+
|
22
|
+
initializer 'adva-blog.register_asset_expansions' do
|
23
|
+
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion(
|
24
|
+
:default => %w( adva-blog/default/styles )
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
data/lib/adva-blog.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'adva/blog'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Adva::Blog::Paths
|
2
|
+
def path_to(page)
|
3
|
+
case page
|
4
|
+
|
5
|
+
when /^the admin posts list page of the "([^"]*)" blog$/
|
6
|
+
section = Blog.find_by_name($1) || raise("could not find blog #{$1.inspect}")
|
7
|
+
polymorphic_path([:admin, section.site, section])
|
8
|
+
|
9
|
+
when /^the admin edit post page for the post "([^"]*)"$/
|
10
|
+
post = Post.find_by_title($1) || raise("could not find post #{$1.inspect}")
|
11
|
+
polymorphic_path([:edit, :admin, post.section.site, post.section, post])
|
12
|
+
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
World(Adva::Blog::Paths)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
.posts {
|
2
|
+
padding-top: 0;
|
3
|
+
margin-left: 0;
|
4
|
+
list-style-type: none;
|
5
|
+
}
|
6
|
+
.post {
|
7
|
+
padding-bottom: 1em;
|
8
|
+
}
|
9
|
+
.meta {
|
10
|
+
font-size: 10pt;
|
11
|
+
color: #999;
|
12
|
+
}
|
13
|
+
.continue {
|
14
|
+
font-size: 10pt;
|
15
|
+
}
|
16
|
+
.continue:after {
|
17
|
+
content: " \2192";
|
18
|
+
}
|
19
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adva-blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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-
|
19
|
+
date: 2010-12-03 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -56,7 +56,35 @@ extensions: []
|
|
56
56
|
extra_rdoc_files: []
|
57
57
|
|
58
58
|
files:
|
59
|
-
-
|
59
|
+
- app/controllers/posts_controller.rb
|
60
|
+
- app/controllers/admin/blogs_controller.rb
|
61
|
+
- app/controllers/admin/posts_controller.rb
|
62
|
+
- app/views/admin/categories/_menu_slice.html.rb
|
63
|
+
- app/views/admin/blogs/show.html.rb
|
64
|
+
- app/views/admin/blogs/edit.html.rb
|
65
|
+
- app/views/admin/blogs/new.html.rb
|
66
|
+
- app/views/admin/blogs/_form.html.rb
|
67
|
+
- app/views/admin/blogs/_menu.html.rb
|
68
|
+
- app/views/admin/posts/index.html.rb
|
69
|
+
- app/views/admin/posts/edit.html.rb
|
70
|
+
- app/views/admin/posts/new.html.rb
|
71
|
+
- app/views/admin/posts/_form.html.rb
|
72
|
+
- app/views/admin/posts/_menu.html.rb
|
73
|
+
- app/views/posts/index.html.rb
|
74
|
+
- app/views/posts/show.html.rb
|
75
|
+
- app/views/posts/_meta.html.rb
|
76
|
+
- app/models/post.rb
|
77
|
+
- app/models/site_slice.rb
|
78
|
+
- app/models/blog.rb
|
79
|
+
- config/redirects.rb
|
80
|
+
- config/routes.rb
|
81
|
+
- config/locales/en.yml
|
82
|
+
- lib/adva_blog/version.rb
|
83
|
+
- lib/adva/blog.rb
|
84
|
+
- lib/testing/factories.rb
|
85
|
+
- lib/testing/paths.rb
|
86
|
+
- lib/adva-blog.rb
|
87
|
+
- public/stylesheets/adva-blog/default/styles.css
|
60
88
|
has_rdoc: true
|
61
89
|
homepage: http://github.com/svenfuchs/adva-cms2
|
62
90
|
licenses: []
|
data/lib/bundler/repository.rb
DELETED
@@ -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
|