roger_themes 0.3.0 → 0.4.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: a509ded3df0137eb3a297dac0fbc2b53375c5b21
4
- data.tar.gz: 77e911078d4f2092123c38ba08471e0f29294db6
3
+ metadata.gz: 6b72e6fba70a480098551b1f513c9058a5a9cf7e
4
+ data.tar.gz: 034d928755f8362f5d67202ba7c889025fdf0727
5
5
  SHA512:
6
- metadata.gz: 46c1970744052789bacaac8e47ec780ba0806efb70f2cd4ce1603087bfc622e096ed2fee751d1e17a8c2a830888d6caa6abee17954fc45a12355b8bbfa28815b
7
- data.tar.gz: 3060c2b37a403c0ececb828fe06777290126d773e68f756a7f6514b9d0548724f2fb74a7726f14de5adf9969897786629e6ac7cfa3bb706ad975b7618d1eeb81
6
+ metadata.gz: d112e902c4ea612e0256ccfb88161d7144047ad1645eed1ef063930179391e4c2190d889c14097707e23e79b2502271d7fd70475e9a2affe77efa3f65bdcbe50
7
+ data.tar.gz: 6512d6905aac96b5bfa387ab4ba40379e874f01ce0892dd328fd376816c259febed7e68b6524773241063ef9978d45ccc5c62c7773da551aad4fc9d47fc6a803
data/README.md CHANGED
@@ -48,6 +48,10 @@ mockup.release do |r|
48
48
 
49
49
  ## Changelog
50
50
 
51
+ ### v0.4.0
52
+
53
+ * Resolve issue around shared paths (#1)
54
+
51
55
  ### v0.1.2
52
56
 
53
57
  * Fix dir merging when a local folder exists
@@ -2,6 +2,8 @@ require File.dirname(__FILE__) + "/shared_folders"
2
2
 
3
3
  module RogerThemes
4
4
  class Middleware
5
+ attr_accessor :project
6
+
5
7
  def initialize(app, options = {})
6
8
  @app = app
7
9
 
@@ -29,7 +31,7 @@ module RogerThemes
29
31
  ret = @app.call(env)
30
32
 
31
33
  # Fallback for shared images
32
- unless ret[0] == 200
34
+ if ret[0] == 404
33
35
 
34
36
  shared_path = @shared_folders.local_to_shared_path(path)
35
37
 
@@ -57,6 +57,8 @@ module RogerThemes
57
57
  "MOCKUP_PROJECT" => release.project
58
58
  }
59
59
  })
60
+
61
+ release.log self, "Running mockup processor for theme: #{theme}"
60
62
  mockup_processor.call(release)
61
63
 
62
64
  # cp html/images and html/fonts => html/themes/**/images && html/themes/**/fonts
@@ -1,3 +1,3 @@
1
1
  module RogerThemes
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1 @@
1
+ <h1>My awesome theme index file!</h1>
@@ -1,18 +1,43 @@
1
1
  require "test_helper"
2
+ require "rack/mock"
3
+ require "roger/testing/mock_project"
4
+
2
5
  require "./lib/roger_themes/middleware"
3
6
 
4
- require "rack/mock"
7
+ class MockApp
8
+ attr_reader :call_stack
9
+ attr_writer :return_value
10
+
11
+ def initialize()
12
+ @call_stack = []
13
+
14
+ @return_value = [200, {}, ["YAM"]]
15
+ end
16
+
17
+ def call(env)
18
+ @call_stack.push env.dup
19
+ @return_value
20
+ end
21
+ end
22
+
5
23
 
6
24
  module RogerThemes
7
25
  class TestMiddleware < ::Test::Unit::TestCase
8
26
 
9
27
  def setup
10
- @app = proc { [200, {}, ["YAM"]] } # Yet another middleware
28
+ @app = MockApp.new # Yet another middleware
11
29
  @middleware = Middleware.new @app
12
30
 
31
+ # Inject mock project
32
+ @middleware.project = Roger::Testing::MockProject.new("test/fixture")
33
+
13
34
  @request = Rack::MockRequest.new(@middleware)
14
35
  end
15
36
 
37
+ def teardown
38
+ @middleware.project.destroy
39
+ end
40
+
16
41
  def test_middleware_can_be_called
17
42
  assert(@middleware.respond_to?(:call))
18
43
  end
@@ -21,5 +46,30 @@ module RogerThemes
21
46
  assert_equal @request.get("/my.js").body, "YAM"
22
47
  end
23
48
 
49
+ # Theme links work by means of rewriting the path info i.e.
50
+ # to render and setting the env[site_theme] var
51
+ def test_theme_links
52
+ @request.get("/themes/my-awesome-theme/theme/elements/index.html")
53
+ assert_equal @app.call_stack.length, 1
54
+ assert_equal @app.call_stack[0]["SITE_THEME"], "my-awesome-theme"
55
+ assert_equal @app.call_stack[0]["PATH_INFO"], "elements/index.html"
56
+ end
57
+
58
+ def test_shared_resources
59
+ # Shared resource will update the PATH_INFO to render a shared image or font
60
+ @app.return_value = [404, {}, ["YAM"]]
61
+ @request.get("/themes/my-awesome-theme/images/fancy.png")
62
+ assert_equal @app.call_stack.length, 2
63
+ assert_equal @app.call_stack[1]["PATH_INFO"], "/images/fancy.png"
64
+ end
65
+
66
+ def test_shared_resources_when_not_modified_is_returned
67
+ @app.return_value = [304, {}, ["YAM"]]
68
+ @request.get("/themes/my-awesome-theme/images/fancy.png")
69
+ assert_equal @app.call_stack.length, 1
70
+ assert_equal @app.call_stack[0]["PATH_INFO"], "/themes/my-awesome-theme/images/fancy.png"
71
+ end
72
+
73
+
24
74
  end
25
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roger_themes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin van der Graaf
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-28 00:00:00.000000000 Z
12
+ date: 2016-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: roger
@@ -116,6 +116,7 @@ files:
116
116
  - lib/roger_themes/version.rb
117
117
  - lib/roger_themes/xc_finalizer.rb
118
118
  - roger_themes.gemspec
119
+ - test/fixture/html/themes/my-awesome-theme/index.html
119
120
  - test/middleware_test.rb
120
121
  - test/processor_test.rb
121
122
  - test/shared_folders_test.rb
@@ -145,6 +146,7 @@ signing_key:
145
146
  specification_version: 4
146
147
  summary: Create themes and release them as static site
147
148
  test_files:
149
+ - test/fixture/html/themes/my-awesome-theme/index.html
148
150
  - test/middleware_test.rb
149
151
  - test/processor_test.rb
150
152
  - test/shared_folders_test.rb