quirkey-gembox 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +41 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +48 -0
- data/VERSION.yml +4 -0
- data/bin/gembox +10 -0
- data/lib/extensions.rb +21 -0
- data/lib/gembox/app.rb +65 -0
- data/lib/gembox/gem_list.rb +41 -0
- data/lib/gembox/gems.rb +42 -0
- data/lib/gembox/view_helpers.rb +69 -0
- data/lib/gembox.rb +13 -0
- data/test/test_gembox_app.rb +133 -0
- data/test/test_gembox_gems.rb +61 -0
- data/test/test_helper.rb +56 -0
- metadata +98 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
bin/gembox
|
7
|
+
config.ru
|
8
|
+
gembox.rb
|
9
|
+
lib/extensions.rb
|
10
|
+
lib/gembox.rb
|
11
|
+
lib/gembox/cli.rb
|
12
|
+
lib/gembox_.rb
|
13
|
+
public/images/edit.png
|
14
|
+
public/images/folder.png
|
15
|
+
public/images/git.gif
|
16
|
+
public/images/page.png
|
17
|
+
public/images/page_white_text.png
|
18
|
+
public/images/rubygems-125x125t.png
|
19
|
+
public/javascripts/base.js
|
20
|
+
public/javascripts/jquery.form.js
|
21
|
+
public/javascripts/jquery.js
|
22
|
+
public/javascripts/jquery.metadata.js
|
23
|
+
public/javascripts/jquery.ui.js
|
24
|
+
public/swf/clippy.swf
|
25
|
+
script/console
|
26
|
+
script/destroy
|
27
|
+
script/generate
|
28
|
+
test/test_gembox.rb
|
29
|
+
test/test_gembox_app.rb
|
30
|
+
test/test_gembox_cli.rb
|
31
|
+
test/test_gembox_gems.rb
|
32
|
+
test/test_helper.rb
|
33
|
+
views/file_tree.haml
|
34
|
+
views/gem.haml
|
35
|
+
views/gembox.sass
|
36
|
+
views/gems_columns.haml
|
37
|
+
views/gems_header.haml
|
38
|
+
views/gems_table.haml
|
39
|
+
views/index.haml
|
40
|
+
views/layout.haml
|
41
|
+
views/no_results.haml
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= gembox
|
2
|
+
|
3
|
+
* FIX (url)
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIX (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIX (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIX (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIX (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIX (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2009 FIXME full name
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION.yml
ADDED
data/bin/gembox
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Created on 2009-2-27.
|
4
|
+
# Copyright (c) 2009. All rights reserved.
|
5
|
+
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/gembox")
|
7
|
+
|
8
|
+
Gembox::App.set :environment, :production
|
9
|
+
Gembox::App.set :port, 5678
|
10
|
+
Gembox::App.run!
|
data/lib/extensions.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Gem
|
2
|
+
class Specification
|
3
|
+
|
4
|
+
def files_tree
|
5
|
+
tree = {}
|
6
|
+
files.each do |file|
|
7
|
+
split_dirs = file.split(/\//)
|
8
|
+
keyed_hash = {}
|
9
|
+
split_dirs.reverse.each do |key|
|
10
|
+
keyed_hash = {key => keyed_hash}
|
11
|
+
end
|
12
|
+
tree.deep_merge!(keyed_hash)
|
13
|
+
end
|
14
|
+
tree
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_github?
|
18
|
+
homepage =~ /github\.com\/([\w\d\-\_]+)\/([\w\d\-\_]+)\/tree/
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/gembox/app.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
|
3
|
+
module Gembox
|
4
|
+
class App < ::Sinatra::Default
|
5
|
+
include Gembox::ViewHelpers
|
6
|
+
include WillPaginate::ViewHelpers
|
7
|
+
|
8
|
+
|
9
|
+
set :public, 'public'
|
10
|
+
set :views, 'views'
|
11
|
+
|
12
|
+
before do
|
13
|
+
Gembox::Gems.load
|
14
|
+
@gems = Gembox::Gems.local_gems.paginate :page => params[:page], :per_page => 30
|
15
|
+
@stats = Gembox::Gems.stats
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/stylesheets/:stylesheet.css' do
|
19
|
+
sass params[:stylesheet].to_sym
|
20
|
+
end
|
21
|
+
|
22
|
+
get '/' do
|
23
|
+
redirect '/gems'
|
24
|
+
end
|
25
|
+
|
26
|
+
get %r{/gems/([\w\-\_]+)/?([\d\.]+)?/?} do
|
27
|
+
show_layout = params[:layout] != 'false'
|
28
|
+
name, version = params[:captures]
|
29
|
+
@gems = Gembox::Gems.search(name)
|
30
|
+
raise Sinatra::NotFound if @gems.empty?
|
31
|
+
@gem_versions = @gems[0][1]
|
32
|
+
if version
|
33
|
+
@gems = Gembox::Gems.search(name, version)
|
34
|
+
@gem = @gems.shift[1].first if @gems
|
35
|
+
end
|
36
|
+
if !@gem
|
37
|
+
@gem = @gem_versions.shift
|
38
|
+
redirect "/gems/#{@gem.name}/#{@gem.version}"
|
39
|
+
end
|
40
|
+
if params[:file]
|
41
|
+
action = params[:action] || view
|
42
|
+
file_path = File.join(@gem.full_gem_path, params[:file])
|
43
|
+
if File.readable?(file_path)
|
44
|
+
if action == 'edit'
|
45
|
+
`$EDITOR #{file_path}`
|
46
|
+
else
|
47
|
+
response.headers['Content-type'] = 'text/plain'
|
48
|
+
return File.read(file_path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
haml :gem, :layout => show_layout
|
53
|
+
end
|
54
|
+
|
55
|
+
get '/gems/?' do
|
56
|
+
show_layout = params[:layout] != 'false'
|
57
|
+
@show_as = params[:as] || 'columns'
|
58
|
+
if @search = params[:search]
|
59
|
+
@gems = Gembox::Gems.search(@search).paginate :page => params[:page]
|
60
|
+
end
|
61
|
+
haml "gems_#{@show_as}".to_sym, :layout => show_layout
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Gembox
|
2
|
+
|
3
|
+
class GemList < Array
|
4
|
+
|
5
|
+
def [](*args)
|
6
|
+
if args.first.is_a?(String)
|
7
|
+
search(args.first)
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def []=(key, value)
|
14
|
+
if key.is_a?(String)
|
15
|
+
if versions = search(key)
|
16
|
+
versions.replace([key, value])
|
17
|
+
else
|
18
|
+
self << [key, value]
|
19
|
+
end
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def search(key)
|
26
|
+
i = find {|v|
|
27
|
+
if v.is_a?(Array)
|
28
|
+
v[0] == key
|
29
|
+
else
|
30
|
+
v == key
|
31
|
+
end
|
32
|
+
}
|
33
|
+
i.is_a?(Array) ? i[1] : i
|
34
|
+
end
|
35
|
+
|
36
|
+
def has_key?(key)
|
37
|
+
!search(key).nil?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/lib/gembox/gems.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Gembox
|
2
|
+
class Gems
|
3
|
+
class << self
|
4
|
+
attr_accessor :source_index
|
5
|
+
|
6
|
+
def load
|
7
|
+
@source_index ||= ::Gem.source_index
|
8
|
+
local_gems
|
9
|
+
end
|
10
|
+
|
11
|
+
def local_gems
|
12
|
+
@local_gems ||= group_gems(source_index.gems)
|
13
|
+
end
|
14
|
+
|
15
|
+
def search(search_term, version = nil)
|
16
|
+
version = version ? Gem::Requirement.create(version) : Gem::Requirement.default
|
17
|
+
gems = source_index.search Gem::Dependency.new(/#{Regexp.escape(search_term)}/, version)
|
18
|
+
group_gems(gems)
|
19
|
+
end
|
20
|
+
|
21
|
+
def stats
|
22
|
+
num_versions = source_index.length
|
23
|
+
num_gems = local_gems.length
|
24
|
+
oldest_gem = source_index.min {|a,b| a[1].date <=> b[1].date }.last
|
25
|
+
{:num_versions => num_versions, :num_gems => num_gems, :oldest_gem => oldest_gem}
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
def group_gems(gem_collection)
|
30
|
+
gem_hash = GemList.new
|
31
|
+
gem_collection = gem_collection.values if gem_collection.is_a?(Hash)
|
32
|
+
gem_collection.each do |spec|
|
33
|
+
gem_hash[spec.name] ||= []
|
34
|
+
gem_hash[spec.name] << spec
|
35
|
+
gem_hash[spec.name].sort! {|a,b| (b.version || 0) <=> (a.version || 0) }
|
36
|
+
end
|
37
|
+
gem_hash.sort {|a, b| a[0].downcase <=> b[0].downcase }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Gembox
|
2
|
+
module ViewHelpers
|
3
|
+
|
4
|
+
def tag_options(options, escape = true)
|
5
|
+
option_string = options.collect {|k,v| %{#{k}="#{v}"}}.join(' ')
|
6
|
+
option_string = " " + option_string unless option_string.blank?
|
7
|
+
end
|
8
|
+
|
9
|
+
def content_tag(name, content, options, escape = true)
|
10
|
+
tag_options = tag_options(options, escape) if options
|
11
|
+
"<#{name}#{tag_options}>#{content}</#{name}>"
|
12
|
+
end
|
13
|
+
|
14
|
+
def link_to(text, link = nil, options = {})
|
15
|
+
link ||= text
|
16
|
+
link = url_for(link)
|
17
|
+
"<a href=\"#{link}\">#{text}</a>"
|
18
|
+
end
|
19
|
+
|
20
|
+
def link_to_gem(gem, options = {})
|
21
|
+
text = options[:text] || gem.name
|
22
|
+
version = gem.version if options[:show_version]
|
23
|
+
link_to(text, "/gems/#{gem.name}/#{gem.version}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def url_for(link_options)
|
27
|
+
case link_options
|
28
|
+
when Hash
|
29
|
+
path = link_options.delete(:path) || request.path_info
|
30
|
+
params.delete('captures')
|
31
|
+
path + '?' + build_query(params.merge(link_options))
|
32
|
+
else
|
33
|
+
link_options
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def ts(time)
|
38
|
+
time.strftime('%b %d, %Y') if time
|
39
|
+
end
|
40
|
+
|
41
|
+
def clippy(text, bgcolor='#FFFFFF')
|
42
|
+
html = <<-EOF
|
43
|
+
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
|
44
|
+
width="110"
|
45
|
+
height="14"
|
46
|
+
id="clippy" >
|
47
|
+
<param name="movie" value="/swf/clippy.swf"/>
|
48
|
+
<param name="allowScriptAccess" value="always" />
|
49
|
+
<param name="quality" value="high" />
|
50
|
+
<param name="scale" value="noscale" />
|
51
|
+
<param NAME="FlashVars" value="text=#{text}">
|
52
|
+
<param name="bgcolor" value="#{bgcolor}">
|
53
|
+
<embed src="/swf/clippy.swf"
|
54
|
+
width="110"
|
55
|
+
height="14"
|
56
|
+
name="clippy"
|
57
|
+
quality="high"
|
58
|
+
allowScriptAccess="always"
|
59
|
+
type="application/x-shockwave-flash"
|
60
|
+
pluginspage="http://www.macromedia.com/go/getflashplayer"
|
61
|
+
FlashVars="text=#{text}"
|
62
|
+
bgcolor="#{bgcolor}"
|
63
|
+
/>
|
64
|
+
</object>
|
65
|
+
EOF
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
data/lib/gembox.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'active_support'
|
6
|
+
require 'will_paginate/array'
|
7
|
+
require 'will_paginate/view_helpers'
|
8
|
+
|
9
|
+
require 'extensions'
|
10
|
+
require 'gembox/gem_list'
|
11
|
+
require 'gembox/gems'
|
12
|
+
require 'gembox/view_helpers'
|
13
|
+
require 'gembox/app'
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
describe "Gembox App" do
|
4
|
+
|
5
|
+
describe 'getting index' do
|
6
|
+
before do
|
7
|
+
get '/'
|
8
|
+
end
|
9
|
+
|
10
|
+
should "redirect to /gems" do
|
11
|
+
should.be.redirect
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'getting gems' do
|
17
|
+
before do
|
18
|
+
get '/gems'
|
19
|
+
end
|
20
|
+
|
21
|
+
should 'load the index' do
|
22
|
+
should.be.ok
|
23
|
+
end
|
24
|
+
|
25
|
+
should "display gem list" do
|
26
|
+
body.should have_element('div#gems')
|
27
|
+
end
|
28
|
+
|
29
|
+
should "display list of installed gems" do
|
30
|
+
body.should have_element('.gem')
|
31
|
+
end
|
32
|
+
|
33
|
+
should "display as 4 columns" do
|
34
|
+
body.should have_element('.column')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'getting gems/ with layout = false' do
|
39
|
+
before do
|
40
|
+
get '/gems/?layout=false'
|
41
|
+
end
|
42
|
+
|
43
|
+
should "load" do
|
44
|
+
should.be.ok
|
45
|
+
end
|
46
|
+
|
47
|
+
should "not display layout" do
|
48
|
+
body.should.not have_element('html')
|
49
|
+
end
|
50
|
+
|
51
|
+
should "display gem list" do
|
52
|
+
html_body.should have_element('#gems')
|
53
|
+
end
|
54
|
+
|
55
|
+
should "display as 4 columns" do
|
56
|
+
html_body.should have_element('.column')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'getting gems/ with a simple search' do
|
61
|
+
before do
|
62
|
+
get '/gems/?search=s'
|
63
|
+
end
|
64
|
+
|
65
|
+
should "load" do
|
66
|
+
should.be.ok
|
67
|
+
end
|
68
|
+
|
69
|
+
should "display gem list" do
|
70
|
+
body.should have_element('#gems')
|
71
|
+
end
|
72
|
+
|
73
|
+
should "display gems that match the search" do
|
74
|
+
body.should have_element('.gem', /sinatra/)
|
75
|
+
end
|
76
|
+
|
77
|
+
should "not display gems that do not match the search" do
|
78
|
+
body.should.not have_element('.gem', /rack/)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'getting gems/ with as = table' do
|
83
|
+
before do
|
84
|
+
get '/gems/?layout=false&as=table'
|
85
|
+
end
|
86
|
+
|
87
|
+
should "load" do
|
88
|
+
should.be.ok
|
89
|
+
end
|
90
|
+
|
91
|
+
should "not display layout" do
|
92
|
+
body.should.not have_element('html')
|
93
|
+
end
|
94
|
+
|
95
|
+
should "display as table" do
|
96
|
+
html_body.should have_element('table#gems')
|
97
|
+
html_body.should have_element('table#gems tr.gem')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'getting gems/:name' do
|
102
|
+
before do
|
103
|
+
get '/gems/sinatra'
|
104
|
+
end
|
105
|
+
|
106
|
+
should "redirect to most recent version" do
|
107
|
+
status.should.be.equal 302
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'getting gems/name/version' do
|
112
|
+
before do
|
113
|
+
get '/gems/sinatra/0.9.0.4'
|
114
|
+
end
|
115
|
+
|
116
|
+
should "display dependencies" do
|
117
|
+
body.should have_element('#dependencies .gem', /rack/)
|
118
|
+
end
|
119
|
+
|
120
|
+
should "display link to gems website" do
|
121
|
+
body.should have_element('a', 'http://sinatra.rubyforge.org')
|
122
|
+
end
|
123
|
+
|
124
|
+
should "load gem spec specified version" do
|
125
|
+
body.should have_element('.version', '0.9.0.4')
|
126
|
+
end
|
127
|
+
|
128
|
+
should "display links to all versions" do
|
129
|
+
body.should have_element('#versions a')
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
describe 'Gembox::Gems' do
|
4
|
+
|
5
|
+
describe '#load' do
|
6
|
+
before do
|
7
|
+
Gembox::Gems.load
|
8
|
+
end
|
9
|
+
|
10
|
+
should "load local gems" do
|
11
|
+
Gembox::Gems.local_gems.should.be.an instance_of(Array)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "load source index into source_index" do
|
15
|
+
Gembox::Gems.source_index.should.be.an instance_of(Gem::SourceIndex)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#local_gems" do
|
20
|
+
before do
|
21
|
+
Gembox::Gems.load
|
22
|
+
@gems = Gembox::Gems.local_gems
|
23
|
+
end
|
24
|
+
|
25
|
+
should "return array of array of gems" do
|
26
|
+
@gems.should.be.an instance_of(Gembox::GemList)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "only have one entry per gem" do
|
30
|
+
@gems.should.has_key? 'sinatra'
|
31
|
+
@gems.should.not.has_key? 'sinatra-0.9.0.5'
|
32
|
+
end
|
33
|
+
|
34
|
+
should "have an array of spec versions per gem name" do
|
35
|
+
@gems['sinatra'].should.be.an instance_of(Array)
|
36
|
+
@gems['sinatra'].first.should.be.an instance_of(Gem::Specification)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#search' do
|
41
|
+
before do
|
42
|
+
Gembox::Gems.load
|
43
|
+
@gems = Gembox::Gems.search 'sin'
|
44
|
+
end
|
45
|
+
|
46
|
+
should "return a list of gem specs" do
|
47
|
+
@gems.should.be.an instance_of(Gembox::GemList)
|
48
|
+
end
|
49
|
+
|
50
|
+
should "only have one entry per gem" do
|
51
|
+
@gems.should.has_key? 'sinatra'
|
52
|
+
@gems.should.not.has_key? 'sinatra-0.9.0.5'
|
53
|
+
end
|
54
|
+
|
55
|
+
should "return gems that match the specname" do
|
56
|
+
@gems.should.not.has_key? 'rack'
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra'
|
3
|
+
require 'sinatra/test/bacon'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
require File.join(File.dirname(__FILE__), '..', 'gembox.rb')
|
7
|
+
|
8
|
+
require 'nokogiri'
|
9
|
+
|
10
|
+
|
11
|
+
module TestHelper
|
12
|
+
|
13
|
+
def instance_of(klass)
|
14
|
+
lambda {|obj| obj.is_a?(klass) }
|
15
|
+
end
|
16
|
+
|
17
|
+
# HTML matcher for bacon
|
18
|
+
#
|
19
|
+
# it 'should display document' do
|
20
|
+
# body.should have_element('#document')
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# With content matching:
|
24
|
+
#
|
25
|
+
# it 'should display loaded document' do
|
26
|
+
# body.should have_element('#document .title', /My Document/)
|
27
|
+
# end
|
28
|
+
def have_element(search, content = nil)
|
29
|
+
lambda do |obj|
|
30
|
+
doc = Nokogiri.parse(obj.to_s)
|
31
|
+
node_set = doc.search(search)
|
32
|
+
if node_set.empty?
|
33
|
+
false
|
34
|
+
else
|
35
|
+
collected_content = node_set.collect {|t| t.content }.join(' ')
|
36
|
+
case content
|
37
|
+
when Regexp
|
38
|
+
collected_content =~ content
|
39
|
+
when String
|
40
|
+
collected_content.include?(content)
|
41
|
+
when nil
|
42
|
+
true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def html_body
|
49
|
+
body =~ /^\<html/ ? body : "<html><body>#{body}</body></html>"
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
Bacon::Context.send(:include, TestHelper)
|
56
|
+
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quirkey-gembox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Quint
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-27 00:00:00 -08:00
|
13
|
+
default_executable: gembox
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rubygems
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.3.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activesupport
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.2
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: mislav-will_paginate
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.3.7
|
44
|
+
version:
|
45
|
+
description: A sinatra based interface for browsing and admiring your gems
|
46
|
+
email: aaron@quirkey.com
|
47
|
+
executables:
|
48
|
+
- gembox
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files: []
|
52
|
+
|
53
|
+
files:
|
54
|
+
- History.txt
|
55
|
+
- Manifest.txt
|
56
|
+
- PostInstall.txt
|
57
|
+
- README.rdoc
|
58
|
+
- VERSION.yml
|
59
|
+
- bin/gembox
|
60
|
+
- lib/extensions.rb
|
61
|
+
- lib/gembox
|
62
|
+
- lib/gembox/app.rb
|
63
|
+
- lib/gembox/gem_list.rb
|
64
|
+
- lib/gembox/gems.rb
|
65
|
+
- lib/gembox/view_helpers.rb
|
66
|
+
- lib/gembox.rb
|
67
|
+
- test/test_gembox_app.rb
|
68
|
+
- test/test_gembox_gems.rb
|
69
|
+
- test/test_helper.rb
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: http://github.com/quirkey/gembox
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options:
|
74
|
+
- --inline-source
|
75
|
+
- --charset=UTF-8
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
version:
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
version:
|
90
|
+
requirements: []
|
91
|
+
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.2.0
|
94
|
+
signing_key:
|
95
|
+
specification_version: 2
|
96
|
+
summary: A sinatra based interface for browsing and admiring your gems.
|
97
|
+
test_files: []
|
98
|
+
|