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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -1
  3. data/lib/robotron.rb +15 -7
  4. data/lib/robotron/version.rb +1 -1
  5. data/spec/robotron_spec.rb +25 -0
  6. data/spec/spec_helper.rb +3 -3
  7. metadata +15 -86
  8. data/spec/dummy/README.rdoc +0 -28
  9. data/spec/dummy/Rakefile +0 -6
  10. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  11. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  12. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  13. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  14. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  15. data/spec/dummy/bin/bundle +0 -3
  16. data/spec/dummy/bin/rails +0 -4
  17. data/spec/dummy/bin/rake +0 -4
  18. data/spec/dummy/bin/setup +0 -29
  19. data/spec/dummy/config.ru +0 -4
  20. data/spec/dummy/config/application.rb +0 -25
  21. data/spec/dummy/config/boot.rb +0 -5
  22. data/spec/dummy/config/database.yml +0 -25
  23. data/spec/dummy/config/environment.rb +0 -5
  24. data/spec/dummy/config/environments/development.rb +0 -41
  25. data/spec/dummy/config/environments/production.rb +0 -79
  26. data/spec/dummy/config/environments/test.rb +0 -42
  27. data/spec/dummy/config/initializers/assets.rb +0 -11
  28. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  29. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  30. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  31. data/spec/dummy/config/initializers/inflections.rb +0 -16
  32. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  33. data/spec/dummy/config/initializers/session_store.rb +0 -3
  34. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  35. data/spec/dummy/config/locales/en.yml +0 -23
  36. data/spec/dummy/config/routes.rb +0 -3
  37. data/spec/dummy/config/secrets.yml +0 -22
  38. data/spec/dummy/db/development.sqlite3 +0 -0
  39. data/spec/dummy/log/development.log +0 -554
  40. data/spec/dummy/public/404.html +0 -67
  41. data/spec/dummy/public/422.html +0 -67
  42. data/spec/dummy/public/500.html +0 -66
  43. data/spec/dummy/public/favicon.ico +0 -0
  44. data/spec/robotron_test.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d98e83b9ddc83acdb475cce2f794699b1404f9b
4
- data.tar.gz: 2127c1b2ea670e993fd533ca02c9e483e65e9c4d
3
+ metadata.gz: 9d22cd6f6c7336231f9f9f066a5a7c8ba58a7724
4
+ data.tar.gz: 8d3cd0ff88adb92ef55b527fc92594a5684a6a00
5
5
  SHA512:
6
- metadata.gz: dddb489f382556f1f8da5f22f301b810adb906487a51b583a57018909c34fefbdd1e24471548ba36965747e8c2b72b47f45f16d18d7f5fe82d9ed3c7c0ea5943
7
- data.tar.gz: 8ab25a3abffb1ceb4ad30be5e0c8fdb2a2e89b74fd6832baed84bdebc9608d5326723dce67e9690ac8972a7fdd92d091eb7b6a6d4d25950c9d5ddf70139094ec
6
+ metadata.gz: 65f8cb4f1a32d3985740a4673065da197813c045bd53c9db14d9c8aa4e2ff9570c9ced1a2f506153612533f505e6decbeeda6bfccd61d834be0f199a0e02ca02
7
+ data.tar.gz: 45e082552538e308082d29fe2d75d4cf301ada453eabe8638335d5f6ca7c704950835b0ad6de8da42f13e1933c43b5b410c5a514fc5f94a4d3e9143b342acdf3
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Robotron
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/robotron.svg)](https://badge.fury.io/rb/robotron)
4
+ [![Code Climate](https://codeclimate.com/github/droptheplot/robotron/badges/gpa.svg)](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 = if Rails.env.production?
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
- [404, default_headers, [default_body]]
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-agent: *\nDisallow: /"
24
+ "User-Agent: *\nDisallow: /"
17
25
  end
18
26
 
19
27
  def default_headers
@@ -1,3 +1,3 @@
1
1
  module Robotron
2
- VERSION = "0.0.1"
2
+ VERSION = '0.1.0'
3
3
  end
@@ -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
@@ -1,6 +1,6 @@
1
- ENV['RAILS_ENV'] ||= 'test'
2
- require File.expand_path("../dummy/config/environment", __FILE__)
3
- require "rspec/rails"
1
+ require 'rspec'
2
+ require 'rack'
3
+ require 'robotron'
4
4
 
5
5
  RSpec.configure do |config|
6
6
  config.expect_with :rspec do |expectations|
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.1
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: 2015-06-14 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.1
20
- type: :runtime
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.2.1
26
+ version: 3.4.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: sqlite3
28
+ name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
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: '0'
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/dummy/README.rdoc
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.6
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/dummy/app/assets/javascripts/application.js
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:
@@ -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,6 +0,0 @@
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
@@ -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,5 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -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>
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
data/spec/dummy/bin/rails DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
data/spec/dummy/bin/rake DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
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,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Rails.application
@@ -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
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -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