Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Documentation improvements #5

Merged
merged 3 commits into from

2 participants

@troysurrett

I've gently updated the documentation on this project. Please consider merging my changes.

I've also added tests to check the spelling in branch spelling-tests. Both the tests and documentation updates are in my master branch.

Thanks!

Troy Surrett added some commits
Troy Surrett Failing test to ensure there are no misspellings in the README.rdoc file
Includes a constant in test/helper.rb to excuse certain words.
Requires aspell to be installed and available on the command line to
run the tests.
b67a0e1
Troy Surrett Test for proper spelling in the project's license
Also a refactor of the code that asserts correct spelling in a given file.
c9581f1
Troy Surrett First pass at updating the README for grammar/spelling
The test that asserts the README has no misspellings now passes.
a16efe3
@bokmann
Owner

Beautiful.

@bokmann bokmann merged commit 196b87f into bokmann:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 3, 2012
  1. Failing test to ensure there are no misspellings in the README.rdoc file

    Troy Surrett authored
    Includes a constant in test/helper.rb to excuse certain words.
    Requires aspell to be installed and available on the command line to
    run the tests.
Commits on Oct 4, 2012
  1. Test for proper spelling in the project's license

    Troy Surrett authored
    Also a refactor of the code that asserts correct spelling in a given file.
  2. First pass at updating the README for grammar/spelling

    Troy Surrett authored
    The test that asserts the README has no misspellings now passes.
This page is out of date. Refresh to see the latest.
Showing with 39 additions and 12 deletions.
  1. +8 −8 README.rdoc
  2. +19 −0 test/helper.rb
  3. +12 −4 test/test_sentient_user.rb
View
16 README.rdoc
@@ -1,11 +1,11 @@
= sentient_user
-How many times have you needed access to the current user in your models? It happens a lot if you aretrying to do some intelligent logging, if you want the models to control some aspect of their access, and so on. This is easy hackery that you can find in blogs entries all over the web, but I wanted a nice package for it, for eseveral reasons:
+How often have you needed to access the current user in your models? This happens often if you are attempting intelligent logging or if you want the models to control some aspect of their access, etc. This is easy hackery that you can find in many blog entries, but I wanted a nice package for it, for several reasons:
* There are several different ways this can be accomplished, but only the variation that uses Thread.local is safe for use in thread-safe rails.
-* Even the Thread.local is considered slightly hacky (but better than monkeypatching ActiveRecord::Base)
-* Should fashions change in this area in Rails' future, I want one place to change it, but I want to keep my methods working.
-* This concept generally breaks in the console, where there is no controller to set the user. This gem adds a make_current method on the user instance, so you can choose to find a user and execute this method. That could be really useful in rake tasks, for insntance.
+* Even using Thread.local is considered slightly hacky (but better than monkeypatching ActiveRecord::Base)
+* Should fashions change in this area in Rails' future, I want one place to change it, and to keep my methods working.
+* This concept generally breaks in the console, where there is no controller to set the user. This gem adds a make_current method on the user instance, so you can choose to find a user and execute the current_user method. That could be really useful in rake tasks, for instance.
== Usage
@@ -17,17 +17,17 @@ include SentientController in your application controller
* You have a current_user method available to your controllers
* You will write your own tests to cover this code.
-If those assumptions don't work for you, feel free to unpack and hack. Its simple enough code to change. I purposefully didn't want to complicate it with an initializer, several config options, etc. as all that would blur this delightfully simple piece of code.
+If those assumptions don't work for you, feel free to unpack and hack. It's simple enough code to change. I purposefully didn't want to complicate it with an initializer, several config options, etc. as all that would blur this delightfully simple piece of code.
== Note on Patches/Pull Requests
* Fork the project.
* Make your feature addition or bug fix.
-* Add tests for it. This is important so I don't break it in a
- future version unintentionally.
+* Add tests for it. This is important so I don't break it
+ unintentionally in a future version.
* Commit, do not mess with rakefile, version, or history.
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
+ (if you want to have your own version, that is fine but please bump the version in a commit by itself which I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.
== Copyright
View
19 test/helper.rb
@@ -18,3 +18,22 @@ class User
end
class AnonymousUser < User ; end
+
+ExceptedWords = %w{ hackery hacky monkeypatching
+ ActiveRecord SentientUser SentientController
+ initializer config rakefile bokmann
+ sublicense MERCHANTABILITY NONINFRINGEMENT
+ }
+
+def check_spelling_in_file(path_relative_to_gem_root)
+ path = "#{File.dirname(__FILE__)}/../#{path_relative_to_gem_root}"
+ begin
+ aspell_output = `cat #{path} | aspell list`
+ rescue => err
+ warn "You probably don't have aspell. On mac: brew install aspell --lang=en"
+ raise err
+ end
+ noticed_words = aspell_output.split($/)
+ misspellings = noticed_words - ExceptedWords
+ assert_equal [], misspellings
+end
View
16 test/test_sentient_user.rb
@@ -6,23 +6,23 @@ class TestSentientUser < Test::Unit::TestCase
p.make_current
assert_equal Person.current, p
end
-
+
should "allow making the 'user' class sentient" do
u = User.new
u.make_current
assert_equal User.current, u
end
-
+
should "not allow making Person.current a user" do
assert_raise ArgumentError do
Person.current = User.new
end
end
-
+
should "allow making person.current a person" do
Person.current = Person.new
end
-
+
should "allow subclasses of user to be assigned to user.current" do
User.current = AnonymousUser.new
end
@@ -46,4 +46,12 @@ class TestSentientUser < Test::Unit::TestCase
assert_equal Person.current, p
end
end
+
+ should "have no spelling errors in its README" do
+ check_spelling_in_file "README.rdoc"
+ end
+
+ should "have no spelling errors in the license" do
+ check_spelling_in_file "LICENSE"
+ end
end
Something went wrong with that request. Please try again.