Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

helper name change

git-svn-id: https://svn.thoughtbot.com/plugins/mile_marker/trunk@152 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
commit e3396f2bcaf857ec8fabc67e1c979327156d93f5 1 parent a6da036
cpytel authored
12 README
@@ -6,18 +6,26 @@ License:: Distributes under the same terms as Ruby
6 6
7 7 A plugin for visually setting expectations throughout application development.
8 8
9   -Adds a todo helper for marking page elements with the milestone they are slated to be developed, and makes them unable to be interacted with.
  9 +Adds a helper for marking page elements with the milestone they are slated to be developed, and makes them unable to be interacted with.
10 10
11 11 Usage:
12 12
13 13 Once the plugin has been installed, in your views you can now do:
14 14
15   -<div class="person" <%= todo "Milestone 6" %>>
  15 +<div class="person" <%= mile 6 %>>
16 16 <div class="name">Your Name<div>
17 17 </div>
18 18
19 19 When viewed in development mode, the person div would be overlaid with a grey box with the words "Milestone 6" in it.
20 20
  21 +If you happen to not call your milestones, "milestones", or for any other reason want the label to be something different, just supply a string instead:
  22 +
  23 +<div class="person" <%= mile "Next Week" %>>
  24 + <div class="name">Your Name<div>
  25 +</div>
  26 +
  27 +And that will still result in the marker being labeled with "Next Week" instead.
  28 +
21 29 By default, the milestone markers will be only appear in the Rails development environment. To customize this, add the following to environment.rb
22 30
23 31 Thoughtbot::MileMarker.environments = %w(development staging production)
6 Rakefile
@@ -5,17 +5,17 @@ require 'rake/rdoctask'
5 5 desc 'Default: run unit tests.'
6 6 task :default => :test
7 7
8   -desc 'Test the todo plugin.'
  8 +desc 'Test the mile_marker plugin.'
9 9 Rake::TestTask.new(:test) do |t|
10 10 t.libs << 'lib'
11 11 t.pattern = 'test/**/*_test.rb'
12 12 t.verbose = true
13 13 end
14 14
15   -desc 'Generate documentation for the todo plugin.'
  15 +desc 'Generate documentation for the mile_marker plugin.'
16 16 Rake::RDocTask.new(:rdoc) do |rdoc|
17 17 rdoc.rdoc_dir = 'rdoc'
18   - rdoc.title = 'Todo'
  18 + rdoc.title = 'Mile Marker'
19 19 rdoc.options << '--line-numbers' << '--inline-source'
20 20 rdoc.rdoc_files.include('README')
21 21 rdoc.rdoc_files.include('lib/**/*.rb')
20 lib/mile_marker.rb
... ... @@ -1,8 +1,8 @@
1 1 module Thoughtbot
2 2 module MileMarkerHelper
3   - def todo(detail="")
  3 + def mile(detail="")
4 4 return unless MileMarker.enabled?
5   - "todo=\"" + (detail.is_a?(Fixnum) ? "Milestone " : "") + "#{detail}\""
  5 + "mile=\"" + (detail.is_a?(Fixnum) ? "Milestone " : "") + "#{detail}\""
6 6 end
7 7
8 8 def initialize_mile_marker(request = nil)
@@ -18,12 +18,12 @@ def add_initialize_mile_marker()
18 18 end
19 19
20 20 class MileMarker
21   - # The environments in which to enable the Todo functionality to run. Defaults
  21 + # The environments in which to enable the Mile Marker functionality to run. Defaults
22 22 # to 'development' only.
23 23 @@environments = ['development']
24 24 cattr_accessor :environments
25 25
26   - # Return true if the Todo functionality is enabled for the current environment
  26 + # Return true if the Mile Marker functionality is enabled for the current environment
27 27 def self.enabled?
28 28 environments.include?(ENV['RAILS_ENV'])
29 29 end
@@ -32,15 +32,15 @@ def self.initialize_mile_marker()
32 32 %Q~
33 33 <script type="text/javascript">
34 34 //<![CDATA[
35   - function init_todo() {
36   - $$('*[todo]').each(function(block, index) {
37   - html = '<div id="todo_'+index+'" style="display: none; z-index: 1000; position: absolute; background-color: #000; opacity: .33; filter: alpha(opacity=33); color: #fff; font-family: Verdana; font-weight: bold; font-size: 20px;"><div style="margin: 5px;">'+block.getAttribute('todo')+'</div></div>'
  35 + function init_miles() {
  36 + $$('*[mile]').each(function(block, index) {
  37 + html = '<div id="mile_'+index+'" style="display: none; z-index: 1000; position: absolute; background-color: #000; opacity: .33; filter: alpha(opacity=33); color: #fff; font-family: Verdana; font-weight: bold; font-size: 20px;"><div style="margin: 5px;">'+block.getAttribute('mile')+'</div></div>'
38 38 new Insertion.Before($(block), html);
39   - Position.clone($(block), $('todo_'+index));
40   - $('todo_'+index).toggle();
  39 + Position.clone($(block), $('mile_'+index));
  40 + $('mile_'+index).toggle();
41 41 });
42 42 }
43   - Event.observe(window, 'load', init_todo, false);
  43 + Event.observe(window, 'load', init_miles, false);
44 44 //]]>
45 45 </script>
46 46 ~
28 test/mile_marker_test.rb
@@ -3,45 +3,45 @@
3 3 class MileMarkerTest < Test::Unit::TestCase
4 4 include Thoughtbot::MileMarkerHelper
5 5
6   - def test_todo_helper_should_return_nothing_if_no_enabled
  6 + def test_mile_helper_should_return_nothing_if_no_enabled
7 7 Thoughtbot::MileMarker.environments = ['development']
8 8 ENV['RAILS_ENV']="test_environment"
9   - output = todo("Milestone 1")
  9 + output = mile("Milestone 1")
10 10 assert_nil output
11 11 end
12 12
13   - def test_todo_helper_should_include_detail_when_supplied_detail
  13 + def test_mile_helper_should_include_detail_when_supplied_detail
14 14 Thoughtbot::MileMarker.environments = ['development']
15 15 ENV['RAILS_ENV']="development"
16   - output = todo("Milestone 1")
17   - assert_equal "todo=\"Milestone 1\"", output
  16 + output = mile("Milestone 1")
  17 + assert_equal "mile=\"Milestone 1\"", output
18 18 end
19 19
20   - def test_todo_helper_should_include_add_milestone_when_supplied_integer
  20 + def test_mile_helper_should_include_add_milestone_when_supplied_integer
21 21 Thoughtbot::MileMarker.environments = ['development']
22 22 ENV['RAILS_ENV']="development"
23   - output = todo(1)
24   - assert_equal "todo=\"Milestone 1\"", output
  23 + output = mile(1)
  24 + assert_equal "mile=\"Milestone 1\"", output
25 25 end
26 26
27   - def test_todo_helper_should_include_no_detail_when_supplied_no_detail
  27 + def test_mile_helper_should_include_no_detail_when_supplied_no_detail
28 28 Thoughtbot::MileMarker.environments = ['development']
29 29 ENV['RAILS_ENV']="development"
30   - output = todo
31   - assert_equal "todo=\"\"", output
  30 + output = mile
  31 + assert_equal "mile=\"\"", output
32 32 end
33 33
34   - def test_initialize_todo_should_return_nothing_if_not_enabled
  34 + def test_initialize_mile_should_return_nothing_if_not_enabled
35 35 ENV['RAILS_ENV']="test_environment"
36 36 output = initialize_mile_marker
37 37 assert_nil output
38 38 end
39 39
40   - def test_initialize_todo_should_return_javascript_if_enabled
  40 + def test_initialize_mile_should_return_javascript_if_enabled
41 41 Thoughtbot::MileMarker.environments = ['development']
42 42 ENV['RAILS_ENV']="development"
43 43 output = initialize_mile_marker
44   - assert_match /function init_todo/, output
  44 + assert_match /function init_miles/, output
45 45 end
46 46
47 47 def test_javascript_should_be_added_to_head_if_enabled

0 comments on commit e3396f2

Please sign in to comment.
Something went wrong with that request. Please try again.