acts_as_seo_friendly 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af4a6e1f97297bd3f47d528d74f04460e534a2d7
4
+ data.tar.gz: af53d91adce2fa9f0e0cee011ddfbb7119040cac
5
+ SHA512:
6
+ metadata.gz: 0f9687c9f8ee7cebdf683bfccde4d935e15365b39c6a1ba94c7ffdbad104846504fb1ff9f0ab39394157322ee20e85b9d5fe721c43da045b5f5e2d28ff751ded
7
+ data.tar.gz: 17cb35787428a12da77259e3053fb13f8d5dc288d76a27ec77f1b941dffd4d5d2d89a8719d9b8e6fd0b8cdfb1d7bb678c99290dbaf7a325dbd4161e7c22bc38d
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Timur Khafizov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ [![Code Climate](https://codeclimate.com/github/fishtag/acts_as_seo_friendly/badges/gpa.svg)](https://codeclimate.com/github/fishtag/acts_as_seo_friendly)
2
+ [![Test Coverage](https://codeclimate.com/github/fishtag/acts_as_seo_friendly/badges/coverage.svg)](https://codeclimate.com/github/fishtag/acts_as_seo_friendly)
3
+
4
+ ActsAsSeoFriendly
5
+
6
+ README pending
7
+
8
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,12 @@
1
+ class CreateSeoData < ActiveRecord::Migration
2
+ def change
3
+ create_table :seo_data do |t|
4
+ t.references :datable, polymorphic: true, index: true
5
+ t.string :meta_keywords
6
+ t.string :meta_title
7
+ t.text :meta_description
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ require 'acts_as_seo_friendly/engine'
2
+
3
+ module ActsAsSeoFriendly
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :Datable
7
+ autoload_under 'datable' do
8
+ autoload :Core
9
+ autoload :Getters
10
+ end
11
+ end
12
+
13
+ ActiveSupport.on_load(:active_record) do
14
+ extend ActsAsSeoFriendly::Datable
15
+ end
@@ -0,0 +1,27 @@
1
+ module ActsAsSeoFriendly
2
+ module Datable
3
+ def seo_friendly?
4
+ false
5
+ end
6
+
7
+ def acts_as_seo_friendly(format_attribute: :title)
8
+ class_eval do
9
+ # Define association
10
+ has_one :seo_datum, dependent: :destroy, class_name: 'ActsAsSeoFriendly::SeoDatum', as: :datable
11
+
12
+ # Allow to create or update seo_datum as nested form
13
+ accepts_nested_attributes_for :seo_datum, update_only: true, allow_destroy: true
14
+
15
+ def self.seo_friendly?
16
+ true
17
+ end
18
+ end
19
+
20
+ # Include core methods for generating basic data, etc
21
+ include Core
22
+ include Getters
23
+
24
+ self.seo_datable_with(format_attribute)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,46 @@
1
+ module ActsAsSeoFriendly
2
+ module Datable
3
+ module Core
4
+ extend ActiveSupport::Concern
5
+
6
+ SEO_ATTRIBUTES = %i(meta_title meta_keywords meta_description)
7
+
8
+ included do
9
+ class_attribute :meta_keywords_format
10
+ class_attribute :meta_description_format
11
+ class_attribute :meta_title_format
12
+ class_attribute :format_attribute
13
+
14
+ # Set default interpolation strings
15
+ format_meta_description_as '%s'
16
+ format_meta_keywords_as '%s'
17
+ format_meta_title_as '%s'
18
+ end
19
+
20
+ module ClassMethods
21
+ # Define class-level methods for setting seo attributes
22
+ SEO_ATTRIBUTES.each do |seo_attr|
23
+ define_method(%[format_#{seo_attr}_as]) do |seo_attribute_format = nil, &block|
24
+ seo_attribute_format = block.call if block
25
+
26
+ seo_attribute_format.squish! if seo_attribute_format.is_a?(String)
27
+
28
+ send(%[#{seo_attr}_format=], seo_attribute_format)
29
+ end
30
+ end
31
+
32
+ # Define method for setting default format argument
33
+ def seo_datable_with(format_attribute)
34
+ self.format_attribute = format_attribute.to_sym
35
+ end
36
+ end
37
+
38
+ # Defines instance methods for setting basic seo datum attributes
39
+ ActsAsSeoFriendly::Datable::Core::SEO_ATTRIBUTES.each do |seo_attr|
40
+ define_method(%[dynamic_#{seo_attr}]) do
41
+ self.class.send(%[#{seo_attr}_format]) % send(self.class.format_attribute)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,15 @@
1
+ module ActsAsSeoFriendly
2
+ module Datable
3
+ module Getters
4
+ ActsAsSeoFriendly::Datable::Core::SEO_ATTRIBUTES.each do |seo_attr|
5
+ define_method(seo_attr) do
6
+ if seo_datum
7
+ seo_datum.public_send(seo_attr)
8
+ else
9
+ public_send("dynamic_#{seo_attr}")
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ module ActsAsSeoFriendly
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module ActsAsSeoFriendly
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts_as_seo_friendly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Timur Khafizov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-12 00:00:00.000000000 Z
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.2.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.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pg
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Description of ActsAsSeoFriendly.
42
+ email:
43
+ - timur.khafizov@fishtag.ru
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - db/migrate/1_create_seo_data.rb
52
+ - lib/acts_as_seo_friendly.rb
53
+ - lib/acts_as_seo_friendly/datable.rb
54
+ - lib/acts_as_seo_friendly/datable/core.rb
55
+ - lib/acts_as_seo_friendly/datable/getters.rb
56
+ - lib/acts_as_seo_friendly/engine.rb
57
+ - lib/acts_as_seo_friendly/version.rb
58
+ homepage: https://github.com/fishtag/acts_as_seo_friendly
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Summary of ActsAsSeoFriendly.
82
+ test_files: []