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 ADDED
@@ -0,0 +1,18 @@
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
+ log/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format d
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :test do
5
+ gem 'rspec'
6
+ gem 'rspec-rails'
7
+ gem 'capybara'
8
+ gem 'coveralls', :require => false
9
+ end
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
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ RSpec::Core::RakeTask.new(:spec)
4
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <title>Snipp</title>
6
+ <%= stylesheet_link_tag :all %>
7
+ <%= javascript_include_tag :defaults %>
8
+ <%= csrf_meta_tag %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1,3 @@
1
+ <h1>Rich Snippets Sample</h1>
2
+ <h2>Breadcumb</h2>
3
+ <%= breadcrumb [:root, :food, :food_fruit, :food_fruit_red, :food_fruit_red_apple], s: "/" %>
@@ -0,0 +1,9 @@
1
+ en:
2
+ views:
3
+ breadcrumb:
4
+ # Sample
5
+ root: "Top"
6
+ food: "Food"
7
+ food_fruit: "Fruit"
8
+ food_fruit_red: "Red"
9
+ food_fruit_red_apple: "Apple"
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
@@ -0,0 +1,4 @@
1
+ module Snipp
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -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 = "&nbsp;#{options.delete(:sepalator)||options.delete(:s)||'&gt;'}&nbsp;"
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
@@ -0,0 +1,9 @@
1
+ module Snipp
2
+ class Hooks
3
+ def self.init
4
+ ActiveSupport.on_load(:action_view) do
5
+ ::ActionView::Base.send :include, Snipp::ActionViewExtension
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Snipp
2
+ class Railtie < ::Rails::Railtie
3
+ initializer :snipp do |app|
4
+ Snipp::Hooks.init
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Snipp
2
+ VERSION = "0.0.1"
3
+ end
data/lib/snipp.rb ADDED
@@ -0,0 +1,10 @@
1
+ module Snipp
2
+ end
3
+
4
+ require 'snipp/helpers/action_view_extension'
5
+ require 'snipp/hooks'
6
+
7
+ if defined? Rails
8
+ require 'snipp/railtie'
9
+ require 'snipp/engine'
10
+ end
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
@@ -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)
@@ -0,0 +1,16 @@
1
+ # coding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe Snipp do
5
+
6
+ before do
7
+ Snipp::Hooks.init
8
+ visit "/"
9
+ puts page.html
10
+ end
11
+
12
+ describe do
13
+ it { expect(true).to be_true }
14
+ end
15
+
16
+ end
@@ -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