multigiri 0.0.1 → 0.0.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.
@@ -1,8 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
+ # You might want to use some HTML 5 features right now, so your code is more readable & cleaner.
4
+
5
+ # In future it can detect if the browser is capable to deal with given HTML 5 feature and
6
+ # if yes, then there will be no transformation required. But then carefully with caching :)
3
7
  module Rack
4
8
  class Multigiri
5
9
  module HTML5
10
+ # Browsers supporting HTML 5 should can submit forms through PUT or DELETE natively.
6
11
  class Forms
7
12
  def initialize(app)
8
13
  @app = app
@@ -23,6 +28,7 @@ module Rack
23
28
  end
24
29
  end
25
30
 
31
+ # Elements can have attribute hidden.
26
32
  class Hidden
27
33
  def initialize(app)
28
34
  @app = app
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+
3
+ # @example
4
+ # use Multigiri do
5
+ # use LinkChecker, Rango.logger do |path|
6
+ # "public" + path
7
+ # end
8
+ # end
9
+ module Rack
10
+ class Multigiri
11
+ class LinkChecker
12
+ def initialize(app, logger, patterns = nil, &block)
13
+ @app, @logger, @patterns, @block = app, logger, patterns, block
14
+ @patterns ||= {"img" => "src", "link" => "href", "a" => "href"}
15
+ end
16
+
17
+ def links
18
+ @links ||= Array.new
19
+ end
20
+
21
+ def call(env)
22
+ status, headers, document = @app.call(env)
23
+ @patterns.each do |tag, attribute|
24
+ document.css("#{tag}[#{attribute}]").each do |element|
25
+ link = element[attribute]
26
+ unless link.match(/^\w+:\/\//)
27
+ self.links << link
28
+ end
29
+ end
30
+ end
31
+ check_links
32
+ [status, headers, document]
33
+ end
34
+
35
+ private
36
+ def check_links
37
+ self.links.each do |link|
38
+ real_path = @block.call(link)
39
+ unless File.exist?(real_path)
40
+ @logger.error("[LINK] #{link} doesn't exist")
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class Multigiri
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,26 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multigiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jakub Stastny aka Botanicus
8
13
  autorequire:
9
14
  bindir: bin
10
15
  cert_chain:
11
- date: 2010-02-03 00:00:00 +00:00
16
+ date: 2010-03-12 00:00:00 +00:00
12
17
  default_executable: multigiri
13
18
  dependencies:
14
19
  - !ruby/object:Gem::Dependency
15
20
  name: nokogiri
16
- type: :runtime
17
- version_requirement:
18
- version_requirements: !ruby/object:Gem::Requirement
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
19
23
  requirements:
20
24
  - - ">="
21
25
  - !ruby/object:Gem::Version
26
+ segments:
27
+ - 0
22
28
  version: "0"
23
- version:
29
+ type: :runtime
30
+ version_requirements: *id001
24
31
  description: ""
25
32
  email: stastny@101ideas.cz
26
33
  executables: []
@@ -43,6 +50,7 @@ files:
43
50
  - lib/multigiri/email_obfuscator.rb
44
51
  - lib/multigiri/google_analytics.rb
45
52
  - lib/multigiri/html5.rb
53
+ - lib/multigiri/link_checker.rb
46
54
  - lib/multigiri/version.rb
47
55
  - multigiri.gemspec
48
56
  - multigiri.pre.gemspec
@@ -64,18 +72,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
72
  requirements:
65
73
  - - ">="
66
74
  - !ruby/object:Gem::Version
75
+ segments:
76
+ - 1
77
+ - 9
67
78
  version: "1.9"
68
- version:
69
79
  required_rubygems_version: !ruby/object:Gem::Requirement
70
80
  requirements:
71
81
  - - ">="
72
82
  - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
73
85
  version: "0"
74
- version:
75
86
  requirements: []
76
87
 
77
88
  rubyforge_project: multigiri
78
- rubygems_version: 1.3.5
89
+ rubygems_version: 1.3.6
79
90
  signing_key:
80
91
  specification_version: 3
81
92
  summary: ""