proxeze 0.1.0 → 0.2.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/README.rdoc +5 -0
- data/VERSION +1 -1
- data/examples/sinatra/app.rb +96 -0
- data/examples/sinatra/config.ru +6 -0
- data/examples/sinatra/public/app.css +17 -0
- data/examples/sinatra/public/app.js +5 -0
- data/examples/sinatra/public/favicon.ico +0 -0
- data/examples/sinatra/public/nested_directory/file_inside_nested_directory.txt +3 -0
- data/examples/sinatra/views/index.haml +26 -0
- data/examples/sinatra/views/layout.haml +10 -0
- data/lib/proxeze.rb +12 -0
- data/proxeze.gemspec +11 -3
- metadata +13 -40
data/README.rdoc
CHANGED
@@ -96,6 +96,11 @@ This allows you to proxy specific instances of your classes without proxying all
|
|
96
96
|
a.class # => Proxeze::A
|
97
97
|
a.__getobj__.class # => A
|
98
98
|
|
99
|
+
== Supported Ruby versions
|
100
|
+
This code has been tested on 1.8.7, 1.9.2, and JRuby 1.5.6. I haven't bothered to test it on anything else, but I strongly suspect it will work just fine on any Ruby implementation greater than 1.8.6.
|
101
|
+
|
102
|
+
If you run into problems, feel free to open an issue at https://github.com/jacaetevha/proxeze/issues, or you can fix it yourself (see "Contributing to proxeze" below).
|
103
|
+
|
99
104
|
== Contributing to proxeze
|
100
105
|
|
101
106
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra'
|
3
|
+
require 'haml'
|
4
|
+
require 'proxeze'
|
5
|
+
|
6
|
+
module Visibility
|
7
|
+
def visible?
|
8
|
+
@visible = true if @visible.nil?
|
9
|
+
@visible
|
10
|
+
end
|
11
|
+
|
12
|
+
def be_invisible!
|
13
|
+
@visible = false
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def be_visible!
|
18
|
+
@visible = true
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class ListingItem
|
24
|
+
attr_reader :name, :children, :path
|
25
|
+
attr_accessor :parent
|
26
|
+
|
27
|
+
def initialize name, is_directory
|
28
|
+
@name = name.split('/').last
|
29
|
+
@path = name.split('/')[0..-2]
|
30
|
+
@is_directory = is_directory
|
31
|
+
@children = []
|
32
|
+
end
|
33
|
+
|
34
|
+
def full_path
|
35
|
+
if parent.nil?
|
36
|
+
name
|
37
|
+
else
|
38
|
+
File.join(*([parent.full_path] + [name]).flatten)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def top_level?
|
43
|
+
path.nil? || path.empty?
|
44
|
+
end
|
45
|
+
|
46
|
+
def directory?
|
47
|
+
@is_directory
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Proxeze.proxy ListingItem
|
52
|
+
Proxeze::ListingItem.send :include, Visibility
|
53
|
+
configure do
|
54
|
+
ALL_LISTINGS = Dir['**/**'].collect{|e| ListingItem.new(e, File.directory?(e)) }
|
55
|
+
ALL_LISTINGS.each do |e|
|
56
|
+
next if e.path.nil? || e.path.empty?
|
57
|
+
e.parent = ALL_LISTINGS.detect{|e1| e1.name == e.path.last}
|
58
|
+
e.parent.children << e if e.parent
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
helpers do
|
63
|
+
def unhide &blk
|
64
|
+
hide_all_listings
|
65
|
+
ALL_LISTINGS.select(&blk).each{|e| e.be_visible!}
|
66
|
+
end
|
67
|
+
|
68
|
+
def hide_all_listings
|
69
|
+
ALL_LISTINGS.each{|e| e.be_invisible!}
|
70
|
+
end
|
71
|
+
|
72
|
+
def unhide_all_listings
|
73
|
+
ALL_LISTINGS.each{|e| e.be_visible!}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
before do
|
78
|
+
hide_all_listings
|
79
|
+
end
|
80
|
+
|
81
|
+
get '/' do
|
82
|
+
unhide {|e| e.top_level?}
|
83
|
+
@top = true
|
84
|
+
haml :index
|
85
|
+
end
|
86
|
+
|
87
|
+
get '/*' do
|
88
|
+
if request.xhr?
|
89
|
+
content_type 'text/plain'
|
90
|
+
File.read(params[:splat].first)
|
91
|
+
else
|
92
|
+
path = params[:splat].first.split('/')
|
93
|
+
unhide {|e| e.name == path.last || e.path == path.last}
|
94
|
+
haml :index
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #def;
|
3
|
+
}
|
4
|
+
.file_listing{
|
5
|
+
style: 'width: 15%';
|
6
|
+
}
|
7
|
+
#file_contents {
|
8
|
+
overflow: auto;
|
9
|
+
position: absolute;
|
10
|
+
width: 80%;
|
11
|
+
height: 90%;
|
12
|
+
top: 2px;
|
13
|
+
right: 10px;
|
14
|
+
background-color: white;
|
15
|
+
border: 1px solid #222;
|
16
|
+
padding: 7px;
|
17
|
+
}
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#file_contents
|
2
|
+
|
3
|
+
- visible_listings = ALL_LISTINGS.select{|e| e.visible?}
|
4
|
+
|
5
|
+
- if visible_listings.first.parent.nil?
|
6
|
+
.file_listing
|
7
|
+
%a{:href => "/"} up
|
8
|
+
|
9
|
+
- visible_listings.each do |item|
|
10
|
+
- if item.parent
|
11
|
+
.file_listing
|
12
|
+
%a{:href => "/#{item.parent.name}"}&= item.parent.name
|
13
|
+
.file_listing
|
14
|
+
- if item.directory?
|
15
|
+
%a{:href => "/#{item.name}"}&= item.name
|
16
|
+
- unless @top
|
17
|
+
- item.children.each do |child|
|
18
|
+
.file_listing
|
19
|
+
- if child.directory?
|
20
|
+
%a{:href => "/#{child.full_path}"}&= child.name
|
21
|
+
- else
|
22
|
+
%a{:onclick => "show_file('#{child.full_path}');", :href => "##{child.name}"}&= child.name
|
23
|
+
|
24
|
+
- else
|
25
|
+
%a{:onclick => "show_file('#{item.full_path}');", :href => "##{item.name}"}&= item.name
|
26
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
!!! Strict
|
2
|
+
%html{ :xmlns => "http://www.w3.org/1999/xhtml" }
|
3
|
+
%head
|
4
|
+
%title Proxeze Example
|
5
|
+
%link{:type => 'text/css', :rel => 'stylesheet', :href => '/app.css'}
|
6
|
+
%script{:type => 'text/javascript', :src => '/app.js' }
|
7
|
+
%script{:type => 'text/javascript', :src => 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'}
|
8
|
+
%body
|
9
|
+
#content
|
10
|
+
= yield
|
data/lib/proxeze.rb
CHANGED
@@ -11,6 +11,18 @@ module Proxeze
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
# Create a proxy class for the given target class.
|
15
|
+
# If redefine_new_method is false, the target class' #new
|
16
|
+
# method will not be reimplemented.
|
17
|
+
#
|
18
|
+
# When the target class' #new method is reimplemented,
|
19
|
+
# all subsequent calls to #new on that class will return
|
20
|
+
# an instance of a proxied class (in the Proxeze namespace),
|
21
|
+
# thereby allowing seemless integration with existing
|
22
|
+
# classes.
|
23
|
+
#
|
24
|
+
# Typically, only the Proxeze.for method should pass in
|
25
|
+
# redefine_new_method=false here.
|
14
26
|
def self.proxy target_class, redefine_new_method = true
|
15
27
|
cls_name = target_class.name.gsub '::', ''
|
16
28
|
unless self.class_defined? cls_name
|
data/proxeze.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{proxeze}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jason Rogers"]
|
@@ -23,6 +23,14 @@ Gem::Specification.new do |s|
|
|
23
23
|
"README.rdoc",
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
|
+
"examples/sinatra/app.rb",
|
27
|
+
"examples/sinatra/config.ru",
|
28
|
+
"examples/sinatra/public/app.css",
|
29
|
+
"examples/sinatra/public/app.js",
|
30
|
+
"examples/sinatra/public/favicon.ico",
|
31
|
+
"examples/sinatra/public/nested_directory/file_inside_nested_directory.txt",
|
32
|
+
"examples/sinatra/views/index.haml",
|
33
|
+
"examples/sinatra/views/layout.haml",
|
26
34
|
"lib/proxeze.rb",
|
27
35
|
"proxeze.gemspec",
|
28
36
|
"spec/definitions.rb",
|
@@ -32,16 +40,16 @@ Gem::Specification.new do |s|
|
|
32
40
|
s.homepage = %q{http://github.com/jacaetevha/proxeze}
|
33
41
|
s.licenses = ["MIT"]
|
34
42
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.
|
43
|
+
s.rubygems_version = %q{1.5.0}
|
36
44
|
s.summary = %q{A basic proxy/delegate framework for Ruby that will allow you to wrap any object with a proxy instance.}
|
37
45
|
s.test_files = [
|
46
|
+
"examples/sinatra/app.rb",
|
38
47
|
"spec/definitions.rb",
|
39
48
|
"spec/proxeze_spec.rb",
|
40
49
|
"spec/spec_helper.rb"
|
41
50
|
]
|
42
51
|
|
43
52
|
if s.respond_to? :specification_version then
|
44
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
53
|
s.specification_version = 3
|
46
54
|
|
47
55
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxeze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Jason Rogers
|
@@ -24,8 +20,6 @@ dependencies:
|
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
23
|
version: "0"
|
30
24
|
type: :development
|
31
25
|
prerelease: false
|
@@ -37,10 +31,6 @@ dependencies:
|
|
37
31
|
requirements:
|
38
32
|
- - ~>
|
39
33
|
- !ruby/object:Gem::Version
|
40
|
-
segments:
|
41
|
-
- 2
|
42
|
-
- 4
|
43
|
-
- 0
|
44
34
|
version: 2.4.0
|
45
35
|
type: :development
|
46
36
|
prerelease: false
|
@@ -52,10 +42,6 @@ dependencies:
|
|
52
42
|
requirements:
|
53
43
|
- - ~>
|
54
44
|
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 1
|
57
|
-
- 0
|
58
|
-
- 0
|
59
45
|
version: 1.0.0
|
60
46
|
type: :development
|
61
47
|
prerelease: false
|
@@ -67,10 +53,6 @@ dependencies:
|
|
67
53
|
requirements:
|
68
54
|
- - ~>
|
69
55
|
- !ruby/object:Gem::Version
|
70
|
-
segments:
|
71
|
-
- 1
|
72
|
-
- 5
|
73
|
-
- 2
|
74
56
|
version: 1.5.2
|
75
57
|
type: :development
|
76
58
|
prerelease: false
|
@@ -82,8 +64,6 @@ dependencies:
|
|
82
64
|
requirements:
|
83
65
|
- - ">="
|
84
66
|
- !ruby/object:Gem::Version
|
85
|
-
segments:
|
86
|
-
- 0
|
87
67
|
version: "0"
|
88
68
|
type: :development
|
89
69
|
prerelease: false
|
@@ -95,10 +75,6 @@ dependencies:
|
|
95
75
|
requirements:
|
96
76
|
- - ~>
|
97
77
|
- !ruby/object:Gem::Version
|
98
|
-
segments:
|
99
|
-
- 2
|
100
|
-
- 4
|
101
|
-
- 0
|
102
78
|
version: 2.4.0
|
103
79
|
type: :development
|
104
80
|
prerelease: false
|
@@ -110,10 +86,6 @@ dependencies:
|
|
110
86
|
requirements:
|
111
87
|
- - ~>
|
112
88
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 1
|
115
|
-
- 0
|
116
|
-
- 0
|
117
89
|
version: 1.0.0
|
118
90
|
type: :development
|
119
91
|
prerelease: false
|
@@ -125,10 +97,6 @@ dependencies:
|
|
125
97
|
requirements:
|
126
98
|
- - ~>
|
127
99
|
- !ruby/object:Gem::Version
|
128
|
-
segments:
|
129
|
-
- 1
|
130
|
-
- 5
|
131
|
-
- 2
|
132
100
|
version: 1.5.2
|
133
101
|
type: :development
|
134
102
|
prerelease: false
|
@@ -140,8 +108,6 @@ dependencies:
|
|
140
108
|
requirements:
|
141
109
|
- - ">="
|
142
110
|
- !ruby/object:Gem::Version
|
143
|
-
segments:
|
144
|
-
- 0
|
145
111
|
version: "0"
|
146
112
|
type: :development
|
147
113
|
prerelease: false
|
@@ -162,6 +128,14 @@ files:
|
|
162
128
|
- README.rdoc
|
163
129
|
- Rakefile
|
164
130
|
- VERSION
|
131
|
+
- examples/sinatra/app.rb
|
132
|
+
- examples/sinatra/config.ru
|
133
|
+
- examples/sinatra/public/app.css
|
134
|
+
- examples/sinatra/public/app.js
|
135
|
+
- examples/sinatra/public/favicon.ico
|
136
|
+
- examples/sinatra/public/nested_directory/file_inside_nested_directory.txt
|
137
|
+
- examples/sinatra/views/index.haml
|
138
|
+
- examples/sinatra/views/layout.haml
|
165
139
|
- lib/proxeze.rb
|
166
140
|
- proxeze.gemspec
|
167
141
|
- spec/definitions.rb
|
@@ -181,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
155
|
requirements:
|
182
156
|
- - ">="
|
183
157
|
- !ruby/object:Gem::Version
|
184
|
-
hash:
|
158
|
+
hash: 2702813715672519678
|
185
159
|
segments:
|
186
160
|
- 0
|
187
161
|
version: "0"
|
@@ -190,17 +164,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
164
|
requirements:
|
191
165
|
- - ">="
|
192
166
|
- !ruby/object:Gem::Version
|
193
|
-
segments:
|
194
|
-
- 0
|
195
167
|
version: "0"
|
196
168
|
requirements: []
|
197
169
|
|
198
170
|
rubyforge_project:
|
199
|
-
rubygems_version: 1.
|
171
|
+
rubygems_version: 1.5.0
|
200
172
|
signing_key:
|
201
173
|
specification_version: 3
|
202
174
|
summary: A basic proxy/delegate framework for Ruby that will allow you to wrap any object with a proxy instance.
|
203
175
|
test_files:
|
176
|
+
- examples/sinatra/app.rb
|
204
177
|
- spec/definitions.rb
|
205
178
|
- spec/proxeze_spec.rb
|
206
179
|
- spec/spec_helper.rb
|