rails-static 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 874baed57ec25bdca7c934d805e7394586fd9736
4
- data.tar.gz: 458628d2a4014570f3f321b4caf4ed2c39a6df42
3
+ metadata.gz: ba79014208d1a8e1629703999efa4432f7eb7249
4
+ data.tar.gz: 9d4e466039ed62f5fd2766fb9bb44a95d310ad51
5
5
  SHA512:
6
- metadata.gz: e714989e28b1e2223c4a0381d5ac0a90e9dc0de7e1e9565bd445a8bfba51bd4611301fcfce828f5adefa4c5c04d2dddae569dd1f4a5fcc791f0f13d3ed27233b
7
- data.tar.gz: 9936b41c13510313f02ae6a8eeafab781949d444179fc9a21868aee0082a57b03c5b12319641c55a3e16b9dfe6919d86bf7d40ce04caf2cbb65e623022249b7c
6
+ metadata.gz: 47eba128e94a5c2f4ce4724ba12a901a970a35f4198edf81f5c8aef62e1fd70c47eba7417259ddc9167d3fe0b0a540f54f0ac6a2a7da05727716bcd9e347f3c0
7
+ data.tar.gz: 10132bbe8f260f1801d22d8182c8f81f95b61a452a511eab494f9fe7628b9ceb7cdd5bd3c65bf327c01f57c0106aadd810729822db3f34136ff3afb718702749
@@ -18,5 +18,15 @@ module RailsStatic
18
18
  yield @config
19
19
  end
20
20
 
21
+ def files
22
+ config.routes.map {|r| path_from_route r }
23
+ end
24
+
25
+ def path_from_route(route)
26
+ path = route.gsub %r{^/}, ''
27
+ path = path.gsub(%r{/$}, "/#{RailsStatic.config.index}") if route =~ %r{/$}
28
+ path += RailsStatic.config.extension
29
+ end
30
+
21
31
  end
22
32
  end
@@ -16,13 +16,15 @@ namespace :static do
16
16
 
17
17
  RailsStatic.config.routes.each do |route|
18
18
 
19
- path = path_from_route route
19
+ path = RailsStatic.path_from_route route
20
+ fullpath = full_path path
20
21
 
21
22
  print "Generating #{path} "
22
23
 
24
+ File.delete fullpath if File.exists? fullpath
25
+
23
26
  r = app.get(route)
24
27
 
25
- fullpath = full_path path
26
28
  dir = File.dirname(fullpath)
27
29
  FileUtils.mkdir_p dir
28
30
  File.open(fullpath, "w") do |f|
@@ -36,7 +38,7 @@ namespace :static do
36
38
  desc "Delete static pages"
37
39
  task :clean => :environment do
38
40
  RailsStatic.config.routes.each do |route|
39
- path = path_from_route route
41
+ path = RailsStatic.path_from_route route
40
42
  fullpath = full_path path
41
43
 
42
44
  next unless File.exists? fullpath
@@ -51,12 +53,6 @@ namespace :static do
51
53
 
52
54
  private
53
55
 
54
- def path_from_route(route)
55
- path = route
56
- path = path.gsub(%r{/$}, "/#{RailsStatic.config.index}") if route =~ %r{/$}
57
- path += RailsStatic.config.extension
58
- end
59
-
60
56
  def full_path(path)
61
57
  File.join(Rails.public_path, path)
62
58
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rails-static"
6
- s.version = '1.1.0'
6
+ s.version = '1.2.0'
7
7
  s.authors = ["DanX"]
8
8
  s.email = ["danx.exe@gmail.com"]
9
9
  s.homepage = "http://danx.in"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-static
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DanX
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-02 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A rake task for generating static websites using Rails.
14
14
  email: