imprenta 0.0.3 → 0.0.4

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +6 -0
  4. data/README.md +55 -4
  5. data/Rakefile +11 -0
  6. data/imprenta.gemspec +5 -1
  7. data/lib/imprenta/cache_page.rb +8 -17
  8. data/lib/imprenta/configuration.rb +5 -0
  9. data/lib/imprenta/content_rack.rb +27 -0
  10. data/lib/imprenta/content_server/file.rb +36 -0
  11. data/lib/imprenta/content_server/s3.rb +32 -0
  12. data/lib/imprenta/rails.rb +5 -1
  13. data/lib/imprenta/static_server.rb +3 -7
  14. data/lib/imprenta/storage/S3.rb +39 -0
  15. data/lib/imprenta/storage/file.rb +25 -0
  16. data/lib/imprenta/version.rb +1 -1
  17. data/lib/imprenta.rb +7 -3
  18. data/spec/configuration_spec.rb +57 -0
  19. data/spec/dummy/README.rdoc +261 -0
  20. data/spec/dummy/Rakefile +7 -0
  21. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  22. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  23. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  24. data/spec/dummy/app/controllers/home_controller.rb +10 -0
  25. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  26. data/spec/dummy/app/mailers/.gitkeep +0 -0
  27. data/spec/dummy/app/models/.gitkeep +0 -0
  28. data/spec/dummy/app/views/home/dummy.html.erb +1 -0
  29. data/spec/dummy/app/views/home/index.html.erb +1 -0
  30. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  31. data/spec/dummy/config/application.rb +17 -0
  32. data/spec/dummy/config/boot.rb +10 -0
  33. data/spec/dummy/config/database.yml +25 -0
  34. data/spec/dummy/config/environment.rb +5 -0
  35. data/spec/dummy/config/environments/development.rb +12 -0
  36. data/spec/dummy/config/environments/production.rb +12 -0
  37. data/spec/dummy/config/environments/test.rb +12 -0
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/spec/dummy/config/initializers/inflections.rb +15 -0
  40. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  41. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  42. data/spec/dummy/config/initializers/session_store.rb +8 -0
  43. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/spec/dummy/config/locales/en.yml +5 -0
  45. data/spec/dummy/config/routes.rb +5 -0
  46. data/spec/dummy/config.ru +4 -0
  47. data/spec/dummy/db/test.sqlite3 +0 -0
  48. data/spec/dummy/lib/assets/.gitkeep +0 -0
  49. data/spec/dummy/log/.gitkeep +0 -0
  50. data/spec/dummy/public/404.html +26 -0
  51. data/spec/dummy/public/422.html +26 -0
  52. data/spec/dummy/public/500.html +25 -0
  53. data/spec/dummy/public/favicon.ico +0 -0
  54. data/spec/dummy/script/rails +6 -0
  55. data/spec/features/publish_spec.rb +26 -0
  56. data/spec/file_storage_spec.rb +25 -0
  57. data/spec/spec_helper.rb +16 -0
  58. data/spec/support/dummy_rack.rb +5 -0
  59. metadata +152 -9
  60. data/lib/imprenta/file_rack.rb +0 -48
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Imprenta::Storage::File do
4
+ let(:storage) { described_class.new}
5
+
6
+ after do
7
+ FileUtils.rm_rf(File.join([File.dirname(__FILE__), "dummy", "public", "imprenta"]))
8
+ end
9
+
10
+ context "#persist" do
11
+ let(:path) { Rails.public_path.to_s + '/imprenta/test.html' }
12
+
13
+ it "creates html and html.gz files for the cached content" do
14
+ storage.persist("test", "test")
15
+ expect(File.exist?(path)).to be_true
16
+ expect(File.exist?(path + '.gz')).to be_true
17
+ end
18
+
19
+ it "creates file with the content provided" do
20
+ storage.persist("test", "test")
21
+ file = File.open(path, 'r')
22
+ expect(file.read).to eq("test")
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
10
+
11
+ RSpec.configure do |config|
12
+ config.mock_with :rspec
13
+ config.use_transactional_fixtures = true
14
+ config.infer_base_class_for_anonymous_controllers = false
15
+ config.order = "random"
16
+ end
@@ -0,0 +1,5 @@
1
+ class DummyRack
2
+ def call(env)
3
+ [200, nil, nil]
4
+ end
5
+ end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imprenta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Chacon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-31 00:00:00.000000000 Z
11
+ date: 2013-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: fog
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -25,19 +53,47 @@ dependencies:
25
53
  - !ruby/object:Gem::Version
26
54
  version: '1.3'
27
55
  - !ruby/object:Gem::Dependency
28
- name: rails
56
+ name: sqlite3
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
- - - ~>
59
+ - - '>='
32
60
  - !ruby/object:Gem::Version
33
- version: 4.0.0
61
+ version: '0'
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
- - - ~>
66
+ - - '>='
39
67
  - !ruby/object:Gem::Version
40
- version: 4.0.0
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: capybara
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
41
97
  - !ruby/object:Gem::Dependency
42
98
  name: rake
43
99
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +116,7 @@ extensions: []
60
116
  extra_rdoc_files: []
61
117
  files:
62
118
  - .gitignore
119
+ - .travis.yml
63
120
  - Gemfile
64
121
  - LICENSE.txt
65
122
  - README.md
@@ -68,10 +125,55 @@ files:
68
125
  - lib/imprenta.rb
69
126
  - lib/imprenta/cache_page.rb
70
127
  - lib/imprenta/configuration.rb
71
- - lib/imprenta/file_rack.rb
128
+ - lib/imprenta/content_rack.rb
129
+ - lib/imprenta/content_server/file.rb
130
+ - lib/imprenta/content_server/s3.rb
72
131
  - lib/imprenta/rails.rb
73
132
  - lib/imprenta/static_server.rb
133
+ - lib/imprenta/storage/S3.rb
134
+ - lib/imprenta/storage/file.rb
74
135
  - lib/imprenta/version.rb
136
+ - spec/configuration_spec.rb
137
+ - spec/dummy/README.rdoc
138
+ - spec/dummy/Rakefile
139
+ - spec/dummy/app/assets/javascripts/application.js
140
+ - spec/dummy/app/assets/stylesheets/application.css
141
+ - spec/dummy/app/controllers/application_controller.rb
142
+ - spec/dummy/app/controllers/home_controller.rb
143
+ - spec/dummy/app/helpers/application_helper.rb
144
+ - spec/dummy/app/mailers/.gitkeep
145
+ - spec/dummy/app/models/.gitkeep
146
+ - spec/dummy/app/views/home/dummy.html.erb
147
+ - spec/dummy/app/views/home/index.html.erb
148
+ - spec/dummy/app/views/layouts/application.html.erb
149
+ - spec/dummy/config.ru
150
+ - spec/dummy/config/application.rb
151
+ - spec/dummy/config/boot.rb
152
+ - spec/dummy/config/database.yml
153
+ - spec/dummy/config/environment.rb
154
+ - spec/dummy/config/environments/development.rb
155
+ - spec/dummy/config/environments/production.rb
156
+ - spec/dummy/config/environments/test.rb
157
+ - spec/dummy/config/initializers/backtrace_silencers.rb
158
+ - spec/dummy/config/initializers/inflections.rb
159
+ - spec/dummy/config/initializers/mime_types.rb
160
+ - spec/dummy/config/initializers/secret_token.rb
161
+ - spec/dummy/config/initializers/session_store.rb
162
+ - spec/dummy/config/initializers/wrap_parameters.rb
163
+ - spec/dummy/config/locales/en.yml
164
+ - spec/dummy/config/routes.rb
165
+ - spec/dummy/db/test.sqlite3
166
+ - spec/dummy/lib/assets/.gitkeep
167
+ - spec/dummy/log/.gitkeep
168
+ - spec/dummy/public/404.html
169
+ - spec/dummy/public/422.html
170
+ - spec/dummy/public/500.html
171
+ - spec/dummy/public/favicon.ico
172
+ - spec/dummy/script/rails
173
+ - spec/features/publish_spec.rb
174
+ - spec/file_storage_spec.rb
175
+ - spec/spec_helper.rb
176
+ - spec/support/dummy_rack.rb
75
177
  homepage: https://github.com/skyscrpr/imprenta
76
178
  licenses:
77
179
  - MIT
@@ -97,4 +199,45 @@ signing_key:
97
199
  specification_version: 4
98
200
  summary: This gem helps the process of publishing and serving static pages within
99
201
  rails
100
- test_files: []
202
+ test_files:
203
+ - spec/configuration_spec.rb
204
+ - spec/dummy/README.rdoc
205
+ - spec/dummy/Rakefile
206
+ - spec/dummy/app/assets/javascripts/application.js
207
+ - spec/dummy/app/assets/stylesheets/application.css
208
+ - spec/dummy/app/controllers/application_controller.rb
209
+ - spec/dummy/app/controllers/home_controller.rb
210
+ - spec/dummy/app/helpers/application_helper.rb
211
+ - spec/dummy/app/mailers/.gitkeep
212
+ - spec/dummy/app/models/.gitkeep
213
+ - spec/dummy/app/views/home/dummy.html.erb
214
+ - spec/dummy/app/views/home/index.html.erb
215
+ - spec/dummy/app/views/layouts/application.html.erb
216
+ - spec/dummy/config.ru
217
+ - spec/dummy/config/application.rb
218
+ - spec/dummy/config/boot.rb
219
+ - spec/dummy/config/database.yml
220
+ - spec/dummy/config/environment.rb
221
+ - spec/dummy/config/environments/development.rb
222
+ - spec/dummy/config/environments/production.rb
223
+ - spec/dummy/config/environments/test.rb
224
+ - spec/dummy/config/initializers/backtrace_silencers.rb
225
+ - spec/dummy/config/initializers/inflections.rb
226
+ - spec/dummy/config/initializers/mime_types.rb
227
+ - spec/dummy/config/initializers/secret_token.rb
228
+ - spec/dummy/config/initializers/session_store.rb
229
+ - spec/dummy/config/initializers/wrap_parameters.rb
230
+ - spec/dummy/config/locales/en.yml
231
+ - spec/dummy/config/routes.rb
232
+ - spec/dummy/db/test.sqlite3
233
+ - spec/dummy/lib/assets/.gitkeep
234
+ - spec/dummy/log/.gitkeep
235
+ - spec/dummy/public/404.html
236
+ - spec/dummy/public/422.html
237
+ - spec/dummy/public/500.html
238
+ - spec/dummy/public/favicon.ico
239
+ - spec/dummy/script/rails
240
+ - spec/features/publish_spec.rb
241
+ - spec/file_storage_spec.rb
242
+ - spec/spec_helper.rb
243
+ - spec/support/dummy_rack.rb
@@ -1,48 +0,0 @@
1
- module Imprenta
2
- class FileRack
3
- attr_accessor :custom_domain
4
-
5
- def initialize(args = {})
6
- @custom_domain = args[:custom_domain]
7
- end
8
-
9
- def call(env)
10
- request = ::Rack::Request.new(env)
11
- path = custom_domain ? env["SERVER_NAME"] : id_from_env(env)
12
-
13
- raise ::ActionController::RoutingError.exception("Page Not Found") unless path
14
-
15
- file, headers = pick_file_and_headers_for_path(path, request)
16
- env.merge!("PATH_INFO" => "/")
17
- ::Rack::File.new(file, headers).call(env)
18
- end
19
-
20
- private
21
-
22
- def id_from_env(env)
23
- env["action_dispatch.request.path_parameters"][:id]
24
- end
25
-
26
- def get_best_encoding(request)
27
- ::Rack::Utils.select_best_encoding(%w(gzip identity), request.accept_encoding)
28
- end
29
-
30
- def headers
31
- @headers ||= {'Content-Type' => 'text/html' }
32
- end
33
-
34
- def pick_file_and_headers_for_path(path, request)
35
- encoding = get_best_encoding(request)
36
- file = "#{Rails.public_path}/imprenta/" + path + '.html'
37
- if File.exist?(file)
38
- if encoding == 'gzip'
39
- file = file + '.gz'
40
- headers['Content-Encoding'] = 'gzip'
41
- end
42
- else
43
- raise ::ActionController::RoutingError.exception("Page Not Found")
44
- end
45
- [file, headers]
46
- end
47
- end
48
- end