seory 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 255ce5bf7ad7b79b1c1ba7b647c83bae44377685
4
- data.tar.gz: 93d4ddd0a609d7403cb616da854ad06ce95ed540
3
+ metadata.gz: 31a71be5bea7d32b2895e6b280c50db69074f284
4
+ data.tar.gz: e313695b9b65b658367267bcc5c9a89d82b151d9
5
5
  SHA512:
6
- metadata.gz: 593351c2bba8912fd3aa0b1500ba53ee22c88b39c6475936b0ad362ab482cce9004112387ef1b7803bedb638f850a844472a4496dcc65f0d5401b8614ff76a60
7
- data.tar.gz: 6813ee8c151970d98042038433febb0f646f12f961ec5ae3e61e062471b64da92d15573bedaef7d534af5eb2798dff3f5754b9dd3240c14c9f67848478d83438
6
+ metadata.gz: 92c72d830486a8487178f108e7d9459c7aad9ebab926668263f1f9460f0846212f17fe2115b88fbeca780fb89a989d3307ce7c93edf97598994381148f701e5c
7
+ data.tar.gz: efd6daee3a8d918db5c596adf39f9da80fb4e6ad75825b195e99ca4069e04055bbbec103e20728030ecba3bb7d0cb32e0b5969e62f1f2289f8630ab7b6c78533
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in seory.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rspec'
6
+ gem 'rspec', '>= 3.0.0'
data/README.md CHANGED
@@ -33,14 +33,15 @@ match %w[products#popular products#new_release], {
33
33
 
34
34
  # Can contain dynamic content based on controller using assigned ivar
35
35
  match 'brands#show' {
36
- title: -> { assign(:brand).name }
36
+ title { assign(:brand).name }
37
37
  }
38
38
 
39
39
  # Custom lookup rule with controller
40
40
  match ->(controller) { controller.params[:page].to_i == 1 }, {
41
- keywords: -> do
41
+ keywords do
42
42
  search = assign(:search_object)
43
43
 
44
+ # do something
44
45
  end
45
46
  }
46
47
 
@@ -60,7 +61,7 @@ default do
60
61
  end
61
62
  ```
62
63
 
63
- Then we can use seory in your application.
64
+ Then we can use seory in your application.[TODO]
64
65
  ```ruby
65
66
  module ApplicationHelper
66
67
 
@@ -85,3 +86,9 @@ end
85
86
  3. Commit your changes (`git commit -am 'Add some feature'`)
86
87
  4. Push to the branch (`git push origin my-new-feature`)
87
88
  5. Create a new Pull Request
89
+
90
+ ## Thanks
91
+
92
+ - @libkazz: Specification adviser
93
+ - @darashi: God father
94
+
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.pattern = "spec/**/*_spec.rb"
6
+ end
7
+
8
+ task :default => [:spec]
2
9
 
data/lib/seory/dsl.rb CHANGED
@@ -25,10 +25,12 @@ module Seory
25
25
  @page_contents
26
26
  end
27
27
 
28
+ def misc(name, val = nil, &block)
29
+ @page_contents.define(name, val, &block)
30
+ end
31
+
28
32
  Seory::CONTENTS.each do |name|
29
- define_method(name) do |val = nil, &block|
30
- @page_contents.define(name, val, &block)
31
- end
33
+ define_method(name) {|val = nil, &block| misc(name, val, &block) }
32
34
  end
33
35
  end
34
36
 
data/lib/seory/runtime.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # TODO move somewhere
2
2
  require 'active_support/all'
3
+ require 'seory'
3
4
 
4
5
  module Seory
5
6
  class Runtime
@@ -12,8 +13,16 @@ module Seory
12
13
  @controller = controller
13
14
  end
14
15
 
16
+ def assigns(name)
17
+ @controller.view_assigns[name.to_s]
18
+ end
19
+
20
+ def misc(name)
21
+ calculate_content_for(name)
22
+ end
23
+
15
24
  Seory::CONTENTS.each do |name|
16
- define_method(name) { calculate_content_for(name) }
25
+ define_method(name) { misc(name) }
17
26
  end
18
27
 
19
28
  private
data/lib/seory/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Seory
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/seory.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "seory/version"
2
2
 
3
3
  module Seory
4
- CONTENTS = %w[title h1 h2 meta_description meta_keywords canonical_url image_url].map(&:to_sym)
4
+ CONTENTS = %w[title h1 h2 meta_description meta_keywords canonical_url og_image_url].map(&:to_sym)
5
5
 
6
6
  class Error < RuntimeError
7
7
  end
data/seory.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["moronatural@gmail.com"]
11
11
  spec.summary = %q{SEO contents manager for Rails.}
12
12
  spec.description = %q{Manage SEO contets in Rails app. based on controller, action and more complex context.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/esminc/seory"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -8,11 +8,15 @@ describe Seory::Dsl do
8
8
  match 'products#index' do
9
9
  title 'My Great Product'
10
10
  h1 'Great Product Name'
11
+
12
+ misc :option, 'static optional val'
11
13
  end
12
14
 
13
15
  default do
14
16
  title 'Misc site'
15
17
  h1 { controller.controller_name.upcase }
18
+
19
+ misc(:option) { "dynamic option name at #{controller.controller_name}" }
16
20
  end
17
21
  end
18
22
  end
@@ -24,11 +28,13 @@ describe Seory::Dsl do
24
28
 
25
29
  specify { expect(seory.title).to eq 'My Great Product' }
26
30
  specify { expect(seory.h1).to eq 'Great Product Name' }
31
+ specify { expect(seory.misc(:option)).to eq 'static optional val' }
27
32
  end
28
33
 
29
34
  context 'at misc#show' do
30
35
  let(:controller) { double('controller', controller_name: 'misc', action_name: 'show') }
31
36
 
32
37
  specify { expect(seory.h1).to eq 'MISC' }
38
+ specify { expect(seory.misc(:option)).to eq 'dynamic option name at misc' }
33
39
  end
34
40
  end
@@ -36,4 +36,14 @@ describe Seory::Runtime do
36
36
  specify { expect(seory.title).to eq 'EDIT | My Site' }
37
37
  end
38
38
  end
39
+
40
+ context 'Access controller assigns(instance variables)' do
41
+ before do
42
+ allow(controller).to receive(:view_assigns).and_return('products' => [:products] * 42)
43
+
44
+ page_contents.define(:title) { "Good Shop with #{assigns(:products).size} products!" }
45
+ end
46
+
47
+ specify { expect(seory.title).to eq 'Good Shop with 42 products!' }
48
+ end
39
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - moro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-04 00:00:00.000000000 Z
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -77,7 +77,7 @@ files:
77
77
  - spec/seory/page_contents_spec.rb
78
78
  - spec/seory/runtime_spec.rb
79
79
  - spec/spec_helper.rb
80
- homepage: ''
80
+ homepage: https://github.com/esminc/seory
81
81
  licenses:
82
82
  - MIT
83
83
  metadata: {}