metaa 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.iml
19
+ .idea
20
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - jruby-19mode
7
+ - rbx-19mode
8
+
9
+ notifications:
10
+ recipients:
11
+ - anhkind@gmail.com
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in metaa.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 anguyen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ [![Build Status](https://travis-ci.org/anhkind/metaa.png)](https://travis-ci.org/anhkind/metaa)
2
+
3
+ # Metaa
4
+
5
+ Metaa adds meta tags to your Rails application with ease.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'metaa'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install metaa
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
data/lib/metaa.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'action_view'
2
+
3
+ require "metaa/version"
4
+ require 'metaa/tag'
5
+ require 'metaa/tag_collection'
6
+ require 'metaa/view_helper'
7
+
8
+ module Metaa
9
+ end
10
+
11
+ ActionView::Base.send :include, Metaa::ViewHelpers
data/lib/metaa/tag.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Metaa
2
+ class Tag
3
+ include ActionView::Helpers::TagHelper
4
+ attr_reader :attributes
5
+
6
+ def initialize(attributes = {})
7
+ @attributes = attributes
8
+ end
9
+
10
+ def html
11
+ tag(:meta, @attributes)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ module Metaa
2
+ class TagCollection
3
+ def initialize(tags = [])
4
+ add(tags)
5
+ end
6
+
7
+ def add(new_tags)
8
+ new_tags = [new_tags] if !new_tags.is_a? Array
9
+ new_tags.each do |tag|
10
+ tag = Tag.new(tag) if !tag.is_a?(Tag)
11
+ tags << tag
12
+ end
13
+ end
14
+
15
+ def tags
16
+ @tags ||= []
17
+ end
18
+
19
+ def html
20
+ tags.map(&:html).join
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Metaa
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ module Metaa
2
+ module ViewHelpers
3
+ def add_meta_tags(meta = [])
4
+ meta = [meta] if !meta.is_a? Array
5
+ self.meta_tags.concat meta
6
+ end
7
+
8
+ def display_meta_tags
9
+ TagCollection.new(meta_tags).html
10
+ end
11
+
12
+ def meta_tags
13
+ @meta_tags ||= []
14
+ end
15
+ end
16
+ end
data/metaa.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'metaa/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "metaa"
8
+ gem.version = Metaa::VERSION
9
+ gem.authors = ["anhkind"]
10
+ gem.email = ["anhkind@gmail.com"]
11
+ gem.description = "Metaa adds meta tags to your Rails application with ease"
12
+ gem.summary = "Meta tags with ease"
13
+ gem.homepage = "https://github.com/anhkind/metaa"
14
+
15
+ gem.add_dependency 'activesupport', '>= 3.0'
16
+ gem.add_dependency 'actionpack', '>= 3.0'
17
+ gem.add_dependency 'activemodel', '>= 3.0'
18
+
19
+ gem.add_development_dependency 'rake', '>= 0.9.2'
20
+ gem.add_development_dependency 'rspec', '~> 2.12'
21
+ gem.add_development_dependency 'rspec-mocks', '>= 2.12.1'
22
+ gem.add_development_dependency 'rspec-rails', '~> 2.12'
23
+
24
+ gem.files = `git ls-files`.split($/)
25
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
26
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
27
+ gem.require_paths = ["lib"]
28
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metaa::TagCollection do
4
+ describe '#add' do
5
+ it 'add a meta object to internal list' do
6
+ meta_collection = Metaa::TagCollection.new
7
+ meta_collection.add Metaa::Tag.new({name: 'keywords', content: 'abc'})
8
+ expect(meta_collection.tags.first.attributes).to eq({name: 'keywords', content: 'abc'})
9
+ end
10
+
11
+ it 'add a hash as a new meta object to internal list' do
12
+ meta_collection = Metaa::TagCollection.new
13
+ meta_collection.add({name: 'keywords', content: 'abc'})
14
+ expect(meta_collection.tags.first.attributes).to eq({name: 'keywords', content: 'abc'})
15
+ end
16
+ end
17
+
18
+ describe '#html' do
19
+ it 'converts list of meta objects to html' do
20
+ meta_list = [
21
+ Metaa::Tag.new({name: 'keywords', content: 'abc'}),
22
+ Metaa::Tag.new({name: 'keywords', content: '123, 456'})
23
+ ]
24
+ meta_collection = Metaa::TagCollection.new(meta_list)
25
+ expect(meta_collection.html).to eq "<meta content=\"abc\" name=\"keywords\" /><meta content=\"123, 456\" name=\"keywords\" />"
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metaa::Tag do
4
+ it 'converts a meta tag to html' do
5
+ tag = Metaa::Tag.new({name: 'keywords', content: 'abc'})
6
+ expect(tag.html).to eq "<meta content=\"abc\" name=\"keywords\" />"
7
+ end
8
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ module Metaa
4
+ describe ViewHelpers do
5
+ let(:subject) { Class.new{include ViewHelpers}.new }
6
+
7
+ describe "#add_meta_tags" do
8
+ it "adds the meta tags from an input array" do
9
+ meta = [
10
+ { name: 'keywords', content: 'abc'}
11
+ ]
12
+
13
+ subject.add_meta_tags meta
14
+ expect(subject.send :meta_tags).to eq([
15
+ { name: 'keywords', content: 'abc'}
16
+ ])
17
+ end
18
+
19
+ it "adds the meta tags from an input hash" do
20
+ meta = { name: 'keywords', content: 'abc'}
21
+
22
+ subject.add_meta_tags meta
23
+ expect(subject.send :meta_tags).to eq([
24
+ { name: 'keywords', content: 'abc'}
25
+ ])
26
+ end
27
+ end
28
+
29
+ describe "#display_meta_tags" do
30
+ it "displays the added meta tags" do
31
+ subject.stub meta_tags: [
32
+ { name: 'keywords', content: 'abc'}
33
+ ]
34
+
35
+ expect(subject.display_meta_tags).to eq "<meta content=\"abc\" name=\"keywords\" />"
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,2 @@
1
+ require 'bundler/setup'
2
+ require 'metaa'
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metaa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - anhkind
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: actionpack
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: activemodel
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.9.2
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.9.2
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '2.12'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.12'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec-mocks
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 2.12.1
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 2.12.1
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec-rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.12'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.12'
126
+ description: Metaa adds meta tags to your Rails application with ease
127
+ email:
128
+ - anhkind@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .travis.yml
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - lib/metaa.rb
140
+ - lib/metaa/tag.rb
141
+ - lib/metaa/tag_collection.rb
142
+ - lib/metaa/version.rb
143
+ - lib/metaa/view_helper.rb
144
+ - metaa.gemspec
145
+ - spec/metaa/tag_collection_spec.rb
146
+ - spec/metaa/tag_spec.rb
147
+ - spec/metaa/view_helper_spec.rb
148
+ - spec/spec_helper.rb
149
+ homepage: https://github.com/anhkind/metaa
150
+ licenses: []
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 1.8.24
170
+ signing_key:
171
+ specification_version: 3
172
+ summary: Meta tags with ease
173
+ test_files:
174
+ - spec/metaa/tag_collection_spec.rb
175
+ - spec/metaa/tag_spec.rb
176
+ - spec/metaa/view_helper_spec.rb
177
+ - spec/spec_helper.rb