bagger 0.1.0 → 0.1.1

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.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v 0.1.1
4
+
5
+ * Do not version cache manifest (http://diveintohtml5.org/offline.html)
6
+
3
7
  ## v 0.1.0
4
8
 
5
9
  * Combine javascript and stylesheets into several packages
@@ -20,6 +20,10 @@ module Bagger
20
20
  @manifest = {}
21
21
  end
22
22
 
23
+ def add_to_manifest(key, path)
24
+ @manifest[key] = File.expand_path(@path_prefix + "/" + path)
25
+ end
26
+
23
27
  def to_manifest(path, keep_original = true)
24
28
  content = File.open(File.join(@target_dir, path)) { |f| f.read }
25
29
  extension = File.extname(path)
@@ -32,9 +36,8 @@ module Bagger
32
36
  File.open(new_file_path, 'w') { |f| f.write content }
33
37
  FileUtils.rm(File.join(@target_dir, path)) unless keep_original
34
38
  manifest_key_path = File.expand_path("/#{dirname}/#{basename}#{extension}")
35
- effective_path = File.expand_path(@path_prefix + "/" + File.join(dirname, new_file_name))
36
- @manifest[manifest_key_path] = effective_path
37
- end
39
+ add_to_manifest(manifest_key_path, File.join(dirname, new_file_name))
40
+ end
38
41
 
39
42
  def stylesheets
40
43
  @stylesheets ||= calculate_stylesheets
@@ -49,7 +52,7 @@ module Bagger
49
52
  version_files
50
53
  combine_css
51
54
  combine_js
52
- generate_and_version_cache_manifest
55
+ generate_cache_manifest
53
56
  write_manifest
54
57
  end
55
58
 
@@ -127,7 +130,11 @@ module Bagger
127
130
  File.open(File.join(@target_dir, javascript_path), 'w'){|f| f.write compressed}
128
131
  end
129
132
 
130
- def generate_and_version_cache_manifest
133
+ # IMPORTANT:html 5 cache manifest should not be cached
134
+ # because that would treat it as a new manifest with
135
+ # new resources discarding the ones already downloaded
136
+ # http://diveintohtml5.org/offline.html
137
+ def generate_cache_manifest
131
138
  path = File.join(@target_dir, @cache_manifest_path)
132
139
  FileUtils.mkdir_p(File.dirname(path))
133
140
  File.open(path, 'w') do |f|
@@ -139,7 +146,7 @@ module Bagger
139
146
  f.puts 'NETWORK:'
140
147
  f.puts '*'
141
148
  end
142
- to_manifest(@cache_manifest_path)
149
+ add_to_manifest(File.join("/", @cache_manifest_path), @cache_manifest_path)
143
150
  end
144
151
 
145
152
  protected
@@ -1,3 +1,3 @@
1
1
  module Bagger
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/test/bagger_test.rb CHANGED
@@ -90,13 +90,13 @@ class BaggerTest < Test::Unit::TestCase
90
90
 
91
91
  should 'add the cache manifest to the manifest' do
92
92
  Bagger.bagit!(default_options)
93
- assert_match /\/cache\..*\.manifest/, manifest['/cache.manifest']
93
+ assert_equal "/cache.manifest", manifest['/cache.manifest']
94
94
  end
95
95
 
96
- should 'create a versioned cache manifest' do
96
+ should 'not version the cache manifest (http://diveintohtml5.org/offline.html)' do
97
97
  Bagger.bagit!(default_options)
98
- expected_path = File.join(@target_dir, manifest['/cache.manifest'])
99
- assert File.exists?(expected_path), 'versioned cache manifest not found'
98
+ expected_path = File.join(@target_dir, 'cache.manifest')
99
+ assert File.exists?(expected_path), 'unversionened cache manifest not found'
100
100
  end
101
101
 
102
102
  should 'allow to specify the path' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-12 00:00:00.000000000 Z
12
+ date: 2011-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70153224223720 !ruby/object:Gem::Requirement
16
+ requirement: &70212879727180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70153224223720
24
+ version_requirements: *70212879727180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: addressable
27
- requirement: &70153224223120 !ruby/object:Gem::Requirement
27
+ requirement: &70212879721620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70153224223120
35
+ version_requirements: *70212879721620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: uglifier
38
- requirement: &70153224222560 !ruby/object:Gem::Requirement
38
+ requirement: &70212879718780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70153224222560
46
+ version_requirements: *70212879718780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rainpress
49
- requirement: &70153224221960 !ruby/object:Gem::Requirement
49
+ requirement: &70212879718260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70153224221960
57
+ version_requirements: *70212879718260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70153224221440 !ruby/object:Gem::Requirement
60
+ requirement: &70212879717020 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70153224221440
68
+ version_requirements: *70212879717020
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: shoulda-context
71
- requirement: &70153224220920 !ruby/object:Gem::Requirement
71
+ requirement: &70212879716160 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70153224220920
79
+ version_requirements: *70212879716160
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: mocha
82
- requirement: &70153224220300 !ruby/object:Gem::Requirement
82
+ requirement: &70212879715420 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70153224220300
90
+ version_requirements: *70212879715420
91
91
  description: ! 'A framework agnostic packaging solution for your assets: version files,
92
92
  combine them, minify them and create a manifest'
93
93
  email: