metaa 0.0.13 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +34 -23
  3. data/lib/metaa/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWY1YmFjNmQ1N2U0ZjYyNDQ0MjhlMDFjYmQ3MzA5NGY4ZDZmZmU0MQ==
4
+ ZmIzMzFmNWRmNWI2OWIxYWI5OWIwZjc4ZTJlMzUwNWY0ZDRmOTI3Ng==
5
5
  data.tar.gz: !binary |-
6
- MzViZGQ3OGNhZWE4YzE1Njg1MDZjZTA2ZjJmMDc0NzcwZWMyNDYwYg==
6
+ OWVkNTBlNTVkNjRjNTk5MGNmYzZkNGRiYjFhN2ExNjhlOTlmZDI1OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWM3NTFlMmQwNjlkZTFjMTFiYmU4ZThmZTFlNTRhYTM1Njg2NzI4Y2E2NzBh
10
- ZWM3YmM5NGIyZTAwMDUwMDM0YzhkYzA1YjgxZjU3NmU0NTJiOTBhZTEzNjk3
11
- NjAzNzdlZDdiYjBmMGM0OTg2Y2QyODgzZTEzNDE1YjQzYTg1YmM=
9
+ OGRkNGFmZDBjOGU3ZGYwMGNjNmVmMGU2Yjg5NDBhZmM0MTY1OGRkZTFiMTQ2
10
+ ODU1ZmRiYzFhNzU5MjUyZjJkMWI3NmI0MjI1OTcyZDc2ODgwZTNhNThiNDk1
11
+ MGYyZGNjYjFhYmY5YjM3YTg2MTZhM2Y0MWI1NTlhZDY5ZGUzYjQ=
12
12
  data.tar.gz: !binary |-
13
- MzQ1OWFmZWYzMWUyZWZjOTAzNGQxZjA0Zjg3MGFjZmRkOGRhZGQ5YTA4NGRk
14
- N2JkZGUwM2ZmMWYwNjljZTI4MzNmY2IyNzAxMTVjZjg4ZjhhYjliZjZhYTFk
15
- MjAzNTc2NGViYzk0MjU2YTg4ZWU1NTcxMTQ1ZDEyMzM2YjdmOWE=
13
+ ZDk3NTkyY2JjNDAxOWNhZTQ1YzE2Yzk5YTliOTY2ZjllZThlMmFiYWIzN2Rl
14
+ Y2ExNjI5ZTI0NWY1ZGQyY2Q4NTI0ZGMwYTBkM2EwZjE3NWI0NWRmYjBjZjQx
15
+ ZTdmMGZhYWZjYzYxMjA0YmM0N2E2YzlhYmVlZGRhOThhYmZlZmU=
data/README.md CHANGED
@@ -6,6 +6,12 @@ Metaa adds meta tags to your Rails application with ease.
6
6
 
7
7
  With Metaa, you can easily add meta tags to your current model with simple DSL, then render these tags on your views with a single method.
8
8
 
9
+ ## Installation
10
+
11
+ Add Metaa to your Gemfile:
12
+
13
+ gem 'metaa'
14
+
9
15
  ## Generator
10
16
 
11
17
  The command is simple, just add the model you want to create the meta for:
@@ -16,11 +22,7 @@ rails generate meta Product
16
22
 
17
23
  This will generate `ProductMeta` meta class in your app/meta folder.
18
24
 
19
- ## Meta definition
20
-
21
- After generated, the meta class will look like this:
22
-
23
- ```
25
+ ```ruby
24
26
  # app/meta/product_meta.rb
25
27
  class ProductMeta < Metaa::Meta
26
28
  def define_meta
@@ -33,20 +35,38 @@ class ProductMeta < Metaa::Meta
33
35
  end
34
36
  ```
35
37
 
36
- You can define meta tags multiple times and these tags will be displayed in the order you define in meta class.
38
+ ## Meta definition
37
39
 
38
- To access to the rendered html, just use method `meta_tags` on your ActiveRecord instance:
40
+ We can define the meta tags as following:
39
41
 
42
+ ```ruby
43
+ # app/meta/product_meta.rb
44
+ class ProductMeta < Metaa::Meta
45
+ def define_meta
46
+ meta name: "title",
47
+ content: object.title
48
+
49
+ # You can define multiple meta tags in order
50
+ meta name: "description",
51
+ content: object.description
52
+ end
53
+ end
54
+ ...
55
+
56
+ product.title #=> "product title"
57
+ product.description #=> "product description"
58
+
59
+ # access to the rendered html
60
+ product.meta_tags #=> "<meta content=\"product title\" name=\"title\" /><meta content=\"product description\" name=\"description\" />"
40
61
  ```
41
- product.meta_tags
42
- ```
62
+
43
63
  All ActiveRecord instances will have this behavior if appropriate meta class is defined, e.g. `ProductMeta` for model `Product`.
44
64
 
45
65
  ## Non ActiveRecord
46
66
 
47
67
  With non ActiveRecord instances, you can still generate the meta class and define the meta tags normally with any class name. However, you have to handle the meta object manually:
48
68
 
49
- ```
69
+ ```ruby
50
70
  # app/meta/non_active_record_model_meta.rb
51
71
  class NonActiveRecordModelMeta < Metaa::Meta
52
72
  def define_meta
@@ -55,27 +75,18 @@ class NonActiveRecordModelMeta < Metaa::Meta
55
75
 
56
76
  end
57
77
  end
58
-
59
78
  ...
60
79
 
61
- ruby_object.respond_to? :title #=> true
62
-
63
- ...
80
+ ruby_object.title #=> "a title"
64
81
 
65
82
  # create meta object from ruby_object
66
83
  meta_object = NonActiveRecordModelMeta.new(ruby_object)
67
84
 
68
- # access rendered html of the defined meta tags
69
- meta_object.to_html
85
+ # access to the rendered html
86
+ meta_object.to_html #=> "<meta content=\"a title\" name=\"title\" />"
70
87
  ```
71
88
 
72
- ## Installation
73
-
74
- Add Metaa to your Gemfile:
75
-
76
- gem 'metaa'
77
-
78
- And run bundle install within your app's directory.
89
+ Notice that we use `meta_tags` method on ActiveRecord instances instead of `to_html` method on the meta objects in order to avoid method name conflicts on your models.
79
90
 
80
91
 
81
92
  ## Contributing
@@ -1,3 +1,3 @@
1
1
  module Metaa
2
- VERSION = "0.0.13"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - anhkind
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-25 00:00:00.000000000 Z
11
+ date: 2013-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport