ironhide 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/TODO +1 -0
- data/ironhide.gemspec +0 -1
- data/lib/ironhide.rb +1 -1
- data/lib/ironhide/includer.rb +17 -5
- data/lib/ironhide/version.rb +1 -1
- data/spec/spec_helper.rb +34 -2
- metadata +15 -30
- data/Gemfile.lock +0 -98
data/.gitignore
CHANGED
data/ironhide.gemspec
CHANGED
data/lib/ironhide.rb
CHANGED
data/lib/ironhide/includer.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'httpclient'
|
2
|
-
require 'rails'
|
3
2
|
|
4
3
|
module Ironhide
|
5
4
|
class Includer
|
@@ -8,23 +7,36 @@ module Ironhide
|
|
8
7
|
attr_writer :default_timeout
|
9
8
|
|
10
9
|
def default_timeout
|
11
|
-
@default_timeout ||=
|
10
|
+
@default_timeout ||= 600
|
12
11
|
end
|
13
12
|
|
14
13
|
def get(url, timeout = default_timeout)
|
15
|
-
|
16
|
-
cached = Rails.cache.read(key)
|
14
|
+
cached = cache_read(url)
|
17
15
|
return cached unless cached.nil?
|
18
16
|
|
19
17
|
response = HTTPClient.get(url)
|
20
18
|
if response.status_code == 200
|
21
19
|
content = response.body.content
|
22
|
-
|
20
|
+
cache_write(url, content, timeout)
|
23
21
|
content
|
24
22
|
else
|
25
23
|
nil
|
26
24
|
end
|
27
25
|
end
|
26
|
+
|
27
|
+
def cache_read(url)
|
28
|
+
return nil unless defined? Rails
|
29
|
+
Rails.cache.read(cache_key(url))
|
30
|
+
end
|
31
|
+
|
32
|
+
def cache_write(url, value, timeout)
|
33
|
+
return unless defined? Rails
|
34
|
+
Rails.cache.write(cache_key(url), value, :expires_in => timeout)
|
35
|
+
end
|
36
|
+
|
37
|
+
def cache_key(url)
|
38
|
+
"Ironhide::Includer::#{Digest::MD5.hexdigest(url)}"
|
39
|
+
end
|
28
40
|
end
|
29
41
|
|
30
42
|
extend ClassMethods
|
data/lib/ironhide/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,31 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
|
3
|
+
begin
|
4
|
+
# rails 3.0.x
|
5
|
+
require 'rails'
|
6
|
+
require 'rails/application/configurable'
|
7
|
+
require 'rails/application/configuration'
|
8
|
+
require 'rails/application/bootstrap'
|
9
|
+
require 'rails/application/railties'
|
10
|
+
require 'rails/application/finisher'
|
11
|
+
require 'action_view'
|
12
|
+
require 'action_view/base'
|
13
|
+
require 'action_view/helpers'
|
14
|
+
require 'action_view/lookup_context'
|
15
|
+
require 'action_view/paths'
|
16
|
+
require 'active_support/cache'
|
17
|
+
require 'active_support/cache/memory_store'
|
18
|
+
rescue LoadError
|
19
|
+
# rails 2.3.x
|
20
|
+
require 'initializer'
|
21
|
+
require 'action_view'
|
22
|
+
require 'action_view/base'
|
23
|
+
require 'action_view/helpers'
|
24
|
+
require 'action_view/paths'
|
25
|
+
require 'active_support/cache'
|
26
|
+
require 'active_support/cache/memory_store'
|
27
|
+
end
|
28
|
+
|
2
29
|
require 'bundler/setup'
|
3
30
|
|
4
31
|
require 'ironhide'
|
@@ -6,6 +33,11 @@ require 'ironhide'
|
|
6
33
|
require 'webmock/rspec'
|
7
34
|
|
8
35
|
RSpec.configure do |config|
|
9
|
-
|
10
|
-
|
36
|
+
if Rails.version.split('.').first == '3'
|
37
|
+
Class.new(Rails::Application)
|
38
|
+
Rails.application.initializers.select { |x| x.name == :initialize_cache }.first.run
|
39
|
+
else
|
40
|
+
RAILS_ROOT = "./"
|
41
|
+
Rails::Initializer.new(Rails::Configuration.new).initialize_cache
|
42
|
+
end
|
11
43
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ironhide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Felipe Oliveira
|
@@ -15,28 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-16 00:00:00 -02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
name: rails
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 3
|
33
|
-
version: "2.3"
|
34
|
-
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
21
|
- !ruby/object:Gem::Dependency
|
37
22
|
name: httpclient
|
38
23
|
prerelease: false
|
39
|
-
requirement: &
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
40
25
|
none: false
|
41
26
|
requirements:
|
42
27
|
- - ">="
|
@@ -49,11 +34,11 @@ dependencies:
|
|
49
34
|
- 2
|
50
35
|
version: 2.1.5.2
|
51
36
|
type: :runtime
|
52
|
-
version_requirements: *
|
37
|
+
version_requirements: *id001
|
53
38
|
- !ruby/object:Gem::Dependency
|
54
39
|
name: bundler
|
55
40
|
prerelease: false
|
56
|
-
requirement: &
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
57
42
|
none: false
|
58
43
|
requirements:
|
59
44
|
- - ">="
|
@@ -65,11 +50,11 @@ dependencies:
|
|
65
50
|
- 0
|
66
51
|
version: 1.0.0
|
67
52
|
type: :development
|
68
|
-
version_requirements: *
|
53
|
+
version_requirements: *id002
|
69
54
|
- !ruby/object:Gem::Dependency
|
70
55
|
name: rspec
|
71
56
|
prerelease: false
|
72
|
-
requirement: &
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
73
58
|
none: false
|
74
59
|
requirements:
|
75
60
|
- - ">="
|
@@ -80,11 +65,11 @@ dependencies:
|
|
80
65
|
- 2
|
81
66
|
version: "2.2"
|
82
67
|
type: :development
|
83
|
-
version_requirements: *
|
68
|
+
version_requirements: *id003
|
84
69
|
- !ruby/object:Gem::Dependency
|
85
70
|
name: webmock
|
86
71
|
prerelease: false
|
87
|
-
requirement: &
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
88
73
|
none: false
|
89
74
|
requirements:
|
90
75
|
- - ">="
|
@@ -96,7 +81,7 @@ dependencies:
|
|
96
81
|
- 1
|
97
82
|
version: 1.6.1
|
98
83
|
type: :development
|
99
|
-
version_requirements: *
|
84
|
+
version_requirements: *id004
|
100
85
|
description: Allows you to include an external html file inside your view.
|
101
86
|
email:
|
102
87
|
- felipecvo@gmail.com
|
@@ -109,9 +94,9 @@ extra_rdoc_files: []
|
|
109
94
|
files:
|
110
95
|
- .gitignore
|
111
96
|
- Gemfile
|
112
|
-
- Gemfile.lock
|
113
97
|
- README.rdoc
|
114
98
|
- Rakefile
|
99
|
+
- TODO
|
115
100
|
- ironhide.gemspec
|
116
101
|
- lib/ironhide.rb
|
117
102
|
- lib/ironhide/helpers/includer_helper.rb
|
@@ -152,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
137
|
requirements: []
|
153
138
|
|
154
139
|
rubyforge_project: ironhide
|
155
|
-
rubygems_version: 1.
|
140
|
+
rubygems_version: 1.4.2
|
156
141
|
signing_key:
|
157
142
|
specification_version: 3
|
158
143
|
summary: Allows you to include an external html file inside your view.
|
data/Gemfile.lock
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
ironhide (0.0.1)
|
5
|
-
httpclient (>= 2.1.5.2)
|
6
|
-
rails (>= 2.3)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: http://rubygems.org/
|
10
|
-
specs:
|
11
|
-
abstract (1.0.0)
|
12
|
-
actionmailer (3.0.0)
|
13
|
-
actionpack (= 3.0.0)
|
14
|
-
mail (~> 2.2.5)
|
15
|
-
actionpack (3.0.0)
|
16
|
-
activemodel (= 3.0.0)
|
17
|
-
activesupport (= 3.0.0)
|
18
|
-
builder (~> 2.1.2)
|
19
|
-
erubis (~> 2.6.6)
|
20
|
-
i18n (~> 0.4.1)
|
21
|
-
rack (~> 1.2.1)
|
22
|
-
rack-mount (~> 0.6.12)
|
23
|
-
rack-test (~> 0.5.4)
|
24
|
-
tzinfo (~> 0.3.23)
|
25
|
-
activemodel (3.0.0)
|
26
|
-
activesupport (= 3.0.0)
|
27
|
-
builder (~> 2.1.2)
|
28
|
-
i18n (~> 0.4.1)
|
29
|
-
activerecord (3.0.0)
|
30
|
-
activemodel (= 3.0.0)
|
31
|
-
activesupport (= 3.0.0)
|
32
|
-
arel (~> 1.0.0)
|
33
|
-
tzinfo (~> 0.3.23)
|
34
|
-
activeresource (3.0.0)
|
35
|
-
activemodel (= 3.0.0)
|
36
|
-
activesupport (= 3.0.0)
|
37
|
-
activesupport (3.0.0)
|
38
|
-
addressable (2.2.2)
|
39
|
-
arel (1.0.1)
|
40
|
-
activesupport (~> 3.0.0)
|
41
|
-
builder (2.1.2)
|
42
|
-
crack (0.1.8)
|
43
|
-
diff-lcs (1.1.2)
|
44
|
-
erubis (2.6.6)
|
45
|
-
abstract (>= 1.0.0)
|
46
|
-
httpclient (2.1.5.2)
|
47
|
-
i18n (0.4.1)
|
48
|
-
mail (2.2.5)
|
49
|
-
activesupport (>= 2.3.6)
|
50
|
-
mime-types
|
51
|
-
treetop (>= 1.4.5)
|
52
|
-
mime-types (1.16)
|
53
|
-
polyglot (0.3.1)
|
54
|
-
rack (1.2.1)
|
55
|
-
rack-mount (0.6.13)
|
56
|
-
rack (>= 1.0.0)
|
57
|
-
rack-test (0.5.4)
|
58
|
-
rack (>= 1.0)
|
59
|
-
rails (3.0.0)
|
60
|
-
actionmailer (= 3.0.0)
|
61
|
-
actionpack (= 3.0.0)
|
62
|
-
activerecord (= 3.0.0)
|
63
|
-
activeresource (= 3.0.0)
|
64
|
-
activesupport (= 3.0.0)
|
65
|
-
bundler (~> 1.0.0)
|
66
|
-
railties (= 3.0.0)
|
67
|
-
railties (3.0.0)
|
68
|
-
actionpack (= 3.0.0)
|
69
|
-
activesupport (= 3.0.0)
|
70
|
-
rake (>= 0.8.4)
|
71
|
-
thor (~> 0.14.0)
|
72
|
-
rake (0.8.7)
|
73
|
-
rspec (2.2.0)
|
74
|
-
rspec-core (~> 2.2)
|
75
|
-
rspec-expectations (~> 2.2)
|
76
|
-
rspec-mocks (~> 2.2)
|
77
|
-
rspec-core (2.2.1)
|
78
|
-
rspec-expectations (2.2.0)
|
79
|
-
diff-lcs (~> 1.1.2)
|
80
|
-
rspec-mocks (2.2.0)
|
81
|
-
thor (0.14.0)
|
82
|
-
treetop (1.4.8)
|
83
|
-
polyglot (>= 0.3.1)
|
84
|
-
tzinfo (0.3.23)
|
85
|
-
webmock (1.6.1)
|
86
|
-
addressable (>= 2.2.2)
|
87
|
-
crack (>= 0.1.7)
|
88
|
-
|
89
|
-
PLATFORMS
|
90
|
-
ruby
|
91
|
-
|
92
|
-
DEPENDENCIES
|
93
|
-
bundler (>= 1.0.0)
|
94
|
-
httpclient (>= 2.1.5.2)
|
95
|
-
ironhide!
|
96
|
-
rails (>= 2.3)
|
97
|
-
rspec (>= 2.2)
|
98
|
-
webmock (>= 1.6.1)
|