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.
@@ -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
1
+ 0.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cans}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bryce Kerley"]
@@ -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
 
@@ -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
- reload_history if enabled
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
- ActiveSupport::Dependencies.history.each { |f| load f }
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
- enabled = false
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
@@ -7,4 +7,8 @@
7
7
  %ul
8
8
  - @modules.each do |m|
9
9
  %li
10
- =link "/module/#{m.name}", m.name
10
+ =link "/module/#{m.name}", m.name
11
+ %h1 History
12
+ %ul
13
+ - @history.each do |f|
14
+ %li&= f
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bryce Kerley