Permalink
Browse files

minor: whitespace

  • Loading branch information...
1 parent 357a4ab commit 73e896da6e059b4d88330130d758846ab8771ec9 @djsun committed Aug 16, 2010
Showing with 694 additions and 689 deletions.
  1. +1 −1 README.mdown
  2. +1 −1 examples/datacatalog/Rakefile
  3. +5 −5 examples/datacatalog/config/config.rb
  4. +2 −2 examples/datacatalog/lib/base.rb
  5. +5 −5 examples/datacatalog/lib/resource.rb
  6. +2 −2 examples/datacatalog/lib/roles.rb
  7. +6 −6 examples/datacatalog/model_helpers/search.rb
  8. +1 −1 examples/datacatalog/models/categorization.rb
  9. +1 −1 examples/datacatalog/models/note.rb
  10. +3 −3 examples/datacatalog/models/source.rb
  11. +2 −2 examples/datacatalog/models/usage.rb
  12. +7 −7 examples/datacatalog/models/user.rb
  13. +7 −7 examples/datacatalog/resources/categories.rb
  14. +4 −4 examples/datacatalog/resources/categories_sources.rb
  15. +1 −1 examples/datacatalog/resources/notes.rb
  16. +3 −3 examples/datacatalog/resources/sources.rb
  17. +3 −3 examples/datacatalog/resources/sources_usages.rb
  18. +3 −3 examples/datacatalog/resources/users.rb
  19. +2 −2 examples/datacatalog/tasks/db.rake
  20. +1 −1 examples/datacatalog/tasks/test.rake
  21. +1 −1 examples/datacatalog/test/helpers/assertions/assert_include.rb
  22. +1 −1 examples/datacatalog/test/helpers/assertions/assert_not_include.rb
  23. +7 −7 examples/datacatalog/test/helpers/lib/model_factories.rb
  24. +1 −1 examples/datacatalog/test/helpers/lib/model_helpers.rb
  25. +7 −7 examples/datacatalog/test/helpers/lib/request_helpers.rb
  26. +8 −8 examples/datacatalog/test/helpers/shared/api_keys.rb
  27. +1 −1 examples/datacatalog/test/helpers/shared/common_body_responses.rb
  28. +2 −2 examples/datacatalog/test/helpers/shared/model_counts.rb
  29. +4 −4 examples/datacatalog/test/helpers/shared/status_codes.rb
  30. +4 −4 examples/datacatalog/test/helpers/test_cases/resource_test_case.rb
  31. +6 −6 examples/datacatalog/test/models/categorization_test.rb
  32. +8 −8 examples/datacatalog/test/models/category_test.rb
  33. +6 −6 examples/datacatalog/test/models/note_test.rb
  34. +4 −4 examples/datacatalog/test/models/search_test.rb
  35. +5 −5 examples/datacatalog/test/models/source_test.rb
  36. +11 −11 examples/datacatalog/test/models/user_test.rb
  37. +11 −11 examples/datacatalog/test/resources/categories/categories_delete_test.rb
  38. +9 −9 examples/datacatalog/test/resources/categories/categories_get_many_test.rb
  39. +7 −7 examples/datacatalog/test/resources/categories/categories_get_one_test.rb
  40. +16 −16 examples/datacatalog/test/resources/categories/categories_post_test.rb
  41. +17 −17 examples/datacatalog/test/resources/categories/categories_put_test.rb
  42. +25 −25 examples/datacatalog/test/resources/categories_sources/categories_sources_delete_test.rb
  43. +5 −5 examples/datacatalog/test/resources/categories_sources/categories_sources_get_many_test.rb
  44. +15 −15 examples/datacatalog/test/resources/categories_sources/categories_sources_get_one_test.rb
  45. +31 −31 examples/datacatalog/test/resources/categories_sources/categories_sources_post_test.rb
  46. +41 −41 examples/datacatalog/test/resources/categories_sources/categories_sources_put_test.rb
  47. +15 −15 examples/datacatalog/test/resources/notes/notes_get_many_test.rb
  48. +7 −7 examples/datacatalog/test/resources/notes/notes_get_one_test.rb
  49. +12 −12 examples/datacatalog/test/resources/notes/notes_post_test.rb
  50. +11 −11 examples/datacatalog/test/resources/sources/sources_delete_test.rb
  51. +20 −20 examples/datacatalog/test/resources/sources/sources_get_many_search_test.rb
  52. +8 −8 examples/datacatalog/test/resources/sources/sources_get_many_test.rb
  53. +15 −9 examples/datacatalog/test/resources/sources/sources_get_one_test.rb
  54. +13 −13 examples/datacatalog/test/resources/sources/sources_post_test.rb
  55. +30 −30 examples/datacatalog/test/resources/sources/sources_put_test.rb
  56. +24 −24 examples/datacatalog/test/resources/sources_usages/sources_usages_delete_test.rb
  57. +9 −9 examples/datacatalog/test/resources/sources_usages/sources_usages_get_many_filter_test.rb
  58. +9 −9 examples/datacatalog/test/resources/sources_usages/sources_usages_get_many_test.rb
  59. +15 −15 examples/datacatalog/test/resources/sources_usages/sources_usages_get_one_test.rb
  60. +16 −16 examples/datacatalog/test/resources/sources_usages/sources_usages_post_test.rb
  61. +33 −33 examples/datacatalog/test/resources/sources_usages/sources_usages_put_test.rb
  62. +19 −19 examples/datacatalog/test/resources/users/users_delete_test.rb
  63. +16 −16 examples/datacatalog/test/resources/users/users_get_many_test.rb
  64. +8 −8 examples/datacatalog/test/resources/users/users_get_one_test.rb
  65. +13 −13 examples/datacatalog/test/resources/users/users_post_test.rb
  66. +18 −18 examples/datacatalog/test/resources/users/users_put_test.rb
  67. +10 −10 lib/builder.rb
  68. +8 −8 lib/builder/action_definitions.rb
  69. +7 −7 lib/builder/helpers.rb
  70. +13 −14 lib/builder/mongo_helpers.rb
  71. +1 −1 lib/exceptions.rb
  72. +20 −20 lib/resource.rb
  73. +2 −2 lib/roles.rb
  74. +6 −6 notes/permissions.mdown
  75. +1 −1 spec/spec_helper.rb
  76. +2 −2 spec/utility_spec.rb
View
@@ -16,7 +16,7 @@ You will need gemcutter if you don't have it already:
I recommend a user-level install:
gem install resource_sinatra
-
+
Note: in general, beware of `sudo gem install <project_name>` -- it gives elevated privileges. Do you trust `<project name>`? Better to be safe and use a local install to `~/.gem`.
## Usage
@@ -13,7 +13,7 @@ namespace :environment do
puts "Loading application environment..."
require File.dirname(__FILE__) + '/app'
end
-
+
task :models do
puts "Loading models..."
Config.setup_mongomapper
@@ -4,17 +4,17 @@
require 'mongo_mapper'
module Config
-
+
def self.setup
setup_mongomapper
# More application setup can go here...
end
-
+
def self.setup_mongomapper
MongoMapper.connection = new_mongo_connection
MongoMapper.database = environment_config['mongo_database']
end
-
+
def self.new_mongo_connection
Mongo::Connection.new(environment_config["mongo_hostname"])
end
@@ -44,15 +44,15 @@ def self.environment
end
end
end
-
+
def self.environment=(env)
@environment = env
end
def self.environments
config.keys
end
-
+
def self.config
if @config
@config
@@ -1,9 +1,9 @@
module DataCatalog
-
+
class Base < Sinatra::Base
before do
content_type :json
end
end
-
+
end
@@ -1,9 +1,9 @@
require 'uri'
module DataCatalog
-
+
module Resource
-
+
def self.included(includee)
includee.instance_eval do
include SinatraResource::Resource
@@ -21,12 +21,12 @@ def before_authorization(action, role, resource_config)
def convert(object)
object == "" ? "" : object.to_json
end
-
+
def full_uri(path)
base_uri = Config.environment_config["base_uri"]
URI.join(base_uri, path).to_s
end
-
+
def log_event(event, params)
# Application-logic could go here.
end
@@ -73,5 +73,5 @@ def user_for(api_key)
end
end
-
+
end
@@ -1,10 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../../../lib/sinatra_resource')
module DataCatalog
-
+
module Roles
include SinatraResource::Roles
-
+
role :anonymous
role :basic => :anonymous
role :owner => :basic
@@ -1,7 +1,7 @@
module DataCatalog
-
+
class Search
-
+
# Returns an array of strings, tokenized with stopwords removed.
#
# @param [<String>] array
@@ -11,7 +11,7 @@ class Search
def self.process(array)
unstop(tokenize(array))
end
-
+
# Tokenize an array of strings.
#
# @param [<String>] array
@@ -25,7 +25,7 @@ def self.tokenize(array)
end
REMOVE = %r([!,;])
-
+
# Tokenize a string, removing extra characters too.
#
# @param [String] string
@@ -86,7 +86,7 @@ def self.tokens(s)
def self.unstop(array)
array - STOP_WORDS
end
-
+
end
-
+
end
@@ -18,7 +18,7 @@ class Categorization
belongs_to :category, :class_name => 'DataCatalog::Category'
# == Validations
-
+
validate :validate_associations
def validate_associations
@@ -9,7 +9,7 @@ class Note
key :text, String
key :user_id, ObjectId
timestamps!
-
+
# == Indices
# == Associations
@@ -1,5 +1,5 @@
module DataCatalog
-
+
class Source
include MongoMapper::Document
@@ -35,9 +35,9 @@ def categories
validates_presence_of :title
validates_presence_of :url
-
+
# == Callbacks
-
+
before_save :update_keywords
def update_keywords
self._keywords = DataCatalog::Search.process([title, description])
@@ -1,7 +1,7 @@
module DataCatalog
class Usage
-
+
include MongoMapper::EmbeddedDocument
# == Attributes
@@ -21,7 +21,7 @@ class Usage
#
# validates_presence_of :title
# validates_presence_of :url
-
+
# == Class Methods
# == Various Instance Methods
@@ -1,9 +1,9 @@
require 'digest/sha1'
module DataCatalog
-
+
class User
-
+
include MongoMapper::Document
# == Attributes
@@ -19,7 +19,7 @@ class User
ensure_index :email
# == Validations
-
+
validates_presence_of :name
validates_presence_of :role
validate :validate_role
@@ -31,9 +31,9 @@ def validate_role
errors.add(:role, "must be in #{VALID_ROLES.inspect}")
end
end
-
+
# == Callbacks
-
+
before_create :assign_api_key
def assign_api_key
unless _api_key
@@ -46,9 +46,9 @@ def generate_api_key
s = "#{Time.now.to_f}#{salt}#{rand(100_000_000)}#{name}#{email}"
Digest::SHA1.hexdigest(s)
end
-
+
# == Various Instance Methods
-
+
def token
Digest::SHA1.hexdigest("#{id}/#{email}/123456789")
end
@@ -15,7 +15,7 @@ class Categories < Base
permission :delete => :curator
# == Properties
-
+
property :name
property :log
@@ -29,36 +29,36 @@ class Categories < Base
}
end
end
-
+
# == Callbacks
-
+
callback :before_create do |action|
action.params["log"] = "before_create"
end
-
+
callback :after_create do |action, category|
category.log += " after_create"
end
callback :before_update do |action, category|
action.params["log"] = "before_update"
end
-
+
callback :after_update do |action, category|
category.log += " after_update"
end
callback :before_destroy do |action, category|
action.headers 'X-Test-Callbacks' => 'before_destroy'
end
-
+
callback :after_destroy do |action, category|
x = action.response['X-Test-Callbacks']
action.headers 'X-Test-Callbacks' => "#{x} after_destroy"
end
end
-
+
Categories.build
end
@@ -14,7 +14,7 @@ class CategoriesSources < Base
:source_id => child.id
)
end
-
+
relation :delete do |parent, child|
Categorization.find(:conditions => {
:category_id => parent.id,
@@ -30,17 +30,17 @@ class CategoriesSources < Base
permission :create => :curator
permission :update => :curator
permission :delete => :curator
-
+
# == Properties
property :title
property :url
property :raw, :w => :admin
# == Callbacks
-
+
end
-
+
CategoriesSources.build
end
@@ -22,7 +22,7 @@ class Notes < Base
# == Callbacks
end
-
+
Notes.build
end
@@ -13,13 +13,13 @@ class Sources < Base
permission :create => :curator
permission :update => :curator
permission :delete => :curator
-
+
# == Properties
property :title
property :url
property :raw, :w => :admin, :hide_by_default => true
-
+
property :categories do |source|
source.categorizations.map do |categorization|
{
@@ -32,7 +32,7 @@ class Sources < Base
# == Callbacks
end
-
+
Sources.build
end
@@ -16,17 +16,17 @@ class SourcesUsages < Base
permission :create => :curator
permission :update => :curator
permission :delete => :curator
-
+
# == Properties
property :title
property :url
property :description
# == Callbacks
-
+
end
-
+
SourcesUsages.build
end
Oops, something went wrong.

0 comments on commit 73e896d

Please sign in to comment.