seory 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/seory.rb +4 -0
- data/lib/seory/dsl.rb +15 -11
- data/lib/seory/repository.rb +18 -0
- data/lib/seory/runtime.rb +1 -3
- data/lib/seory/version.rb +1 -1
- data/spec/seory/dsl_spec.rb +3 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 255ce5bf7ad7b79b1c1ba7b647c83bae44377685
|
4
|
+
data.tar.gz: 93d4ddd0a609d7403cb616da854ad06ce95ed540
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 593351c2bba8912fd3aa0b1500ba53ee22c88b39c6475936b0ad362ab482cce9004112387ef1b7803bedb638f850a844472a4496dcc65f0d5401b8614ff76a60
|
7
|
+
data.tar.gz: 6813ee8c151970d98042038433febb0f646f12f961ec5ae3e61e062471b64da92d15573bedaef7d534af5eb2798dff3f5754b9dd3240c14c9f67848478d83438
|
data/lib/seory.rb
CHANGED
data/lib/seory/dsl.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
|
+
require 'seory'
|
1
2
|
require 'seory/page_contents'
|
2
|
-
require 'seory/
|
3
|
+
require 'seory/repository'
|
3
4
|
|
4
5
|
module Seory
|
5
6
|
module Dsl
|
6
|
-
extend self
|
7
7
|
|
8
8
|
def describe(&block)
|
9
|
-
|
10
|
-
|
11
|
-
end
|
9
|
+
@repository = Repository.new
|
10
|
+
Descriptor.new(@repository).describe(&block)
|
12
11
|
end
|
13
12
|
|
14
13
|
def lookup(controller)
|
15
|
-
|
16
|
-
Seory::Runtime.new(page_contents, controller)
|
14
|
+
@repository.lookup(controller)
|
17
15
|
end
|
18
16
|
|
19
17
|
class PageContentsBuilder
|
@@ -27,7 +25,7 @@ module Seory
|
|
27
25
|
@page_contents
|
28
26
|
end
|
29
27
|
|
30
|
-
Seory::
|
28
|
+
Seory::CONTENTS.each do |name|
|
31
29
|
define_method(name) do |val = nil, &block|
|
32
30
|
@page_contents.define(name, val, &block)
|
33
31
|
end
|
@@ -35,12 +33,18 @@ module Seory
|
|
35
33
|
end
|
36
34
|
|
37
35
|
class Descriptor
|
38
|
-
def initialize(
|
39
|
-
@
|
36
|
+
def initialize(repository)
|
37
|
+
@repository = repository
|
38
|
+
end
|
39
|
+
|
40
|
+
def describe(&block)
|
41
|
+
instance_exec(&block)
|
42
|
+
|
43
|
+
@repository
|
40
44
|
end
|
41
45
|
|
42
46
|
def match(*conditions, &def_builder)
|
43
|
-
@
|
47
|
+
@repository << PageContentsBuilder.new(*conditions).build!(&def_builder)
|
44
48
|
end
|
45
49
|
|
46
50
|
def default(&def_builder)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'seory/runtime'
|
2
|
+
|
3
|
+
module Seory
|
4
|
+
class Repository
|
5
|
+
def initialize
|
6
|
+
@store = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def <<(page_contents)
|
10
|
+
@store << page_contents
|
11
|
+
end
|
12
|
+
|
13
|
+
def lookup(controller)
|
14
|
+
page_contents = @store.detect {|page| page.match?(controller) }
|
15
|
+
Seory::Runtime.new(page_contents, controller)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/seory/runtime.rb
CHANGED
@@ -5,8 +5,6 @@ module Seory
|
|
5
5
|
class Runtime
|
6
6
|
delegate :action_name, to: :controller
|
7
7
|
|
8
|
-
CONTENTS = %w[title h1 h2 meta_description meta_keywords canonical_url image_url].map(&:to_sym)
|
9
|
-
|
10
8
|
attr_reader :controller
|
11
9
|
|
12
10
|
def initialize(page_contents, controller)
|
@@ -14,7 +12,7 @@ module Seory
|
|
14
12
|
@controller = controller
|
15
13
|
end
|
16
14
|
|
17
|
-
CONTENTS.each do |name|
|
15
|
+
Seory::CONTENTS.each do |name|
|
18
16
|
define_method(name) { calculate_content_for(name) }
|
19
17
|
end
|
20
18
|
|
data/lib/seory/version.rb
CHANGED
data/spec/seory/dsl_spec.rb
CHANGED
@@ -2,8 +2,9 @@ require 'spec_helper'
|
|
2
2
|
require 'seory/dsl'
|
3
3
|
|
4
4
|
describe Seory::Dsl do
|
5
|
+
let(:seory_class) { Object.new.extend(Seory::Dsl) }
|
5
6
|
before do
|
6
|
-
|
7
|
+
seory_class.describe do
|
7
8
|
match 'products#index' do
|
8
9
|
title 'My Great Product'
|
9
10
|
h1 'Great Product Name'
|
@@ -16,7 +17,7 @@ describe Seory::Dsl do
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
subject(:seory) {
|
20
|
+
subject(:seory) { seory_class.lookup(controller) }
|
20
21
|
|
21
22
|
context 'at products#index' do
|
22
23
|
let(:controller) { double('controller', controller_name: 'products', action_name: 'index') }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- moro
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/seory.rb
|
70
70
|
- lib/seory/dsl.rb
|
71
71
|
- lib/seory/page_contents.rb
|
72
|
+
- lib/seory/repository.rb
|
72
73
|
- lib/seory/runtime.rb
|
73
74
|
- lib/seory/version.rb
|
74
75
|
- seory.gemspec
|