sape 0.0.5

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.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +61 -0
  7. data/Rakefile +27 -0
  8. data/lib/app/assets/stylesheets/sape.css +1 -0
  9. data/lib/app/helpers/sape_helper.rb +36 -0
  10. data/lib/app/models/sape_config.rb +15 -0
  11. data/lib/app/models/sape_link.rb +3 -0
  12. data/lib/app/views/sape/_link.html.erb +8 -0
  13. data/lib/app/views/sape/links.html.erb +6 -0
  14. data/lib/generators/sape/migration_generator.rb +19 -0
  15. data/lib/generators/sape/templates/migration.rb +18 -0
  16. data/lib/generators/sape/views_generator.rb +10 -0
  17. data/lib/sape/fetcher.rb +62 -0
  18. data/lib/sape/railtie.rb +5 -0
  19. data/lib/sape/version.rb +3 -0
  20. data/lib/sape.rb +16 -0
  21. data/lib/tasks/sape.rake +28 -0
  22. data/sape.gemspec +35 -0
  23. data/spec/.rspec +2 -0
  24. data/spec/dummy/.gitignore +16 -0
  25. data/spec/dummy/Gemfile +41 -0
  26. data/spec/dummy/Guardfile +24 -0
  27. data/spec/dummy/README.rdoc +28 -0
  28. data/spec/dummy/Rakefile +6 -0
  29. data/spec/dummy/app/assets/images/.keep +0 -0
  30. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  31. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  32. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  33. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  34. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  35. data/spec/dummy/app/mailers/.keep +0 -0
  36. data/spec/dummy/app/models/.keep +0 -0
  37. data/spec/dummy/app/models/concerns/.keep +0 -0
  38. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  39. data/spec/dummy/bin/bundle +3 -0
  40. data/spec/dummy/bin/rails +8 -0
  41. data/spec/dummy/bin/rake +8 -0
  42. data/spec/dummy/bin/spring +18 -0
  43. data/spec/dummy/config/application.rb +23 -0
  44. data/spec/dummy/config/boot.rb +4 -0
  45. data/spec/dummy/config/database.yml +25 -0
  46. data/spec/dummy/config/environment.rb +5 -0
  47. data/spec/dummy/config/environments/development.rb +37 -0
  48. data/spec/dummy/config/environments/production.rb +83 -0
  49. data/spec/dummy/config/environments/test.rb +39 -0
  50. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  51. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  52. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  53. data/spec/dummy/config/initializers/inflections.rb +16 -0
  54. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  55. data/spec/dummy/config/initializers/session_store.rb +3 -0
  56. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  57. data/spec/dummy/config/locales/en.yml +23 -0
  58. data/spec/dummy/config/routes.rb +56 -0
  59. data/spec/dummy/config/secrets.yml +22 -0
  60. data/spec/dummy/config.ru +4 -0
  61. data/spec/dummy/db/migrate/20140715193855_create_sape_storage.rb +18 -0
  62. data/spec/dummy/db/schema.rb +32 -0
  63. data/spec/dummy/db/seeds.rb +7 -0
  64. data/spec/dummy/lib/assets/.keep +0 -0
  65. data/spec/dummy/lib/tasks/.keep +0 -0
  66. data/spec/dummy/log/.keep +0 -0
  67. data/spec/dummy/public/404.html +67 -0
  68. data/spec/dummy/public/422.html +67 -0
  69. data/spec/dummy/public/500.html +66 -0
  70. data/spec/dummy/public/favicon.ico +0 -0
  71. data/spec/dummy/public/robots.txt +5 -0
  72. data/spec/dummy/test/controllers/.keep +0 -0
  73. data/spec/dummy/test/fixtures/.keep +0 -0
  74. data/spec/dummy/test/helpers/.keep +0 -0
  75. data/spec/dummy/test/integration/.keep +0 -0
  76. data/spec/dummy/test/mailers/.keep +0 -0
  77. data/spec/dummy/test/models/.keep +0 -0
  78. data/spec/dummy/test/test_helper.rb +13 -0
  79. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  80. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  81. data/spec/fixtures/response.json +0 -0
  82. data/spec/fixtures/sape.yml +3 -0
  83. data/spec/helpers/sape_helper_spec.rb +39 -0
  84. data/spec/lib/tasks/sape_rake_spec.rb +49 -0
  85. data/spec/models/sape_config_spec.rb +28 -0
  86. data/spec/models/sape_link_spec.rb +21 -0
  87. data/spec/spec_helper.rb +20 -0
  88. data/spec/support/shared_contexts/rake.rb +22 -0
  89. metadata +379 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5cfdd5187a84c1ef29fb0f5224a225092e9816b2
4
+ data.tar.gz: b9bb5c6aa3875b697b78f2b87df1421bea2d3a7e
5
+ SHA512:
6
+ metadata.gz: e5defda0b4dbe9a084c4a214e8b8937967a6225e31417e048d65a1bd7e87f3f13cd89c865ab0e681ebd941880dc8a293ce4d0cabbd39ab04964ebfa2e0c48781
7
+ data.tar.gz: c90da6f6b3bec731e6df5b44b100173cfe01d91fbf98149b873fc10cb2e3215dc00da2d60f896cd50c0479f886a8ff92ab9d81b38e477c58b008069a75900cc7
data/.gitignore ADDED
@@ -0,0 +1,22 @@
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
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ env:
5
+ - DB=sqlite
6
+ script:
7
+ - cd spec/dummy
8
+ - RAILS_ENV=test bundle exec rake db:create --trace
9
+ - RAILS_ENV=test bundle exec rake db:migrate --trace
10
+ - bundle exec rake db:test:prepare
11
+ - bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sape.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Pavel Rodionov
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,61 @@
1
+ ##Sape gem for Ruby On Rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/sape.png)](http://badge.fury.io/rb/sape)
4
+ [![Build Status](https://travis-ci.org/iRet/sape.png?branch=master)](https://travis-ci.org/iRet/sape)
5
+
6
+ ###Rewritten from scratch
7
+
8
+ ### Changes
9
+ * parsing xml file instead of php serialized string
10
+ * storing in database instead of text file
11
+ * requesting by rake task instead of checking on every page load
12
+ * customizable rails friendly erb templates
13
+
14
+ ### Installation
15
+ Include the gem in your Gemfile:
16
+ ```ruby
17
+ gem 'sape'
18
+ ```
19
+
20
+ #### Preparing db
21
+ * `rails g sape:migration`
22
+ * `rake db:migrate`
23
+
24
+ #### Generating config
25
+ * create config/sape.yml
26
+ ```yml
27
+ sape_user: _YOUR_SAPE_HASH_
28
+ host: example.com
29
+ charset: UTF-8
30
+ ```
31
+
32
+ #### Inserting links
33
+ Simply put helper call in desired place. Like this:
34
+ ```ruby
35
+ <% # SIMPLE LINKS %>
36
+ <%= sape_links -%>
37
+
38
+ <% # BLOCK LINKS %>
39
+ <%= sape_links_block -%>
40
+ ```
41
+
42
+ #### Fetching links
43
+ * `rake sape:fetch`
44
+
45
+ Run it by cron or use whenever gem or something other way you like.
46
+
47
+ #### Customizing templates (optional)
48
+ * `rails g sape:views`
49
+ * add `*= require sape` to application.css for block links
50
+
51
+ Templates will be copied to views/sape folder.
52
+
53
+ ### Notes
54
+ * In _link.html.erb first and last string inserting sape code recognized by sape bots. It should not be removed. Also important to levae url untouched.
55
+
56
+ For more information please follow http://www.sape.ru/
57
+
58
+ License
59
+ -------
60
+ This project rocks and uses MIT-LICENSE.
61
+ Copyright © 2014 Pavel Rodionov
data/Rakefile ADDED
@@ -0,0 +1,27 @@
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
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Sape'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rspec/core/rake_task'
23
+
24
+ RSpec::Core::RakeTask.new('spec')
25
+
26
+ # If you want to make this the default task
27
+ task default: :spec
@@ -0,0 +1 @@
1
+ .block_links * { background:transparent none repeat scroll 0 0 !important; border:medium none !important; clear:none !important; clip:rect(auto, auto, auto, auto) !important; font-size:100% !important; font-style:normal !important; font-variant:normal !important; font-weight:normal !important; height:auto !important; letter-spacing:normal !important; line-height:normal !important; margin:0 !important; overflow:visible !important; padding:0 !important; position:static !important; text-align:left !important; text-decoration:none !important; text-indent:0 !important; text-transform:none !important; vertical-align:baseline !important; visibility:visible !important; white-space:normal !important; width:auto; word-spacing:normal !important; z-index:auto !important; cursor: pointer!important; word-wrap: break-word!important; } .block_links li { display:list-item !important; list-style-image:none !important; list-style-position:outside !important; list-style-type:none !important; display: inline; } .block_links li DIV { padding:0.5em !important; } .block_links DIV, .block_links TABLE { padding: 5px !important; } .block_links { width: 185px!important; font-family: Verdana!important; font-size: 10px!important; border: 0px solid #FFFFFF!important; background-color: #FFFFFF!important; padding:5px!important; position: relative!important; display:block!important; } .block_links_icnt, .block_links_icnt * { text-align: left!important; } .block_links_text, .block_links_text A, .block_links_text A:hover { color: #000000!important; font-size: 10px!important; text-decoration: none!important; } .block_links_url { color: #000333!important; font-size: 10px!important; text-decoration: none!important; } .block_links_header, .block_links_header A { color: #464646!important; font-size: 11px!important; font-weight: bold!important; text-decoration: underline!important; } .block_links_sign { color: #999999!important; font-size: 10px!important; text-align: left!important; text-decoration: none!important; } .block_links_clear { clear:both!important; } .block_links TABLE { width: 100%!important; border: 0px!important; }
@@ -0,0 +1,36 @@
1
+ module SapeHelper
2
+ def sape_links_block
3
+ options = { links: SapeLink.where(page: request.original_fullpath, link_type: "simple") }
4
+ if SapeConfig.bot_ips.include?(request.remote_addr)
5
+ options.merge!(check_code: SapeConfig.check_code)
6
+ end
7
+
8
+ render template: 'sape/links', locals: options
9
+ rescue Exception => e
10
+ "<!-- ERROR: #{e.message} -->".html_safe
11
+ end
12
+
13
+ def sape_links
14
+ links = SapeLink.where(page: request.original_fullpath, link_type: "simple").
15
+ pluck(:raw_link).
16
+ join(SapeConfig.delimiter)
17
+
18
+ SapeConfig.bot_ips.include?(request.remote_addr) ? (links + SapeConfig.check_code) : links
19
+ rescue Exception => e
20
+ "<!-- ERROR: #{e.message} -->".html_safe
21
+ end
22
+
23
+ def sape_context_links(text)
24
+ SapeLink.where(page: request.original_fullpath, link_type: "context").each do |link|
25
+ text.gsub!(link.anchor, link.raw_link)
26
+ end
27
+
28
+ if SapeConfig.bot_ips.include?(request.remote_addr)
29
+ "<sape_index>" + text + "</sape_index>" + SapeConfig.check_code
30
+ else
31
+ text
32
+ end
33
+ rescue Exception => e
34
+ "<!-- ERROR: #{e.message} -->".html_safe
35
+ end
36
+ end
@@ -0,0 +1,15 @@
1
+ class SapeConfig < ActiveRecord::Base
2
+ class << self
3
+ def bot_ips
4
+ where(name: 'ip').pluck(:value)
5
+ end
6
+
7
+ def check_code
8
+ where(name: 'sape_new_url').first.try(:value) || " "
9
+ end
10
+
11
+ def delimiter
12
+ where(name: 'sape_delimiter').first.try(:value) || " "
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ class SapeLink < ActiveRecord::Base
2
+
3
+ end
@@ -0,0 +1,8 @@
1
+ <li class="block_links_icnt">
2
+ <div>
3
+ <span onclick="window.open('http://<%= link.host %>}/', '_blank'); return false;">
4
+ <p class="block_links_header"><%= link.anchor%></p>
5
+ <p class="block_links_text"><%= link.raw_link %></p>
6
+ <p class="block_links_url"><%= link.host %></p>
7
+ </div>
8
+ </li>
@@ -0,0 +1,6 @@
1
+ <%= check_code.html_safe if defined?(check_code) -%>
2
+ <% if links.any? -%>
3
+ <ul class="ads">
4
+ <%= render partial: 'sape/link', collection: links -%>
5
+ </ul>
6
+ <% end -%>
@@ -0,0 +1,19 @@
1
+ class Sape::MigrationGenerator < Rails::Generators::Base
2
+ require 'rails/generators'
3
+ require 'rails/generators/migration'
4
+
5
+ include Rails::Generators::Migration
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def self.next_migration_number(dirname)
9
+ if ActiveRecord::Base.timestamped_migrations
10
+ Time.now.utc.strftime('%Y%m%d%H%M%S')
11
+ else
12
+ sprintf('%.3d', (current_migration_number(dirname) + 1))
13
+ end
14
+ end
15
+
16
+ def create_migration_file
17
+ migration_template 'migration.rb', 'db/migrate/create_sape_storage.rb'
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ class CreateSapeStorage < ActiveRecord::Migration
2
+ def change
3
+ create_table :sape_configs do |t|
4
+ t.string :name
5
+ t.string :value
6
+ end
7
+
8
+ create_table :sape_links do |t|
9
+ t.string :page
10
+ t.string :anchor
11
+ t.string :url
12
+ t.string :host
13
+ t.string :raw_link
14
+ t.string :link_type
15
+ end
16
+ add_index :sape_links, [:link_type, :page]
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ class Sape::ViewsGenerator < Rails::Generators::Base
2
+ require 'rails/generators/base'
3
+
4
+ public_task :copy_views
5
+ source_root File.expand_path('../../../app/views', __FILE__)
6
+
7
+ def copy_views
8
+ directory 'sape', 'app/views/sape'
9
+ end
10
+ end
@@ -0,0 +1,62 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ class Fetcher
5
+ class << self
6
+
7
+ def say text
8
+ puts text if Rails.env.development?
9
+ end
10
+
11
+ def get_data(config, link_type)
12
+
13
+ sape_user = config['sape_user']
14
+ host = config['host'].downcase
15
+ charset = config['charset'] || 'utf-8'
16
+ server = config['server'] || 'dispenser-01.sape.ru'
17
+ links_type = {'simple' => 'code.php', 'context' => 'code_context.php'}
18
+
19
+ url = "http://#{server}/#{links_type[link_type]}?user=#{sape_user}&host=#{host}&format=json&no_slash_fix=true"
20
+
21
+ begin
22
+ data = open(url)
23
+ rescue OpenURI::HTTPError
24
+ fail "Could not receive data"
25
+ end
26
+
27
+ JSON.parse(data.read)
28
+ end
29
+
30
+ def fetch_pages(pages, link_type)
31
+ SapeLink.delete_all
32
+ say "Links:: #{link_type}"
33
+ pages.each do |page_url, links|
34
+ say "Page: #{page_url}"
35
+ links.each do |link|
36
+ item = Nokogiri::HTML.parse(link)
37
+
38
+ anchor = item.css('a').text
39
+ url = item.css('a').attr('href').text
40
+ host = Domainatrix.parse(url).host
41
+ SapeLink.create page: page_url, anchor: anchor, host: host, raw_link: link, url: url, link_type: link_type
42
+ say " Added #{anchor} #{host} #{url}"
43
+ end
44
+ end
45
+ end
46
+
47
+ def fetch_config(config_data, bot_ips)
48
+ SapeConfig.delete_all
49
+ say "Ips:"
50
+ bot_ips.each do |ip|
51
+ SapeConfig.create name: 'ip', value: ip
52
+ say " Added #{ip}"
53
+ end
54
+ say "Config"
55
+ config_data.each do |item, data|
56
+ SapeConfig.create name: item, value: data
57
+ say " Added #{item} = #{data}"
58
+ end
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,5 @@
1
+ class Sape::Railtie < Rails::Railtie
2
+ rake_tasks do
3
+ load 'tasks/sape.rake'
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Sape
2
+ VERSION = "0.0.5"
3
+ end
data/lib/sape.rb ADDED
@@ -0,0 +1,16 @@
1
+ require "sape/version"
2
+
3
+ module Sape
4
+ require 'sape/railtie' if defined?(Rails)
5
+ require 'app/helpers/sape_helper'
6
+
7
+ path = File.join(File.dirname(__FILE__), 'app', 'models')
8
+ $LOAD_PATH << path
9
+
10
+ ActiveSupport::Dependencies.autoload_paths << path
11
+ ActiveSupport::Dependencies.autoload_once_paths.delete(path)
12
+ ActionView::Base.send :include, SapeHelper
13
+ ActionController::Base.prepend_view_path File.join(File.dirname(__FILE__), 'app/views')
14
+ end
15
+
16
+ require 'sape/fetcher.rb'
@@ -0,0 +1,28 @@
1
+ namespace :sape do
2
+
3
+ desc "Fetch links from server"
4
+ task fetch: :environment do
5
+ begin
6
+ config = YAML.load_file('config/sape.yml')
7
+ rescue Errno::ENOENT
8
+ fail "Config file not found (config/sape.yml)"
9
+ end
10
+
11
+ data = Fetcher.get_data(config, 'simple')
12
+ data_context = Fetcher.get_data(config, 'context')
13
+ configs, config_data = {}, {}
14
+
15
+ pages = data['__sape_links__']
16
+ pages_context = data_context['__sape_links__']
17
+ bot_ips = data['__sape_ips__']
18
+
19
+ %W{sape_delimiter sape_show_only_block sape_page_obligatory_output sape_new_url}.each do |item|
20
+ config_data[item] = data["__#{item}__"]
21
+ end
22
+
23
+ Fetcher.fetch_config(config_data, bot_ips) if pages.any?
24
+ Fetcher.fetch_pages(pages, 'simple') if pages.any?
25
+ Fetcher.fetch_pages(pages_context, 'context') if pages_context.any?
26
+
27
+ end
28
+ end
data/sape.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sape/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sape"
8
+ spec.version = Sape::VERSION
9
+ spec.authors = ["Pavel Rodionov"]
10
+ spec.email = ["pasha.rod@mail.ru"]
11
+ spec.summary = "Sape.ru Ruby On Rails module"
12
+ spec.description = "Sape.ru links exchange system integration"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rails", ">= 3.0.0"
22
+ spec.add_dependency "nokogiri"
23
+ spec.add_dependency "domainatrix"
24
+ spec.add_dependency "json"
25
+
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "rspec-rails"
28
+ spec.add_development_dependency "rspec-its"
29
+ spec.add_development_dependency "rspec-activemodel-mocks"
30
+ spec.add_development_dependency "fakeweb"
31
+ spec.add_development_dependency "fakeweb-matcher"
32
+ spec.add_development_dependency "bundler", "~> 1.6"
33
+ spec.add_development_dependency "rake"
34
+ spec.add_development_dependency "sqlite3"
35
+ end
data/spec/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,16 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*.log
16
+ /tmp
@@ -0,0 +1,41 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.1.1'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails', '~> 4.0.3'
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+ # Use CoffeeScript for .js.coffee assets and views
13
+ gem 'coffee-rails', '~> 4.0.0'
14
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
15
+ gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use jquery as the JavaScript library
18
+ gem 'jquery-rails'
19
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
+ gem 'turbolinks'
21
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0', group: :doc
25
+
26
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
27
+ gem 'spring', group: :development
28
+
29
+ # Use ActiveModel has_secure_password
30
+ # gem 'bcrypt', '~> 3.1.7'
31
+
32
+ # Use unicorn as the app server
33
+ # gem 'unicorn'
34
+
35
+ # Use Capistrano for deployment
36
+ # gem 'capistrano-rails', group: :development
37
+
38
+ # Use debugger
39
+ # gem 'debugger', group: [:development, :test]
40
+
41
+ gem 'sape', path: "../../"
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')