snipp 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.
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +4 -0
- data/app/views/layouts/application.html.erb +15 -0
- data/app/views/snipp/index.html.erb +3 -0
- data/config/locales/snipp.yml +9 -0
- data/deploy_gem.sh +34 -0
- data/lib/snipp/engine.rb +4 -0
- data/lib/snipp/helpers/action_view_extension.rb +30 -0
- data/lib/snipp/hooks.rb +9 -0
- data/lib/snipp/railtie.rb +7 -0
- data/lib/snipp/version.rb +3 -0
- data/lib/snipp.rb +10 -0
- data/snipp.gemspec +21 -0
- data/spec/fake_rails.rb +40 -0
- data/spec/snipp_spec.rb +16 -0
- data/spec/spec_helper.rb +20 -0
- metadata +84 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 yulii
|
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,52 @@
|
|
1
|
+
# Snipp
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'snipp'
|
11
|
+
```
|
12
|
+
And then execute:
|
13
|
+
```sh
|
14
|
+
$ bundle
|
15
|
+
```
|
16
|
+
Or install it yourself as:
|
17
|
+
```sh
|
18
|
+
$ gem install snipp
|
19
|
+
```
|
20
|
+
## Usage
|
21
|
+
### Breadcrumbs
|
22
|
+
```html+ruby
|
23
|
+
<%= breadcrumb [:root, :food, :food_fruit, :food_fruit_red, :food_fruit_red_apple], s: "/" %>
|
24
|
+
```
|
25
|
+
|
26
|
+
link to `root_path`, `food_path`, `food_fruit_path`, `food_fruit_red`, `food_fruit_red_apple`
|
27
|
+
|
28
|
+
Link text
|
29
|
+
```yaml
|
30
|
+
en:
|
31
|
+
views:
|
32
|
+
breadcrumb:
|
33
|
+
# Sample
|
34
|
+
root: "Top"
|
35
|
+
food: "Food"
|
36
|
+
food_fruit: "Fruit"
|
37
|
+
food_fruit_red: "Red"
|
38
|
+
food_fruit_red_apple: "Apple"
|
39
|
+
```
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
48
|
+
|
49
|
+
## LICENSE
|
50
|
+
(The MIT License)
|
51
|
+
|
52
|
+
Copyright © 2013 yulii. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
data/deploy_gem.sh
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
LIB_NAME="snipp"
|
3
|
+
if [ $# -ne 1 ]
|
4
|
+
then
|
5
|
+
echo "invalid VERSION"
|
6
|
+
exit 1
|
7
|
+
fi
|
8
|
+
GEMSPEC="${LIB_NAME}.gemspec"
|
9
|
+
PKG_FILE="${LIB_NAME}-$1.gem"
|
10
|
+
|
11
|
+
echo "[RUN] gem install"
|
12
|
+
bundle install
|
13
|
+
echo "[RUN] rake"
|
14
|
+
bundle exec rake
|
15
|
+
|
16
|
+
if [ $? -eq 1 ]
|
17
|
+
then
|
18
|
+
exit 1
|
19
|
+
fi
|
20
|
+
echo "[RUN] gem build ${GEMSPEC}"
|
21
|
+
gem build ${GEMSPEC}
|
22
|
+
if [ $? -eq 1 ]
|
23
|
+
then
|
24
|
+
exit 1
|
25
|
+
fi
|
26
|
+
|
27
|
+
echo "[RUN] mv ${PKG_FILE} pkg/"
|
28
|
+
mv ${PKG_FILE} ./pkg
|
29
|
+
echo "[RUN] gem push pkg/${PKG_FILE}"
|
30
|
+
gem push pkg/${PKG_FILE}
|
31
|
+
|
32
|
+
echo "[RUN] git tag -a version-$1"
|
33
|
+
git tag -a version-$1 -m ""
|
34
|
+
git push --tags
|
data/lib/snipp/engine.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Snipp
|
2
|
+
module ActionViewExtension
|
3
|
+
|
4
|
+
# = breadcrumb [ :root, :seach, :item } ], s: "/"
|
5
|
+
# @params paths
|
6
|
+
# @params options
|
7
|
+
def breadcrumb paths, options = {}
|
8
|
+
sepalator = " #{options.delete(:sepalator)||options.delete(:s)||'>'} "
|
9
|
+
sepalator << '<div itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">'
|
10
|
+
|
11
|
+
i18n_options = options.merge({ scope: [:views, :breadcrumb] })
|
12
|
+
|
13
|
+
bc = []
|
14
|
+
paths.each do |e|
|
15
|
+
body = content_tag :span, I18n.t(e, i18n_options), itemprop: :title
|
16
|
+
bc.push link_to body, send("#{e}_path", options), itemprop: :url
|
17
|
+
end
|
18
|
+
code = '<nav class="breadcrumb" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">'
|
19
|
+
code << bc.join(sepalator)
|
20
|
+
|
21
|
+
(paths.size - 1).times do
|
22
|
+
code << '</div>'
|
23
|
+
end
|
24
|
+
code << '</nav>'
|
25
|
+
|
26
|
+
return code.html_safe
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/snipp/hooks.rb
ADDED
data/lib/snipp.rb
ADDED
data/snipp.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'snipp/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "snipp"
|
8
|
+
gem.version = Snipp::VERSION
|
9
|
+
gem.authors = ["yulii"]
|
10
|
+
gem.email = ["yuliinfo@gmail.com"]
|
11
|
+
gem.description = %q{Structured Data Snippets}
|
12
|
+
gem.summary = %q{Let search engines understand the content on your website}
|
13
|
+
gem.homepage = "https://github.com/yulii/snipp"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "rails", "~>3.2.11"
|
21
|
+
end
|
data/spec/fake_rails.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'action_controller/railtie'
|
2
|
+
require 'action_view/railtie'
|
3
|
+
|
4
|
+
# config
|
5
|
+
app = Class.new Rails::Application
|
6
|
+
app.config.active_support.deprecation = :log
|
7
|
+
app.config.secret_token = "e65e0140352e39703c113b0ce30335e8"
|
8
|
+
app.config.generators do |g|
|
9
|
+
# g.template_engine :haml
|
10
|
+
end
|
11
|
+
app.initialize!
|
12
|
+
|
13
|
+
# routing
|
14
|
+
SNIPP_TYPES = [:breadcumb]
|
15
|
+
app.routes.draw do
|
16
|
+
get "/" =>"snipp#index" ,as: :root
|
17
|
+
|
18
|
+
SNIPP_TYPES.each do |e|
|
19
|
+
get "/e" => "index##{e}" ,as: e
|
20
|
+
end
|
21
|
+
|
22
|
+
# for Breadcumb
|
23
|
+
get "/food" => "snipp#index", as: :food
|
24
|
+
get "/food/fruit" => "snipp#index", as: :food_fruit
|
25
|
+
get "/food/fruit/red" => "snipp#index", as: :food_fruit_red
|
26
|
+
get "/food/fruit/red/apple" => "snipp#index", as: :food_fruit_red_apple
|
27
|
+
end
|
28
|
+
|
29
|
+
# controllers
|
30
|
+
class ApplicationController < ActionController::Base ; end
|
31
|
+
|
32
|
+
class SnippController < ApplicationController
|
33
|
+
|
34
|
+
def index ; end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# helpers
|
40
|
+
Object.const_set(:ApplicationHelper, Module.new)
|
data/spec/snipp_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'snipp'
|
4
|
+
|
5
|
+
require 'fake_rails'
|
6
|
+
require 'capybara/rails'
|
7
|
+
require 'coveralls'
|
8
|
+
|
9
|
+
Coveralls.wear!('rails')
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.mock_with :rspec
|
12
|
+
config.expect_with :rspec do |c|
|
13
|
+
c.syntax = :expect # disables `should`
|
14
|
+
end
|
15
|
+
config.include Capybara::DSL
|
16
|
+
end
|
17
|
+
Capybara.configure do |config|
|
18
|
+
config.match = :prefer_exact
|
19
|
+
config.ignore_hidden_elements = false
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: snipp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- yulii
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.11
|
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.2.11
|
30
|
+
description: Structured Data Snippets
|
31
|
+
email:
|
32
|
+
- yuliinfo@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- .rspec
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- app/views/layouts/application.html.erb
|
44
|
+
- app/views/snipp/index.html.erb
|
45
|
+
- config/locales/snipp.yml
|
46
|
+
- deploy_gem.sh
|
47
|
+
- lib/snipp.rb
|
48
|
+
- lib/snipp/engine.rb
|
49
|
+
- lib/snipp/helpers/action_view_extension.rb
|
50
|
+
- lib/snipp/hooks.rb
|
51
|
+
- lib/snipp/railtie.rb
|
52
|
+
- lib/snipp/version.rb
|
53
|
+
- snipp.gemspec
|
54
|
+
- spec/fake_rails.rb
|
55
|
+
- spec/snipp_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
homepage: https://github.com/yulii/snipp
|
58
|
+
licenses: []
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.8.24
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Let search engines understand the content on your website
|
81
|
+
test_files:
|
82
|
+
- spec/fake_rails.rb
|
83
|
+
- spec/snipp_spec.rb
|
84
|
+
- spec/spec_helper.rb
|