Permalink
Browse files

helper name change

git-svn-id: https://svn.thoughtbot.com/plugins/mile_marker/trunk@152 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
1 parent a6da036 commit e3396f2bcaf857ec8fabc67e1c979327156d93f5 cpytel committed Jul 31, 2007
Showing with 37 additions and 29 deletions.
  1. +10 −2 README
  2. +3 −3 Rakefile
  3. +10 −10 lib/mile_marker.rb
  4. +14 −14 test/mile_marker_test.rb
View
@@ -6,18 +6,26 @@ License:: Distributes under the same terms as Ruby
A plugin for visually setting expectations throughout application development.
-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.
+Adds a helper for marking page elements with the milestone they are slated to be developed, and makes them unable to be interacted with.
Usage:
Once the plugin has been installed, in your views you can now do:
-<div class="person" <%= todo "Milestone 6" %>>
+<div class="person" <%= mile 6 %>>
<div class="name">Your Name<div>
</div>
When viewed in development mode, the person div would be overlaid with a grey box with the words "Milestone 6" in it.
+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:
+
+<div class="person" <%= mile "Next Week" %>>
+ <div class="name">Your Name<div>
+</div>
+
+And that will still result in the marker being labeled with "Next Week" instead.
+
By default, the milestone markers will be only appear in the Rails development environment. To customize this, add the following to environment.rb
Thoughtbot::MileMarker.environments = %w(development staging production)
View
@@ -5,17 +5,17 @@ require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
-desc 'Test the todo plugin.'
+desc 'Test the mile_marker plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
-desc 'Generate documentation for the todo plugin.'
+desc 'Generate documentation for the mile_marker plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'Todo'
+ rdoc.title = 'Mile Marker'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
View
@@ -1,8 +1,8 @@
module Thoughtbot
module MileMarkerHelper
- def todo(detail="")
+ def mile(detail="")
return unless MileMarker.enabled?
- "todo=\"" + (detail.is_a?(Fixnum) ? "Milestone " : "") + "#{detail}\""
+ "mile=\"" + (detail.is_a?(Fixnum) ? "Milestone " : "") + "#{detail}\""
end
def initialize_mile_marker(request = nil)
@@ -18,12 +18,12 @@ def add_initialize_mile_marker()
end
class MileMarker
- # The environments in which to enable the Todo functionality to run. Defaults
+ # The environments in which to enable the Mile Marker functionality to run. Defaults
# to 'development' only.
@@environments = ['development']
cattr_accessor :environments
- # Return true if the Todo functionality is enabled for the current environment
+ # Return true if the Mile Marker functionality is enabled for the current environment
def self.enabled?
environments.include?(ENV['RAILS_ENV'])
end
@@ -32,15 +32,15 @@ def self.initialize_mile_marker()
%Q~
<script type="text/javascript">
//<![CDATA[
- function init_todo() {
- $$('*[todo]').each(function(block, index) {
- 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>'
+ function init_miles() {
+ $$('*[mile]').each(function(block, index) {
+ 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>'
new Insertion.Before($(block), html);
- Position.clone($(block), $('todo_'+index));
- $('todo_'+index).toggle();
+ Position.clone($(block), $('mile_'+index));
+ $('mile_'+index).toggle();
});
}
- Event.observe(window, 'load', init_todo, false);
+ Event.observe(window, 'load', init_miles, false);
//]]>
</script>
~
@@ -3,45 +3,45 @@
class MileMarkerTest < Test::Unit::TestCase
include Thoughtbot::MileMarkerHelper
- def test_todo_helper_should_return_nothing_if_no_enabled
+ def test_mile_helper_should_return_nothing_if_no_enabled
Thoughtbot::MileMarker.environments = ['development']
ENV['RAILS_ENV']="test_environment"
- output = todo("Milestone 1")
+ output = mile("Milestone 1")
assert_nil output
end
- def test_todo_helper_should_include_detail_when_supplied_detail
+ def test_mile_helper_should_include_detail_when_supplied_detail
Thoughtbot::MileMarker.environments = ['development']
ENV['RAILS_ENV']="development"
- output = todo("Milestone 1")
- assert_equal "todo=\"Milestone 1\"", output
+ output = mile("Milestone 1")
+ assert_equal "mile=\"Milestone 1\"", output
end
- def test_todo_helper_should_include_add_milestone_when_supplied_integer
+ def test_mile_helper_should_include_add_milestone_when_supplied_integer
Thoughtbot::MileMarker.environments = ['development']
ENV['RAILS_ENV']="development"
- output = todo(1)
- assert_equal "todo=\"Milestone 1\"", output
+ output = mile(1)
+ assert_equal "mile=\"Milestone 1\"", output
end
- def test_todo_helper_should_include_no_detail_when_supplied_no_detail
+ def test_mile_helper_should_include_no_detail_when_supplied_no_detail
Thoughtbot::MileMarker.environments = ['development']
ENV['RAILS_ENV']="development"
- output = todo
- assert_equal "todo=\"\"", output
+ output = mile
+ assert_equal "mile=\"\"", output
end
- def test_initialize_todo_should_return_nothing_if_not_enabled
+ def test_initialize_mile_should_return_nothing_if_not_enabled
ENV['RAILS_ENV']="test_environment"
output = initialize_mile_marker
assert_nil output
end
- def test_initialize_todo_should_return_javascript_if_enabled
+ def test_initialize_mile_should_return_javascript_if_enabled
Thoughtbot::MileMarker.environments = ['development']
ENV['RAILS_ENV']="development"
output = initialize_mile_marker
- assert_match /function init_todo/, output
+ assert_match /function init_miles/, output
end
def test_javascript_should_be_added_to_head_if_enabled

0 comments on commit e3396f2

Please sign in to comment.