exvo_warez 0.0.4 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,16 +1,8 @@
1
1
  = exvo_warez
2
2
 
3
- Description goes here.
3
+ gem "exvo_warez"
4
4
 
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
5
+ use Rack::ExvoWarez
14
6
 
15
7
  == Copyright
16
8
 
data/Rakefile CHANGED
@@ -8,8 +8,8 @@ task :default => :test
8
8
 
9
9
  desc 'Run all tests'
10
10
  Rake::TestTask.new(:test) do |t|
11
- t.libs << 'lib'
12
- t.pattern = 'test/**/*_test.rb'
11
+ t.libs << "test"
12
+ t.test_files = FileList['test/*_test.rb']
13
13
  t.verbose = true
14
14
  end
15
15
 
@@ -21,9 +21,12 @@ begin
21
21
  gemspec.email = "defkode@gmail.com"
22
22
  gemspec.homepage = "http://github.com/defkode/rack-useragent"
23
23
  gemspec.summary = "ExvoWarez"
24
- gemspec.add_dependency("rack-useragent-filter", "0.1.7")
24
+ gemspec.add_dependency("rack-useragent-filter", "0.1.8")
25
25
  gemspec.add_dependency("rack-google-analytics", "0.9.2")
26
26
  gemspec.add_dependency("rack_referral", "0.0.1")
27
+ gemspec.add_dependency("exvo-auth", "~>0.9.2")
27
28
  end
29
+ Jeweler::GemcutterTasks.new
28
30
  rescue LoadError
31
+ puts "Jeweler not available. Install it with: gem install jeweler"
29
32
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.1.3
data/exvo_warez.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{exvo_warez}
8
- s.version = "0.0.4"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tomasz Mazur"]
12
- s.date = %q{2010-09-03}
12
+ s.date = %q{2010-09-06}
13
13
  s.email = %q{defkode@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -23,8 +23,10 @@ Gem::Specification.new do |s|
23
23
  "VERSION",
24
24
  "exvo_warez.gemspec",
25
25
  "lib/exvo_warez.rb",
26
- "test/helper.rb",
27
- "test/test_exvo_warez.rb"
26
+ "lib/rack/exvo/seo.rb",
27
+ "lib/rack/exvo/templates/links.erb",
28
+ "test/exvo_warez_test.rb",
29
+ "test/helper.rb"
28
30
  ]
29
31
  s.homepage = %q{http://github.com/defkode/rack-useragent}
30
32
  s.rdoc_options = ["--charset=UTF-8"]
@@ -32,8 +34,8 @@ Gem::Specification.new do |s|
32
34
  s.rubygems_version = %q{1.3.7}
33
35
  s.summary = %q{ExvoWarez}
34
36
  s.test_files = [
35
- "test/helper.rb",
36
- "test/test_exvo_warez.rb"
37
+ "test/exvo_warez_test.rb",
38
+ "test/helper.rb"
37
39
  ]
38
40
 
39
41
  if s.respond_to? :specification_version then
@@ -41,18 +43,21 @@ Gem::Specification.new do |s|
41
43
  s.specification_version = 3
42
44
 
43
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<rack-useragent-filter>, ["= 0.1.7"])
46
+ s.add_runtime_dependency(%q<rack-useragent-filter>, ["= 0.1.8"])
45
47
  s.add_runtime_dependency(%q<rack-google-analytics>, ["= 0.9.2"])
46
48
  s.add_runtime_dependency(%q<rack_referral>, ["= 0.0.1"])
49
+ s.add_runtime_dependency(%q<exvo-auth>, ["~> 0.9.2"])
47
50
  else
48
- s.add_dependency(%q<rack-useragent-filter>, ["= 0.1.7"])
51
+ s.add_dependency(%q<rack-useragent-filter>, ["= 0.1.8"])
49
52
  s.add_dependency(%q<rack-google-analytics>, ["= 0.9.2"])
50
53
  s.add_dependency(%q<rack_referral>, ["= 0.0.1"])
54
+ s.add_dependency(%q<exvo-auth>, ["~> 0.9.2"])
51
55
  end
52
56
  else
53
- s.add_dependency(%q<rack-useragent-filter>, ["= 0.1.7"])
57
+ s.add_dependency(%q<rack-useragent-filter>, ["= 0.1.8"])
54
58
  s.add_dependency(%q<rack-google-analytics>, ["= 0.9.2"])
55
59
  s.add_dependency(%q<rack_referral>, ["= 0.0.1"])
60
+ s.add_dependency(%q<exvo-auth>, ["~> 0.9.2"])
56
61
  end
57
62
  end
58
63
 
data/lib/exvo_warez.rb CHANGED
@@ -1,11 +1,15 @@
1
+ require "rack/exvo/seo"
1
2
  require "rack/google-analytics"
2
3
  require "rack/useragent/filter"
4
+ require "rack_referral"
5
+ require 'exvo-auth'
3
6
 
4
7
  module Rack
5
8
  class ExvoWarez
6
9
 
7
10
  def initialize(app)
8
11
  @app = app
12
+ apply_middlewares
9
13
  end
10
14
 
11
15
  def apply_middlewares
@@ -16,11 +20,14 @@ module Rack
16
20
 
17
21
  if env == "production"
18
22
  apply_analytics
19
- end
23
+ end
24
+
25
+ if ExvoAuth::Config.client_id
26
+ apply_seo
27
+ end
20
28
  end
21
29
 
22
30
  def call(env)
23
- apply_middlewares
24
31
  @app.call(env)
25
32
  end
26
33
 
@@ -46,6 +53,10 @@ module Rack
46
53
  @app = Rack::UserAgent::Filter.new(@app, required_products, :force_with_cookie => "deprecated_browser")
47
54
  # :template => "#{RAILS_ROOT}/public/browser_unsupported.html.erb"
48
55
  end
56
+
57
+ def apply_seo
58
+ @app = Rack::ExvoWarez::Seo.new(@app)
59
+ end
49
60
 
50
61
  def apply_referral
51
62
  @app = Rack::Referral.new(@app, :url => "#{auth_host}/referrals/<REF>?return_to=<RETURN_TO>")
@@ -0,0 +1,50 @@
1
+ module Rack
2
+ class ExvoWarez
3
+ class Seo
4
+ def initialize(app)
5
+ @app = app
6
+ @apps = apps_index
7
+ @payload = ERB.new(::File.read(::File.expand_path("../templates/links.erb", __FILE__))).result(binding)
8
+ end
9
+
10
+ def call(env)
11
+ status, headers, @body = @app.call(env)
12
+ if html?(headers)
13
+ if cl = headers["Content-Length"]
14
+ headers["Content-Length"] = cl.to_i + @payload.length
15
+ end
16
+ [status, headers, self]
17
+ else
18
+ [status, headers, @body]
19
+ end
20
+ [status, headers, (html?(headers) ? self : @body)]
21
+ end
22
+
23
+ def each
24
+ @body.each do |chunk|
25
+ yield(end_of_body?(chunk) ? with_payload(chunk) : chunk)
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def apps_index
32
+ ExvoAuth::Autonomous::Auth.instance.get("/api/private/apps/trusted").parsed_response.reject do |app|
33
+ app["client_id"] == ExvoAuth::Config.client_id
34
+ end
35
+ end
36
+
37
+ def html?(headers)
38
+ /html/ === headers['Content-Type']
39
+ end
40
+
41
+ def end_of_body?(chunk)
42
+ /<\/body>/ === chunk # There is a slight possibility that this will be split into 2 chunks.
43
+ end
44
+
45
+ def with_payload(chunk)
46
+ chunk.sub("</body>", @payload + "</body>")
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ <footer style="display: none">
2
+ <% @apps.each do |app| %>
3
+ <a href="<%= app["url"] %>"><%= app["name"] %></a>
4
+ <% end %>
5
+ </footer>
@@ -0,0 +1,20 @@
1
+ require 'helper'
2
+
3
+ class TestExvoWarez < Test::Unit::TestCase
4
+ test "sanity" do
5
+ app = lambda {|env| [200, {"Content-Type" => "text/html"}, ["foo", "bar", "</body>"]]}
6
+ Rack::ExvoWarez::Seo.send :define_method, :apps_index do # poor man's mock
7
+ [
8
+ {"url" => "url1", "name" => "name1"},
9
+ {"url" => "url2", "name" => "name2"}
10
+ ]
11
+ end
12
+ a = Rack::ExvoWarez::Seo.new(app)
13
+ p = a.instance_variable_get(:@payload)
14
+ s, h, b = a.call({})
15
+ body = "".tap{|s| b.each{|c| s << c}}
16
+
17
+ assert p.length > 0
18
+ assert_equal "foobar#{p}</body>", body
19
+ end
20
+ end
data/test/helper.rb CHANGED
@@ -1,10 +1,4 @@
1
1
  require 'rubygems'
2
+ gem "test-unit", "~>2.1.0"
2
3
  require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
4
  require 'exvo_warez'
8
-
9
- class Test::Unit::TestCase
10
- end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exvo_warez
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
8
+ - 1
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tomasz Mazur
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-03 00:00:00 +02:00
18
+ date: 2010-09-06 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - "="
28
28
  - !ruby/object:Gem::Version
29
- hash: 21
29
+ hash: 11
30
30
  segments:
31
31
  - 0
32
32
  - 1
33
- - 7
34
- version: 0.1.7
33
+ - 8
34
+ version: 0.1.8
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,22 @@ dependencies:
66
66
  version: 0.0.1
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: exvo-auth
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 63
78
+ segments:
79
+ - 0
80
+ - 9
81
+ - 2
82
+ version: 0.9.2
83
+ type: :runtime
84
+ version_requirements: *id004
69
85
  description:
70
86
  email: defkode@gmail.com
71
87
  executables: []
@@ -83,8 +99,10 @@ files:
83
99
  - VERSION
84
100
  - exvo_warez.gemspec
85
101
  - lib/exvo_warez.rb
102
+ - lib/rack/exvo/seo.rb
103
+ - lib/rack/exvo/templates/links.erb
104
+ - test/exvo_warez_test.rb
86
105
  - test/helper.rb
87
- - test/test_exvo_warez.rb
88
106
  has_rdoc: true
89
107
  homepage: http://github.com/defkode/rack-useragent
90
108
  licenses: []
@@ -120,5 +138,5 @@ signing_key:
120
138
  specification_version: 3
121
139
  summary: ExvoWarez
122
140
  test_files:
141
+ - test/exvo_warez_test.rb
123
142
  - test/helper.rb
124
- - test/test_exvo_warez.rb
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestExvoWarez < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end