cans 0.1.1 → 0.1.2
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/README.rdoc +14 -0
- data/VERSION +1 -1
- data/cans.gemspec +1 -1
- data/lib/cans/application.rb +6 -1
- data/lib/cans/historian.rb +29 -4
- data/lib/cans/views/index.haml +5 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -5,6 +5,20 @@ Interactive online source browser for Rack applications.
|
|
5
5
|
Experimental and unfinished. This gem will probably kill
|
6
6
|
you in your sleep if you try to use it right now.
|
7
7
|
|
8
|
+
== Using in Rails 3
|
9
|
+
|
10
|
+
Add "cans" to your Gemfile:
|
11
|
+
|
12
|
+
gem 'cans'
|
13
|
+
|
14
|
+
Mount cans in routes.rb:
|
15
|
+
|
16
|
+
mount Cans::Application.new, :at=>'/cans'
|
17
|
+
|
18
|
+
Start your Rails app, and use it a bit. Understand that cans will add an after_filter to your whole application to scrape off the file history, since development mode unloads everything after requests.
|
19
|
+
|
20
|
+
Then, visit the cans mountpoint and browse around.
|
21
|
+
|
8
22
|
== Note on Patches/Pull Requests
|
9
23
|
|
10
24
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/cans.gemspec
CHANGED
data/lib/cans/application.rb
CHANGED
@@ -5,6 +5,7 @@ module Cans
|
|
5
5
|
get '/' do
|
6
6
|
@constants = Object.constants
|
7
7
|
@modules = @constants.map{ |c| Object.const_get c}.select{ |c| c.kind_of? Module}.sort_by(&:name)
|
8
|
+
@history = @historian.history
|
8
9
|
haml :index
|
9
10
|
end
|
10
11
|
|
@@ -31,8 +32,12 @@ module Cans
|
|
31
32
|
haml :method
|
32
33
|
end
|
33
34
|
|
35
|
+
def initialize
|
36
|
+
@historian = Historian.new
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
34
40
|
before do
|
35
|
-
@historian ||= Historian.new
|
36
41
|
@historian.delve
|
37
42
|
end
|
38
43
|
|
data/lib/cans/historian.rb
CHANGED
@@ -1,24 +1,49 @@
|
|
1
1
|
module Cans
|
2
2
|
class Historian
|
3
3
|
attr_accessor :enabled
|
4
|
+
attr_accessor :history
|
4
5
|
def initialize
|
6
|
+
self.history = Set.new
|
7
|
+
self.enabled = false
|
5
8
|
try_history
|
9
|
+
try_bugging_rails
|
6
10
|
end
|
7
11
|
|
8
12
|
def delve
|
9
|
-
|
13
|
+
return unless enabled
|
14
|
+
merge_history
|
15
|
+
reload_history
|
16
|
+
end
|
17
|
+
|
18
|
+
def record
|
19
|
+
merge_history
|
10
20
|
end
|
11
21
|
|
12
22
|
private
|
23
|
+
def merge_history
|
24
|
+
history.merge ActiveSupport::Dependencies.history
|
25
|
+
end
|
26
|
+
|
13
27
|
def reload_history
|
14
|
-
|
28
|
+
history.each { |f| require_or_load f }
|
15
29
|
end
|
16
30
|
|
17
31
|
def try_history
|
18
32
|
ActiveSupport::Dependencies.history
|
19
|
-
enabled = true
|
33
|
+
self.enabled = true
|
20
34
|
rescue
|
21
|
-
|
35
|
+
end
|
36
|
+
|
37
|
+
def try_bugging_rails
|
38
|
+
this_historian = self
|
39
|
+
ApplicationController.instance_eval do
|
40
|
+
after_filter :save_history
|
41
|
+
define_method :save_history do
|
42
|
+
this_historian.record
|
43
|
+
end
|
44
|
+
end
|
45
|
+
self.enabled = true
|
46
|
+
rescue => e
|
22
47
|
end
|
23
48
|
end
|
24
49
|
end
|
data/lib/cans/views/index.haml
CHANGED