robotron 0.0.1 → 0.1.0
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.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/robotron.rb +15 -7
- data/lib/robotron/version.rb +1 -1
- data/spec/robotron_spec.rb +25 -0
- data/spec/spec_helper.rb +3 -3
- metadata +15 -86
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -25
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -554
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/robotron_test.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d22cd6f6c7336231f9f9f066a5a7c8ba58a7724
|
4
|
+
data.tar.gz: 8d3cd0ff88adb92ef55b527fc92594a5684a6a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65f8cb4f1a32d3985740a4673065da197813c045bd53c9db14d9c8aa4e2ff9570c9ced1a2f506153612533f505e6decbeeda6bfccd61d834be0f199a0e02ca02
|
7
|
+
data.tar.gz: 45e082552538e308082d29fe2d75d4cf301ada453eabe8638335d5f6ca7c704950835b0ad6de8da42f13e1933c43b5b410c5a514fc5f94a4d3e9143b342acdf3
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Robotron
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/robotron)
|
4
|
+
[](https://codeclimate.com/github/droptheplot/robotron)
|
5
|
+
|
3
6
|
Dynamic robots.txt for different Rails environments with Rack.
|
4
7
|
|
5
8
|
## Getting started
|
@@ -24,4 +27,4 @@ Rails.application.routes.draw do
|
|
24
27
|
end
|
25
28
|
```
|
26
29
|
|
27
|
-
Create **config/robots.txt** for production
|
30
|
+
Create **config/robots.txt.production** for production
|
data/lib/robotron.rb
CHANGED
@@ -1,19 +1,27 @@
|
|
1
1
|
module Robotron
|
2
2
|
class << self
|
3
3
|
def call(env)
|
4
|
-
body =
|
5
|
-
File.read(Rails.root.join('config', 'robots.txt'))
|
6
|
-
else
|
7
|
-
default_body
|
8
|
-
end
|
4
|
+
body = File.read(robots_path)
|
9
5
|
|
10
6
|
[200, default_headers, [body]]
|
11
7
|
rescue Errno::ENOENT
|
12
|
-
[
|
8
|
+
[200, default_headers, [default_body]]
|
9
|
+
end
|
10
|
+
|
11
|
+
def environment
|
12
|
+
ENV['RACK_ENV'] || 'development'
|
13
|
+
end
|
14
|
+
|
15
|
+
def robots_directory
|
16
|
+
defined?(Rails) ? Rails.root.join('config') : File.join('spec')
|
17
|
+
end
|
18
|
+
|
19
|
+
def robots_path
|
20
|
+
File.join(robots_directory, "robots.txt.#{ environment }")
|
13
21
|
end
|
14
22
|
|
15
23
|
def default_body
|
16
|
-
"User-
|
24
|
+
"User-Agent: *\nDisallow: /"
|
17
25
|
end
|
18
26
|
|
19
27
|
def default_headers
|
data/lib/robotron/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Robotron do
|
4
|
+
ENV['RACK_ENV'] ||= 'production'
|
5
|
+
|
6
|
+
let(:request) { Rack::MockRequest.new(Robotron) }
|
7
|
+
|
8
|
+
describe 'without robots.txt' do
|
9
|
+
it 'should response with default robots.txt body' do
|
10
|
+
response = request.get('/robots.txt')
|
11
|
+
|
12
|
+
expect(response.body).to eq("User-Agent: *\nDisallow: /")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'with robots.txt' do
|
17
|
+
it 'should response with robots.txt.environment body' do
|
18
|
+
allow(File).to receive(:read).and_return(ENV['RACK_ENV'])
|
19
|
+
|
20
|
+
response = request.get('/robots.txt')
|
21
|
+
|
22
|
+
expect(response.body).to eq(ENV['RACK_ENV'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robotron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Novikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
20
|
-
type: :
|
19
|
+
version: 3.4.0
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
26
|
+
version: 3.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.6.4
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.6.4
|
41
41
|
description: Dynamic robots.txt for different Rails environments with Rack.
|
42
42
|
email:
|
43
43
|
- novikov359@gmail.com
|
@@ -50,43 +50,7 @@ files:
|
|
50
50
|
- Rakefile
|
51
51
|
- lib/robotron.rb
|
52
52
|
- lib/robotron/version.rb
|
53
|
-
- spec/
|
54
|
-
- spec/dummy/Rakefile
|
55
|
-
- spec/dummy/app/assets/javascripts/application.js
|
56
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
57
|
-
- spec/dummy/app/controllers/application_controller.rb
|
58
|
-
- spec/dummy/app/helpers/application_helper.rb
|
59
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
60
|
-
- spec/dummy/bin/bundle
|
61
|
-
- spec/dummy/bin/rails
|
62
|
-
- spec/dummy/bin/rake
|
63
|
-
- spec/dummy/bin/setup
|
64
|
-
- spec/dummy/config.ru
|
65
|
-
- spec/dummy/config/application.rb
|
66
|
-
- spec/dummy/config/boot.rb
|
67
|
-
- spec/dummy/config/database.yml
|
68
|
-
- spec/dummy/config/environment.rb
|
69
|
-
- spec/dummy/config/environments/development.rb
|
70
|
-
- spec/dummy/config/environments/production.rb
|
71
|
-
- spec/dummy/config/environments/test.rb
|
72
|
-
- spec/dummy/config/initializers/assets.rb
|
73
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
74
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
75
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
76
|
-
- spec/dummy/config/initializers/inflections.rb
|
77
|
-
- spec/dummy/config/initializers/mime_types.rb
|
78
|
-
- spec/dummy/config/initializers/session_store.rb
|
79
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
80
|
-
- spec/dummy/config/locales/en.yml
|
81
|
-
- spec/dummy/config/routes.rb
|
82
|
-
- spec/dummy/config/secrets.yml
|
83
|
-
- spec/dummy/db/development.sqlite3
|
84
|
-
- spec/dummy/log/development.log
|
85
|
-
- spec/dummy/public/404.html
|
86
|
-
- spec/dummy/public/422.html
|
87
|
-
- spec/dummy/public/500.html
|
88
|
-
- spec/dummy/public/favicon.ico
|
89
|
-
- spec/robotron_test.rb
|
53
|
+
- spec/robotron_spec.rb
|
90
54
|
- spec/spec_helper.rb
|
91
55
|
homepage: https://github.com/droptheplot/robotron
|
92
56
|
licenses:
|
@@ -108,46 +72,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
72
|
version: '0'
|
109
73
|
requirements: []
|
110
74
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.4.
|
75
|
+
rubygems_version: 2.4.8
|
112
76
|
signing_key:
|
113
77
|
specification_version: 4
|
114
78
|
summary: Dynamic robots.txt for different Rails environments with Rack.
|
115
79
|
test_files:
|
116
|
-
- spec/
|
117
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
118
|
-
- spec/dummy/app/controllers/application_controller.rb
|
119
|
-
- spec/dummy/app/helpers/application_helper.rb
|
120
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
121
|
-
- spec/dummy/bin/bundle
|
122
|
-
- spec/dummy/bin/rails
|
123
|
-
- spec/dummy/bin/rake
|
124
|
-
- spec/dummy/bin/setup
|
125
|
-
- spec/dummy/config/application.rb
|
126
|
-
- spec/dummy/config/boot.rb
|
127
|
-
- spec/dummy/config/database.yml
|
128
|
-
- spec/dummy/config/environment.rb
|
129
|
-
- spec/dummy/config/environments/development.rb
|
130
|
-
- spec/dummy/config/environments/production.rb
|
131
|
-
- spec/dummy/config/environments/test.rb
|
132
|
-
- spec/dummy/config/initializers/assets.rb
|
133
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
134
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
135
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
136
|
-
- spec/dummy/config/initializers/inflections.rb
|
137
|
-
- spec/dummy/config/initializers/mime_types.rb
|
138
|
-
- spec/dummy/config/initializers/session_store.rb
|
139
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
140
|
-
- spec/dummy/config/locales/en.yml
|
141
|
-
- spec/dummy/config/routes.rb
|
142
|
-
- spec/dummy/config/secrets.yml
|
143
|
-
- spec/dummy/config.ru
|
144
|
-
- spec/dummy/db/development.sqlite3
|
145
|
-
- spec/dummy/log/development.log
|
146
|
-
- spec/dummy/public/404.html
|
147
|
-
- spec/dummy/public/422.html
|
148
|
-
- spec/dummy/public/500.html
|
149
|
-
- spec/dummy/public/favicon.ico
|
150
|
-
- spec/dummy/Rakefile
|
151
|
-
- spec/dummy/README.rdoc
|
152
|
-
- spec/robotron_test.rb
|
80
|
+
- spec/robotron_spec.rb
|
153
81
|
- spec/spec_helper.rb
|
82
|
+
has_rdoc:
|
data/spec/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
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>.
|
data/spec/dummy/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
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 any plugin's vendor/assets/stylesheets directory 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
|
-
*/
|
@@ -1,14 +0,0 @@
|
|
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>
|
data/spec/dummy/bin/bundle
DELETED
data/spec/dummy/bin/rails
DELETED
data/spec/dummy/bin/rake
DELETED
data/spec/dummy/bin/setup
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
# path to your application root.
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
-
|
7
|
-
Dir.chdir APP_ROOT do
|
8
|
-
# This script is a starting point to setup your application.
|
9
|
-
# Add necessary setup steps to this file:
|
10
|
-
|
11
|
-
puts "== Installing dependencies =="
|
12
|
-
system "gem install bundler --conservative"
|
13
|
-
system "bundle check || bundle install"
|
14
|
-
|
15
|
-
# puts "\n== Copying sample files =="
|
16
|
-
# unless File.exist?("config/database.yml")
|
17
|
-
# system "cp config/database.yml.sample config/database.yml"
|
18
|
-
# end
|
19
|
-
|
20
|
-
puts "\n== Preparing database =="
|
21
|
-
system "bin/rake db:setup"
|
22
|
-
|
23
|
-
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system "rm -f log/*"
|
25
|
-
system "rm -rf tmp/cache"
|
26
|
-
|
27
|
-
puts "\n== Restarting application server =="
|
28
|
-
system "touch tmp/restart.txt"
|
29
|
-
end
|
data/spec/dummy/config.ru
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
|
5
|
-
Bundler.require(*Rails.groups)
|
6
|
-
require "robotron"
|
7
|
-
|
8
|
-
module Dummy
|
9
|
-
class Application < Rails::Application
|
10
|
-
# Settings in config/environments/* take precedence over those specified here.
|
11
|
-
# Application configuration should go into files in config/initializers
|
12
|
-
# -- all .rb files in that directory are automatically loaded.
|
13
|
-
|
14
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
-
|
18
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
-
# config.i18n.default_locale = :de
|
21
|
-
|
22
|
-
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
|
-
config.active_record.raise_in_transactional_callbacks = true
|
24
|
-
end
|
25
|
-
end
|
data/spec/dummy/config/boot.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
#
|
7
|
-
default: &default
|
8
|
-
adapter: sqlite3
|
9
|
-
pool: 5
|
10
|
-
timeout: 5000
|
11
|
-
|
12
|
-
development:
|
13
|
-
<<: *default
|
14
|
-
database: db/development.sqlite3
|
15
|
-
|
16
|
-
# Warning: The database defined as "test" will be erased and
|
17
|
-
# re-generated from your development database when you run "rake".
|
18
|
-
# Do not set this db to the same as development or production.
|
19
|
-
test:
|
20
|
-
<<: *default
|
21
|
-
database: db/test.sqlite3
|
22
|
-
|
23
|
-
production:
|
24
|
-
<<: *default
|
25
|
-
database: db/production.sqlite3
|