robots_dot_text 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 687c2189524902c15e273a1369f679f5b7890f3b
4
- data.tar.gz: c76dd2d1fb824dd84d7449894591029d3016b82e
3
+ metadata.gz: b3471a326d11dbfc727ce646ca8fe5b7a4225b47
4
+ data.tar.gz: d2455c4ba664b536e4b54fc315174c66715541ec
5
5
  SHA512:
6
- metadata.gz: 5dc0218b03bc20fb06cb5a531c8a8a961f025cca40ee94387c3d4d4093e1949be91a0e83674d588a4db7a4baad5a3bc925e09c3cc5f5810f121d01b39f13421c
7
- data.tar.gz: 6151bf7a856d57de6de7c26ffa4418ac823c8ea188ac73f52500e97ce687dd74d7722fe80c154e22a89f4271cb964aba0edd22fa79c56cede0f33eef17526282
6
+ metadata.gz: cba5a0eea5b7d943acd576c801248e4fd88dc844244728ecebb7073126060b10912ae90208a019c28009e361b9e60ceef9e253aede25b45de0bd7bbb004c01f0
7
+ data.tar.gz: c3f9c19785211cf6df7c286d441ca01458cb1aff5c6c94176171326b4c4770afc6bff288b63ce82923b3983a0eb7fd897f6c2d105f484c896930112a5470cdf5
data/README.md CHANGED
@@ -27,4 +27,15 @@ You can create a file for every rails environment using the naming convention ro
27
27
  robots.production.txt
28
28
  robots.development.txt
29
29
 
30
-
30
+ ## Further customization of robots.txt file names
31
+ If you would like to customize the robots.txt file name to something other than the rails environment you can do so by overriding the `RobotsDotTextController#robots_file_descriptor` method in your app.
32
+
33
+ class RobotsDotTextController < ActionController::Base
34
+ include RobotsController
35
+ private
36
+ def robots_file_descriptor
37
+ request.env["SERVER_NAME"]
38
+ end
39
+ end
40
+
41
+ The above would load `robots.localhost.txt` when running under `localhost:3000` or `robots.example.txt` when running under `example.com`.
@@ -1,9 +1,3 @@
1
1
  class RobotsDotTextController < ActionController::Base
2
- def show
3
- begin
4
- render "public/robots.#{Rails.env}.txt", layout: false, content_type: 'text/plain'
5
- rescue ActionView::MissingTemplate
6
- render "public/robots.default.txt", layout: false, content_type: 'text/plain'
7
- end
8
- end
2
+ include RobotsController
9
3
  end
@@ -1,4 +1,5 @@
1
1
  require "robots_dot_text/engine"
2
+ require "robots_dot_text/robots_controller"
2
3
 
3
4
  module RobotsDotText
4
5
  end
@@ -0,0 +1,26 @@
1
+ module RobotsController
2
+ extend ActiveSupport::Concern
3
+
4
+ def show
5
+ begin
6
+ render file: robots_file_path, layout: false, content_type: 'text/plain'
7
+ rescue ActionView::MissingTemplate
8
+ render file: default_robots_path, layout: false, content_type: 'text/plain'
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def robots_file_path
15
+ File.join([Rails.root, 'public', "robots.#{robots_file_descriptor}.txt"])
16
+ end
17
+
18
+ def default_robots_path
19
+ File.join([Rails.root, 'public', 'robots.default.txt'])
20
+ end
21
+
22
+ def robots_file_descriptor
23
+ Rails.env.to_s
24
+ end
25
+
26
+ end
@@ -1,3 +1,3 @@
1
1
  module RobotsDotText
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -333,3 +333,86 @@ Processing by RobotsDotTextController#show as HTML
333
333
  Rendered public/robots.test.txt (1.2ms)
334
334
  Completed 200 OK in 7ms (Views: 7.0ms | ActiveRecord: 0.0ms)
335
335
   (0.1ms) rollback transaction
336
+  (0.1ms) begin transaction
337
+ --------------------------------------------------------------------
338
+ RobotsDotTextRenderTest: test_The_test_robots.txt_should_be_rendered
339
+ --------------------------------------------------------------------
340
+ Started GET "/robots.txt" for 127.0.0.1 at 2015-02-20 12:36:49 -0800
341
+  (0.1ms) rollback transaction
342
+  (0.0ms) begin transaction
343
+ -----------------------------
344
+ RobotsDotTextTest: test_truth
345
+ -----------------------------
346
+  (0.0ms) rollback transaction
347
+  (0.1ms) begin transaction
348
+ -----------------------------
349
+ RobotsDotTextTest: test_truth
350
+ -----------------------------
351
+  (0.0ms) rollback transaction
352
+  (0.0ms) begin transaction
353
+ --------------------------------------------------------------------
354
+ RobotsDotTextRenderTest: test_The_test_robots.txt_should_be_rendered
355
+ --------------------------------------------------------------------
356
+ Started GET "/robots.txt" for 127.0.0.1 at 2015-02-20 12:37:17 -0800
357
+ Processing by RobotsDotTextController#show as HTML
358
+ Rendered public/robots.test.txt (3.8ms)
359
+ Completed 200 OK in 17ms (Views: 16.6ms | ActiveRecord: 0.0ms)
360
+  (0.1ms) rollback transaction
361
+  (0.1ms) begin transaction
362
+ -----------------------------
363
+ RobotsDotTextTest: test_truth
364
+ -----------------------------
365
+  (0.1ms) rollback transaction
366
+  (0.1ms) begin transaction
367
+ --------------------------------------------------------------------
368
+ RobotsDotTextRenderTest: test_The_test_robots.txt_should_be_rendered
369
+ --------------------------------------------------------------------
370
+  (0.1ms) rollback transaction
371
+  (0.1ms) begin transaction
372
+ --------------------------------------------------------------------
373
+ RobotsDotTextRenderTest: test_The_test_robots.txt_should_be_rendered
374
+ --------------------------------------------------------------------
375
+  (0.1ms) rollback transaction
376
+  (0.0ms) begin transaction
377
+ -----------------------------
378
+ RobotsDotTextTest: test_truth
379
+ -----------------------------
380
+  (0.0ms) rollback transaction
381
+  (0.1ms) begin transaction
382
+ --------------------------------------------------------------------
383
+ RobotsDotTextRenderTest: test_The_test_robots.txt_should_be_rendered
384
+ --------------------------------------------------------------------
385
+  (0.1ms) rollback transaction
386
+  (0.0ms) begin transaction
387
+ -----------------------------
388
+ RobotsDotTextTest: test_truth
389
+ -----------------------------
390
+  (0.0ms) rollback transaction
391
+  (0.2ms) begin transaction
392
+ --------------------------------------------------------------------
393
+ RobotsDotTextRenderTest: test_The_test_robots.txt_should_be_rendered
394
+ --------------------------------------------------------------------
395
+ Started GET "/robots.txt" for 127.0.0.1 at 2015-02-20 15:30:26 -0800
396
+ Processing by RobotsDotTextController#show as HTML
397
+ Rendered public/robots.test.txt (1.4ms)
398
+ Completed 200 OK in 11ms (Views: 10.8ms | ActiveRecord: 0.0ms)
399
+  (0.1ms) rollback transaction
400
+  (0.0ms) begin transaction
401
+ -----------------------------
402
+ RobotsDotTextTest: test_truth
403
+ -----------------------------
404
+  (0.0ms) rollback transaction
405
+  (0.1ms) begin transaction
406
+ --------------------------------------------------------------------
407
+ RobotsDotTextRenderTest: test_The_test_robots.txt_should_be_rendered
408
+ --------------------------------------------------------------------
409
+ Started GET "/robots.txt" for 127.0.0.1 at 2015-02-20 15:32:15 -0800
410
+ Processing by RobotsDotTextController#show as HTML
411
+ Rendered public/robots.test.txt (1.4ms)
412
+ Completed 200 OK in 10ms (Views: 9.5ms | ActiveRecord: 0.0ms)
413
+  (0.1ms) rollback transaction
414
+  (0.0ms) begin transaction
415
+ -----------------------------
416
+ RobotsDotTextTest: test_truth
417
+ -----------------------------
418
+  (0.0ms) rollback transaction
@@ -4,7 +4,7 @@ class RobotsDotTextRenderTest < ActionDispatch::IntegrationTest
4
4
  fixtures :all
5
5
 
6
6
  test "The test robots.txt should be rendered" do
7
- get 'robots.txt'
7
+ get '/robots.txt'
8
8
  assert_response :success
9
9
  assert_equal "# Dummy test-app robots file", response.body, 'Incorrect robots.txt returned'
10
10
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robots_dot_text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jessie Keck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-16 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.1.7
19
+ version: 4.0.0
20
20
  type: :runtime
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.1.7
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,8 +53,8 @@ files:
53
53
  - lib/generators/robots_dot_text/move_existing_robots_file_generator.rb
54
54
  - lib/robots_dot_text.rb
55
55
  - lib/robots_dot_text/engine.rb
56
+ - lib/robots_dot_text/robots_controller.rb
56
57
  - lib/robots_dot_text/version.rb
57
- - lib/tasks/robots_dot_text_tasks.rake
58
58
  - test/dummy/README.rdoc
59
59
  - test/dummy/Rakefile
60
60
  - test/dummy/app/assets/javascripts/application.js
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :robots_dot_text do
3
- # # Task goes here
4
- # end