doozer 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
data/doozer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{doozer}
8
- s.version = "0.2.5"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["grippy"]
12
- s.date = %q{2009-10-26}
12
+ s.date = %q{2009-10-27}
13
13
  s.default_executable = %q{doozer}
14
14
  s.description = %q{This GEM provides a small, barebones framework for creating MVC Rack applications.}
15
15
  s.email = %q{gmelton@whorde.com}
@@ -72,7 +72,7 @@ Gem::Specification.new do |s|
72
72
  "templates/skeleton/app/views/index/index.html.erb",
73
73
  "templates/skeleton/app/views/layouts/default.html.erb",
74
74
  "templates/skeleton/config/app.yml",
75
- "templates/skeleton/config/boot.rb",
75
+ "templates/skeleton/config/boot.erb",
76
76
  "templates/skeleton/config/database.yml",
77
77
  "templates/skeleton/config/environment.rb",
78
78
  "templates/skeleton/config/rack.rb",
data/lib/doozer/app.rb CHANGED
@@ -257,10 +257,12 @@ module Doozer
257
257
  puts "modified: #{file}"
258
258
  load_files
259
259
  Doozer::Partial.clear_loaded_partials
260
+ Doozer::Configs.clear_static_files
260
261
  elsif(status == FileSystemWatcher::DELETED) then
261
262
  puts "deleted: #{file}"
262
263
  load_files
263
264
  Doozer::Partial.clear_loaded_partials
265
+ Doozer::Configs.clear_static_files
264
266
  end
265
267
  }
266
268
  #don't join the thread it messes up rackup threading watcher.join()
@@ -10,6 +10,8 @@ module Doozer
10
10
  class Configs
11
11
  @@possible_orm = [:active_record, :data_mapper, :sequel]
12
12
  @@app_path = nil
13
+ @@static_file = {}
14
+ @@orm_loaded = false
13
15
 
14
16
  # Load all the config files for the application. Also instantiates a default application Logger.
15
17
  def self.load(rack_env)
@@ -100,7 +102,7 @@ module Doozer
100
102
  end
101
103
 
102
104
  def self.orm_loaded
103
- @@orm_loaded || false
105
+ @@orm_loaded
104
106
  end
105
107
 
106
108
  def self.orm_loaded=(t)
@@ -130,8 +132,13 @@ module Doozer
130
132
  # Return the app name
131
133
  def self.app_name
132
134
  self.app["name"] || ""
133
- end
135
+ end
134
136
 
137
+ # Return the app name
138
+ def self.static_root
139
+ self.app["static_root"] || ""
140
+ end
141
+
135
142
  # Return the app 404 url
136
143
  def self.page_not_found_url
137
144
  self.app[404] || nil
@@ -142,5 +149,27 @@ module Doozer
142
149
  self.app[500] || nil
143
150
  end
144
151
 
152
+ def self.static_url(path)
153
+ return path if path.index('http://') or path.index('https://')
154
+ key = "#{@@app_path}/#{static_root}#{path}"
155
+ if not @@static_file[key].nil?
156
+ return "#{path}?#{@@static_file[key]}"
157
+ else
158
+ begin
159
+ time = File.stat(key).mtime
160
+ hash = Digest::SHA1.hexdigest(time.to_s)[0...5]
161
+ @@static_file[key] = hash
162
+ return "#{path}?#{hash}"
163
+ rescue => e
164
+ logger.error(e.to_s)
165
+ end
166
+ end
167
+ return path
168
+ end
169
+
170
+ def self.clear_static_files
171
+ @@static_file = {}
172
+ end
173
+
145
174
  end
146
175
  end
@@ -270,7 +270,7 @@ module Doozer
270
270
  # Controller hook called after controller#method call
271
271
  def after_filter; end
272
272
 
273
- # Global tear called at the end of every request. Hooks ORM.teardown
273
+ # Global teardown called at the end of every request. Hooks ORM.teardown
274
274
  def finished!
275
275
  Doozer::ORM.after_request if Doozer::Configs.orm_loaded
276
276
  end
data/lib/doozer/lib.rb CHANGED
@@ -27,6 +27,5 @@ module Doozer
27
27
  end
28
28
  s
29
29
  end
30
-
31
30
  end
32
31
  end
@@ -2,7 +2,7 @@ module Doozer
2
2
  module Version
3
3
  MAJOR=0
4
4
  MINOR=2
5
- PATCH=5
5
+ PATCH=6
6
6
  STRING=[MAJOR, MINOR, PATCH].join('.')
7
7
  end
8
8
  end
@@ -75,8 +75,7 @@ module Doozer
75
75
  #
76
76
  # prop - a hash of image tag attributes
77
77
  def img(path, prop={})
78
- path = timestamp_path(path)
79
- "<img src=\"#{path}\"#{hash_to_props(prop)} />"
78
+ "<img src=\"#{static_url(path)}\"#{hash_to_props(prop)} />"
80
79
  end
81
80
 
82
81
  # Creates a stylesheet link tag.
@@ -88,11 +87,10 @@ module Doozer
88
87
  # => Defaults to :rel=>'stylesheet', :type=>'text/css', :media=>'all'
89
88
  def stylesheet(path, prop={})
90
89
  #<link rel="stylesheet" type="text/css" media="all" href="/css/style.css" />
91
- path = timestamp_path(path)
92
90
  prop[:rel] = 'stylesheet' if prop[:rel].nil?
93
91
  prop[:type] = 'text/css' if prop[:type].nil?
94
92
  prop[:media] = 'all' if prop[:media].nil?
95
- "<link #{hash_to_props(prop)} href=\"#{path}\" />"
93
+ "<link #{hash_to_props(prop)} href=\"#{static_url(path)}\" />"
96
94
  end
97
95
 
98
96
  # Creates a link tag for feeds.
@@ -114,9 +112,18 @@ module Doozer
114
112
  #
115
113
  # => Defaults to: :type=>'text/javascript'
116
114
  def javascript(path, prop={})
117
- path = timestamp_path(path)
118
115
  prop[:type] = 'text/javascript' if prop[:type].nil?
119
- "<script #{hash_to_props(prop)} src=\"#{path}\"></script>"
116
+ "<script #{hash_to_props(prop)} src=\"#{static_url(path)}\"></script>"
117
+ end
118
+
119
+
120
+ # Creates a url for static files
121
+ #
122
+ # hahses the file date and appends it to the end of the file for cache busting...
123
+ #
124
+ #
125
+ def static_url(path)
126
+ Doozer::Configs.static_url(path)
120
127
  end
121
128
 
122
129
  # Creates metatags
@@ -1,3 +1,5 @@
1
+ require 'erb'
2
+
1
3
  module Doozer
2
4
 
3
5
  #= Generate Project Skeletons and Files
@@ -349,7 +351,7 @@ Task - Create a task file in project/tasks with the class name of TaskName.
349
351
 
350
352
  # TODO: Dry this up...
351
353
  def self.skeleton(name)
352
-
354
+
353
355
  # create application skeleton
354
356
  if not File.exist?(name)
355
357
  p "Creating #{name}/"
@@ -435,7 +437,12 @@ Task - Create a task file in project/tasks with the class name of TaskName.
435
437
  system("cp #{skeleton_path 'config/*.rb'} #{name}/config")
436
438
 
437
439
  ## load boot.erb replace version number and save as boot.rb
438
-
440
+ boot_skel = skeleton_path 'config/boot.erb'
441
+ results = []
442
+ @version = Doozer::Version::STRING
443
+ File.new(boot_skel, "r").each { |line| results << line }
444
+ boot = ERB.new(results.join(""))
445
+ File.open("#{name}/config/boot.rb", 'w') {|f| f.write(boot.result(binding)) }
439
446
  else
440
447
  p "Skipping #{name}/config directory (already exists)"
441
448
  end
@@ -1,4 +1,4 @@
1
- DOOZER_GEM_VERSION='0.2.5'
1
+ DOOZER_GEM_VERSION='<%=@version%>'
2
2
 
3
3
  require 'date'
4
4
  require 'rubygems'
@@ -7,5 +7,5 @@ begin
7
7
  gem 'doozer', "= #{DOOZER_GEM_VERSION}"
8
8
  require 'doozer'
9
9
  rescue Gem::LoadError
10
- raise "grippy-doozer-#{DOOZER_GEM_VERSION} gem not installed"
10
+ raise "doozer-#{DOOZER_GEM_VERSION} gem not installed"
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doozer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - grippy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-26 00:00:00 -07:00
12
+ date: 2009-10-27 00:00:00 -07:00
13
13
  default_executable: doozer
14
14
  dependencies: []
15
15
 
@@ -76,7 +76,7 @@ files:
76
76
  - templates/skeleton/app/views/index/index.html.erb
77
77
  - templates/skeleton/app/views/layouts/default.html.erb
78
78
  - templates/skeleton/config/app.yml
79
- - templates/skeleton/config/boot.rb
79
+ - templates/skeleton/config/boot.erb
80
80
  - templates/skeleton/config/database.yml
81
81
  - templates/skeleton/config/environment.rb
82
82
  - templates/skeleton/config/rack.rb