cans 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cans (0.1.1)
5
+ haml (~> 3.0.22)
6
+ method_extensions (~> 0.0.8)
7
+ sinatra (~> 1.1.0)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ coderay (0.9.3)
13
+ haml (3.0.23)
14
+ method_extensions (0.0.8)
15
+ coderay (= 0.9.3)
16
+ mocha (0.9.9)
17
+ rake
18
+ rack (1.2.1)
19
+ rack-test (0.5.6)
20
+ rack (>= 1.0)
21
+ rake (0.8.7)
22
+ shoulda (2.11.3)
23
+ sinatra (1.1.0)
24
+ rack (~> 1.1)
25
+ tilt (~> 1.1)
26
+ tilt (1.1)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ cans!
33
+ haml (~> 3.0.22)
34
+ method_extensions (~> 0.0.8)
35
+ mocha (~> 0.9.9)
36
+ rack-test (~> 0.5.6)
37
+ shoulda (~> 2.11.3)
38
+ sinatra (~> 1.1.0)
data/Rakefile CHANGED
@@ -17,6 +17,7 @@ begin
17
17
 
18
18
  gem.add_development_dependency "shoulda", "~> 2.11.3"
19
19
  gem.add_development_dependency 'rack-test', '~> 0.5.6'
20
+ gem.add_development_dependency 'mocha', '~> 0.9.9'
20
21
 
21
22
  gem.required_ruby_version = '~> 1.9.2'
22
23
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/cans.gemspec ADDED
@@ -0,0 +1,87 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{cans}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Bryce Kerley"]
12
+ s.date = %q{2010-11-12}
13
+ s.description = %q{Interactive on-line source browser for rack applications}
14
+ s.email = %q{bkerley@brycekerley.net}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "cans.gemspec",
29
+ "config.ru",
30
+ "lib/cans.rb",
31
+ "lib/cans/address.rb",
32
+ "lib/cans/application.rb",
33
+ "lib/cans/historian.rb",
34
+ "lib/cans/views/index.haml",
35
+ "lib/cans/views/method.haml",
36
+ "lib/cans/views/module.haml",
37
+ "test/fixtures/beverage.rb",
38
+ "test/helper.rb",
39
+ "test/test_address.rb",
40
+ "test/test_application.rb",
41
+ "test/test_cans.rb",
42
+ "test/test_historian.rb"
43
+ ]
44
+ s.homepage = %q{http://github.com/bkerley/cans}
45
+ s.rdoc_options = ["--charset=UTF-8"]
46
+ s.require_paths = ["lib"]
47
+ s.required_ruby_version = Gem::Requirement.new("~> 1.9.2")
48
+ s.rubygems_version = %q{1.3.7}
49
+ s.summary = %q{Source browser for Rack applications}
50
+ s.test_files = [
51
+ "test/fixtures/beverage.rb",
52
+ "test/helper.rb",
53
+ "test/test_address.rb",
54
+ "test/test_application.rb",
55
+ "test/test_cans.rb",
56
+ "test/test_historian.rb"
57
+ ]
58
+
59
+ if s.respond_to? :specification_version then
60
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
+ s.add_runtime_dependency(%q<sinatra>, ["~> 1.1.0"])
65
+ s.add_runtime_dependency(%q<haml>, ["~> 3.0.22"])
66
+ s.add_runtime_dependency(%q<method_extensions>, ["~> 0.0.8"])
67
+ s.add_development_dependency(%q<shoulda>, ["~> 2.11.3"])
68
+ s.add_development_dependency(%q<rack-test>, ["~> 0.5.6"])
69
+ s.add_development_dependency(%q<mocha>, ["~> 0.9.9"])
70
+ else
71
+ s.add_dependency(%q<sinatra>, ["~> 1.1.0"])
72
+ s.add_dependency(%q<haml>, ["~> 3.0.22"])
73
+ s.add_dependency(%q<method_extensions>, ["~> 0.0.8"])
74
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
75
+ s.add_dependency(%q<rack-test>, ["~> 0.5.6"])
76
+ s.add_dependency(%q<mocha>, ["~> 0.9.9"])
77
+ end
78
+ else
79
+ s.add_dependency(%q<sinatra>, ["~> 1.1.0"])
80
+ s.add_dependency(%q<haml>, ["~> 3.0.22"])
81
+ s.add_dependency(%q<method_extensions>, ["~> 0.0.8"])
82
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
83
+ s.add_dependency(%q<rack-test>, ["~> 0.5.6"])
84
+ s.add_dependency(%q<mocha>, ["~> 0.9.9"])
85
+ end
86
+ end
87
+
data/lib/cans.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  require g
3
3
  end
4
4
 
5
- %w{ address application }.each do |f|
5
+ %w{ address application historian }.each do |f|
6
6
  require File.join(File.dirname(__FILE__), 'cans', f)
7
7
  end
8
8
 
@@ -1,6 +1,6 @@
1
1
  module Cans
2
2
  class Application < Sinatra::Base
3
- set :views, File.dirname(__FILE__) + '/views'
3
+ set :views, File.dirname(__FILE__) + '/views'
4
4
 
5
5
  get '/' do
6
6
  @constants = Object.constants
@@ -20,6 +20,7 @@ module Cans
20
20
 
21
21
  @ancestors = @module.ancestors
22
22
  @child_modules = @module.constants.map{ |c| @module.const_get c}.select{ |c| c.kind_of? Module}.sort_by(&:name)
23
+
23
24
  haml :module
24
25
  end
25
26
 
@@ -29,5 +30,18 @@ module Cans
29
30
  @method = @address.target_method
30
31
  haml :method
31
32
  end
33
+
34
+ before do
35
+ @historian ||= Historian.new
36
+ @historian.delve
37
+ end
38
+
39
+ helpers do
40
+ def link(destination, content)
41
+ prefix = request.env['rack.mount.prefix'] || ''
42
+ href = prefix + destination
43
+ "<a href='#{href}'>#{content}</a>"
44
+ end
45
+ end
32
46
  end
33
47
  end
@@ -0,0 +1,24 @@
1
+ module Cans
2
+ class Historian
3
+ attr_accessor :enabled
4
+ def initialize
5
+ try_history
6
+ end
7
+
8
+ def delve
9
+ reload_history if enabled
10
+ end
11
+
12
+ private
13
+ def reload_history
14
+ ActiveSupport::Dependencies.history.each { |f| load f }
15
+ end
16
+
17
+ def try_history
18
+ ActiveSupport::Dependencies.history
19
+ enabled = true
20
+ rescue
21
+ enabled = false
22
+ end
23
+ end
24
+ end
@@ -7,4 +7,4 @@
7
7
  %ul
8
8
  - @modules.each do |m|
9
9
  %li
10
- %a{:href=>"/module/#{m.name}"}&= m.name
10
+ =link "/module/#{m.name}", m.name
@@ -6,31 +6,29 @@
6
6
  %h1 #{@module.name}
7
7
  %p #{@module.name} inherits from:
8
8
  %ul
9
- - @ancestors.sort_by(&:name).each do |a|
9
+ - @ancestors.sort_by(&:inspect).each do |a|
10
10
  %li
11
- %a{:href=>"/module/#{a.name.gsub('::','/')}"}
12
- &=a.name
11
+ - if a.name
12
+ =link "/module/#{a.name.gsub('::','/')}", a.name
13
+ - else
14
+ &= a.inspect
13
15
  %h2 Child Modules
14
16
  %ul
15
17
  - @child_modules.each do |c|
16
18
  %li
17
- %a{:href=>"/module/#{c.name.gsub('::','/')}"}
18
- &=c.name
19
+ =link "/module/#{c.name.gsub('::','/')}", c.name
19
20
  %h2 Class/Module Methods
20
21
  %ul
21
22
  - @class_methods.sort_by(&:to_s).each do |m|
22
23
  %li
23
- %a{:href=>"/method/#{@module.name}/.m/#{m.to_s}"}
24
- &=m.to_s
24
+ =link "/method/#{@module.name}/.m/#{m.to_s}", m.to_s
25
25
  %h2 Local Instance Methods
26
26
  %ul
27
27
  - @local_instance_methods.sort_by(&:to_s).each do |m|
28
28
  %li
29
- %a{:href=>"/method/#{@module.name}/.i/#{m.to_s}"}
30
- &=m.to_s
29
+ =link "/method/#{@module.name}/.i/#{m.to_s}", m.to_s
31
30
  %h2 Inherited Instance Methods
32
31
  %ul
33
32
  - @super_instance_methods.sort_by(&:to_s).each do |m|
34
33
  %li
35
- %a{:href=>"/method/#{@module.name}/.i/#{m.to_s}"}
36
- &=m.to_s
34
+ =link "/method/#{@module.name}/.i/#{m.to_s}", m.to_s
data/test/helper.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'rack/test'
4
4
  require 'shoulda'
5
+ require 'mocha'
5
6
 
6
7
  ENV['RACK_ENV'] = 'test'
7
8
 
@@ -0,0 +1,15 @@
1
+ require 'helper'
2
+
3
+ class TestHistorian < Test::Unit::TestCase
4
+ context 'a Historian' do
5
+ setup do
6
+ @historian = Cans::Historian.new
7
+ end
8
+
9
+ subject { @historian }
10
+
11
+ should "not be enabled since AS isn't loaded" do
12
+ assert !subject.enabled
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bryce Kerley
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-24 00:00:00 -04:00
17
+ date: 2010-11-12 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -92,6 +92,21 @@ dependencies:
92
92
  version: 0.5.6
93
93
  type: :development
94
94
  version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: mocha
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ - 9
106
+ - 9
107
+ version: 0.9.9
108
+ type: :development
109
+ version_requirements: *id006
95
110
  description: Interactive on-line source browser for rack applications
96
111
  email: bkerley@brycekerley.net
97
112
  executables: []
@@ -104,14 +119,18 @@ extra_rdoc_files:
104
119
  files:
105
120
  - .document
106
121
  - .gitignore
122
+ - Gemfile
123
+ - Gemfile.lock
107
124
  - LICENSE
108
125
  - README.rdoc
109
126
  - Rakefile
110
127
  - VERSION
128
+ - cans.gemspec
111
129
  - config.ru
112
130
  - lib/cans.rb
113
131
  - lib/cans/address.rb
114
132
  - lib/cans/application.rb
133
+ - lib/cans/historian.rb
115
134
  - lib/cans/views/index.haml
116
135
  - lib/cans/views/method.haml
117
136
  - lib/cans/views/module.haml
@@ -120,6 +139,7 @@ files:
120
139
  - test/test_address.rb
121
140
  - test/test_application.rb
122
141
  - test/test_cans.rb
142
+ - test/test_historian.rb
123
143
  has_rdoc: true
124
144
  homepage: http://github.com/bkerley/cans
125
145
  licenses: []
@@ -160,3 +180,4 @@ test_files:
160
180
  - test/test_address.rb
161
181
  - test/test_application.rb
162
182
  - test/test_cans.rb
183
+ - test/test_historian.rb