appcache-manifest 0.0.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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,37 @@
1
+ require "appcache-manifest/version"
2
+ require "appcache-manifest/configuration"
3
+
4
+ module Appcache
5
+ class Manifest
6
+ def self.configure(*args, &block)
7
+ new(*args, &block)
8
+ end
9
+
10
+ def initialize(options = {}, &block)
11
+ @@config = Appcache::Config.new(&block)
12
+ set_route
13
+ end
14
+
15
+ def set_route
16
+ Rails.application.routes.draw do
17
+ match @@config.manifest_url => Proc.new {
18
+ manifest_file = "#{Rails.root.to_s}/public/#{Rails.application.config.assets.prefix}/manifest.yml"
19
+ if File.exists?(manifest_file)
20
+ manifest = YAML::load(IO.read(manifest_file))
21
+
22
+ body = ["CACHE MANIFEST"]
23
+ body << "# #{@@config.to_json}"
24
+ for key,value in manifest
25
+ body << Rails.application.config.assets.prefix + "/" + value
26
+ end
27
+ body << "" << "NETWORK: *"
28
+
29
+ [200, {"Content-Type" => "text/cache-manifest"}, [body.join("\n")]]
30
+ else
31
+ [400, {"Content-Type" => "text/html"}, ["File not found"]]
32
+ end
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ module Appcache
2
+ class Config
3
+
4
+ OPTIONS = [
5
+ :manifest_url
6
+ ]
7
+
8
+ def initialize(&block)
9
+ set_getter_setter
10
+ set_defaults
11
+ instance_eval(&block) if block_given?
12
+ end
13
+
14
+ def set_defaults
15
+ @manifest_url = "/application.manifest"
16
+ end
17
+
18
+ def set_getter_setter
19
+ instance_eval(OPTIONS.map do |option|
20
+ o = option.to_s
21
+ <<-EOS
22
+ def #{o}
23
+ @#{o}
24
+ end
25
+
26
+ def #{o}=(value)
27
+ @#{o} = value
28
+ end
29
+ EOS
30
+ end.join("\n\n"))
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module Appcache
2
+ class Manifest
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appcache-manifest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Antoine Grant
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ''
15
+ email:
16
+ - antoinegrant@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Rakefile
23
+ - lib/appcache-manifest.rb
24
+ - lib/appcache-manifest/configuration.rb
25
+ - lib/appcache-manifest/version.rb
26
+ homepage: ''
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 1.8.24
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: Convert manifest.yml to application.manifest and add a route to point to
50
+ it.
51
+ test_files: []