kelredd-sinatra-helpers 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
|
|
17
17
|
s.files = %w(README.rdoc Rakefile) + Dir.glob("{bin,lib}/**/*")
|
18
18
|
s.executables = ['sinatra']
|
19
19
|
|
20
|
-
s.add_dependency('kelredd-useful', ['>= 0.
|
20
|
+
s.add_dependency('kelredd-useful', ['>= 0.3.0'])
|
21
21
|
|
22
22
|
s.add_development_dependency("shoulda", [">= 2.10.2"])
|
23
23
|
s.add_development_dependency("sinatra", [">= 0.9.4"])
|
data/lib/sinatra_helpers/erb.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
+
require "useful/erb_helpers"
|
2
|
+
|
1
3
|
Dir[File.join(File.dirname(__FILE__), "erb" ,"*.rb")].each do |file|
|
2
4
|
require "sinatra_helpers/erb/#{File.basename(file, ".rb")}"
|
3
5
|
end
|
4
6
|
|
5
|
-
require "useful/erb_helpers"
|
6
|
-
Sinatra::Application.helpers Useful::ErbHelpers::Tags
|
7
|
-
Sinatra::Application.helpers Useful::ErbHelpers::Links
|
8
|
-
Sinatra::Application.helpers Useful::ErbHelpers::Forms
|
9
|
-
Sinatra::Application.helpers Useful::ErbHelpers::Proper
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require "useful/erb_helpers/links"
|
4
|
+
|
5
|
+
module SinatraHelpers; end
|
6
|
+
module SinatraHelpers::Erb; end
|
7
|
+
|
8
|
+
module SinatraHelpers::Erb::Links
|
9
|
+
|
10
|
+
SINATRA_HELPERS_LINKS_TMP_FILE = File.expand_path('./tmp/.sinatra_helpers_links')
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def registered(app)
|
15
|
+
app.send(:alias_method, :useful_stylesheet_link_tag, :stylesheet_link_tag)
|
16
|
+
app.send(:alias_method, :stylesheet_link_tag, :sinatra_helpers_stylesheet_link_tag)
|
17
|
+
|
18
|
+
app.send(:alias_method, :useful_javascript_include_tag, :javascript_include_tag)
|
19
|
+
app.send(:alias_method, :javascript_include_tag, :sinatra_helpers_javascript_include_tag)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def sinatra_helpers_stylesheet_link_tag(*args)
|
25
|
+
useful_stylesheet_link_tag(sinatra_helpers_links_args(args))
|
26
|
+
end
|
27
|
+
|
28
|
+
def sinatra_helpers_javascript_include_tag(*args)
|
29
|
+
useful_javascript_include_tag(sinatra_helpers_links_args(args))
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def sinatra_helpers_links_args(args)
|
35
|
+
the_args = args.flatten
|
36
|
+
if the_args.last && the_args.last.kind_of?(::Hash)
|
37
|
+
the_args.last[:timestamp] ||= sinatra_helpers_links_timestamp
|
38
|
+
else
|
39
|
+
the_args << { :timestamp => sinatra_helpers_links_timestamp }
|
40
|
+
end
|
41
|
+
the_args
|
42
|
+
end
|
43
|
+
|
44
|
+
def sinatra_helpers_links_timestamp
|
45
|
+
if defined?(:development?) && !development?
|
46
|
+
unless File.exists?(SINATRA_HELPERS_LINKS_TMP_FILE)
|
47
|
+
`touch #{SINATRA_HELPERS_LINKS_TMP_FILE}`
|
48
|
+
end
|
49
|
+
File.mtime(SINATRA_HELPERS_LINKS_TMP_FILE).to_i.to_s
|
50
|
+
else
|
51
|
+
Time.now.to_i.to_s
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
Sinatra::Application.helpers Useful::ErbHelpers::Links
|
58
|
+
Sinatra::Application.helpers SinatraHelpers::Erb::Links
|
59
|
+
|
60
|
+
Sinatra::Application.register SinatraHelpers::Erb::Links
|
61
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kelly Redding
|
@@ -26,9 +26,9 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
segments:
|
28
28
|
- 0
|
29
|
-
-
|
30
|
-
-
|
31
|
-
version: 0.
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
version: 0.3.0
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
@@ -100,7 +100,11 @@ files:
|
|
100
100
|
- Rakefile
|
101
101
|
- bin/sinatra
|
102
102
|
- lib/sinatra_helpers/environment_tests.rb
|
103
|
+
- lib/sinatra_helpers/erb/forms.rb
|
104
|
+
- lib/sinatra_helpers/erb/links.rb
|
103
105
|
- lib/sinatra_helpers/erb/partials.rb
|
106
|
+
- lib/sinatra_helpers/erb/proper.rb
|
107
|
+
- lib/sinatra_helpers/erb/tags.rb
|
104
108
|
- lib/sinatra_helpers/erb.rb
|
105
109
|
- lib/sinatra_helpers/generator/app.rb
|
106
110
|
- lib/sinatra_helpers/generator/file_templates/app.js.erb
|