obscured_id 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +109 -0
  4. data/Rakefile +38 -0
  5. data/lib/generators/obscured_id/initializer_generator.rb +10 -0
  6. data/lib/generators/obscured_id/migration_generator.rb +22 -0
  7. data/lib/obscured_id/obscured_id.rb +63 -0
  8. data/lib/obscured_id/railtie.rb +26 -0
  9. data/lib/obscured_id/version.rb +3 -0
  10. data/lib/obscured_id.rb +5 -0
  11. data/lib/tasks/obscured_id.rake +18 -0
  12. data/spec/Gemfile +17 -0
  13. data/spec/Gemfile.lock +111 -0
  14. data/spec/MIT-LICENSE +20 -0
  15. data/spec/README.md +2 -0
  16. data/spec/README.rdoc +3 -0
  17. data/spec/Rakefile +38 -0
  18. data/spec/dummy/README.rdoc +261 -0
  19. data/spec/dummy/Rakefile +7 -0
  20. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  21. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  22. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  23. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  24. data/spec/dummy/app/models/thing_with_configured_obscured_id.rb +3 -0
  25. data/spec/dummy/app/models/thing_with_obscured_id.rb +3 -0
  26. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  27. data/spec/dummy/config/application.rb +59 -0
  28. data/spec/dummy/config/boot.rb +10 -0
  29. data/spec/dummy/config/database.yml +25 -0
  30. data/spec/dummy/config/environment.rb +5 -0
  31. data/spec/dummy/config/environments/development.rb +37 -0
  32. data/spec/dummy/config/environments/production.rb +67 -0
  33. data/spec/dummy/config/environments/test.rb +37 -0
  34. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/spec/dummy/config/initializers/inflections.rb +15 -0
  36. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  37. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  38. data/spec/dummy/config/initializers/session_store.rb +8 -0
  39. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  40. data/spec/dummy/config/locales/en.yml +5 -0
  41. data/spec/dummy/config/routes.rb +58 -0
  42. data/spec/dummy/config.ru +4 -0
  43. data/spec/dummy/db/development.sqlite3 +0 -0
  44. data/spec/dummy/db/migrate/20130507231624_create_thing_with_obscured_ids.rb +10 -0
  45. data/spec/dummy/db/migrate/20130507235114_create_thing_with_configured_obscured_ids.rb +8 -0
  46. data/spec/dummy/db/schema.rb +28 -0
  47. data/spec/dummy/db/test.sqlite3 +0 -0
  48. data/spec/dummy/log/development.log +270 -0
  49. data/spec/dummy/log/test.log +2279 -0
  50. data/spec/dummy/public/404.html +26 -0
  51. data/spec/dummy/public/422.html +26 -0
  52. data/spec/dummy/public/500.html +25 -0
  53. data/spec/dummy/public/favicon.ico +0 -0
  54. data/spec/dummy/script/rails +6 -0
  55. data/spec/models/thing_with_configured_obscured_id_spec.rb +31 -0
  56. data/spec/models/thing_with_obscured_id_spec.rb +72 -0
  57. data/spec/obscured_id.gemspec +23 -0
  58. data/spec/spec_helper.rb +38 -0
  59. metadata +180 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ data.tar.gz: b844e043dfcd403fc938c32fe00a303af7cc4675
4
+ metadata.gz: 949561664eb81ca9dd7602998beb39fe4ea223f8
5
+ SHA512:
6
+ data.tar.gz: 56c1c9cb003de86b46b69d0149979fd11dcaa30742c2dd02fb5a977402451a5af9b00d380c59533c1001d322e1d1bb7756d81287ffd4bad8e7f0a4149d5ecdf8
7
+ metadata.gz: 441375951f64c52885ce37168cc8dedb2bf71a0716f17e6d607c1dfb702cf82d5cc0a425521454ddbb9304dd6636782879b59e483cf9acdc0c907ff1b2969798
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # obscured_id
2
+
3
+ This gem provides a has_ helper to populate a field with an obscured version of a model id.
4
+
5
+ ## Why Obscure an ID?
6
+
7
+
8
+ ## Installing
9
+
10
+ 1. Add to your Gemfile:
11
+
12
+ gem 'obscured_id'
13
+
14
+ 1. Install the gem:
15
+
16
+ bundle install
17
+
18
+ 1. Generate the default initializer:
19
+
20
+ rails generate obscured_id:initializer
21
+
22
+ 1. Generate and run a migation for the model you wish to have an obscured id:
23
+
24
+ rails generate obscured_id:migration MODEL_NAME
25
+ rake db:migrate
26
+
27
+ 1. Add the obscured_id declaration to your model:
28
+
29
+ has_obscured_id
30
+
31
+ 1. Populate your database with the obscured id:
32
+
33
+ rake obscured_id:populate[MODEL_NAME]
34
+
35
+ ## Configuration
36
+
37
+ The following options can be configured with a Rails initializer:
38
+
39
+ - `obscured_id_secret_token`: This is the secret token used when generating the obscured id. It is strongly recommended you run the obscured_id:initializer generator to set this, otherwise the default is nil.
40
+ - `obscured_id_field`: This is the field in which you wish to store the obscured id. Default is "obscured_id"
41
+ - `record_obscured_ids`: If set to false, the obscured_id will not automatically be set. Default is true.
42
+
43
+ ## Usage
44
+
45
+ ### Generators
46
+
47
+ #### obscured_id:initializer
48
+
49
+ This creates an initializer with a random secret key for obscuring the model's id. While it is possible to run this plugin without a secret key, it's not recommended.
50
+
51
+ #### obscured_id:migration MODEL_NAME (--field=FIELD_NAME)
52
+
53
+ This creates a migration for a model with the name. The field option lets you override the default field name "obscured_id". If you override the field name, be sure to set the field option in your configuration or `has_obscured_id` declaration.
54
+
55
+ ### Rake Tasks
56
+
57
+ #### rake obscured_id:populate[MODEL_NAME]
58
+
59
+ This will populate a model with an obscured id without recording timestamps. NOTE: that this will populate your model's obscured ID field regardless of your record_obscured_ids configuration or auto option in the `has_obscured_id` declaration.
60
+
61
+ ### Has Declaration
62
+
63
+ When added to your model definition, `has_obscured_id` declaration configures your model to be obscure id capable, adding the methods described below.
64
+
65
+ The following options are available:
66
+
67
+ - `field`: This overides `obscured_id_field`.
68
+ - `secret_token`: This overides `obscured_id_secret_token`.
69
+ - `auto`: If set to false, the obscured_id will not automatically be set.
70
+
71
+ #### Examples
72
+
73
+ ```ruby
74
+ class ThingWithObscuredId < ActiveRecord::Base
75
+ has_obscured_id
76
+ end
77
+
78
+ class ThingWithConfiguredObscuredId < ActiveRecord::Base
79
+ has_obscured_id :field => :hidden_id, :secret_token => "ee71c598567e9d469738b7ec64213b8c", :auto => false
80
+ end
81
+ ```
82
+
83
+ #### Instance Methods
84
+
85
+ - `set_obscured_id`: Force sets the instance's obscured ID.
86
+ - `safe_set_obscured_id`: Sets an instance's obscured ID only if updating is turned on.
87
+
88
+ #### Class Methods
89
+
90
+ - `set_obscured_ids`: Force populates obscured ids for all records. Returns an array of integers, where the first is the count of succesful updates, and the second is the count of failed updates.
91
+
92
+ ## Notes
93
+
94
+ You can turn updating off:
95
+
96
+ ActiveRecord::Base.record_obscured_ids = false
97
+
98
+ And turn it back on:
99
+
100
+ ActiveRecord::Base.record_obscured_ids = true
101
+
102
+ ## Running Tests
103
+
104
+ $ bundle install
105
+ $ rspec spec
106
+
107
+ ## Credits
108
+
109
+ Copyright (c) 2013 Larry Halff, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ObscuredId'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test
@@ -0,0 +1,10 @@
1
+ module ObscuredId
2
+ module Generators
3
+ class InitializerGenerator < Rails::Generators::Base
4
+ desc "This generates an initializer file at config/initializers/obscured_d.rb which configures the obscured_id plugin with a random 32 character secret key."
5
+ def create_initializer_file
6
+ create_file "config/initializers/obscured_id.rb", "#{Rails.application.class.parent_name}::Application.config.obscured_id_token = '#{SecureRandom.hex(32)}'"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ module ObscuredId
2
+ module Generators
3
+ class MigrationGenerator < Rails::Generators::Base
4
+ argument :table, :type => :string, :default => "", :banner => "NAME"
5
+ class_option :field, :type => :string, :default => "obscured_id", :banner => "FIELD_NAME"
6
+
7
+ desc "This generates a migration to add the obscured id field to a table. NAME is the table or model name. " +
8
+ "The field option allows you to specify a custom field name for the obscured id. If you use a custom field name "+
9
+ "be sure to specify this in your has_obscured_id declaration."
10
+
11
+ def create_initializer_file
12
+ raise ArgumentError, "No model or table name specified." if table.empty?
13
+ Rails::Generators.invoke("migration", ["add_#{options.field}_to_#{table.classify}", "#{options.field}:string:index"])
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+
20
+
21
+
22
+
@@ -0,0 +1,63 @@
1
+ module ObscuredId
2
+ module HasObscuredId
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ class_attribute :obscured_id_secret_token, :obscured_id_field, :record_obscured_ids
7
+ end
8
+
9
+ # Specify this +has+ extension if you want to model a to have an obscured id. This requires a key
10
+ # column for the obscured id, which is <tt>obscured_id</tt> by default.
11
+ module ClassMethods
12
+
13
+ # Configuration options are:
14
+ #
15
+ # * <tt>field</tt> - specifies the column name to use for the obscured id. Default is +obscured_id+.
16
+ # * <tt>secret_token</tt> - salt for the SHA1 digest. Default is +obscured_id_secret_token+ configuration option.
17
+ # * <tt>auto</tt> - Automatically update record with obscured id after save. Default it true.
18
+ def has_obscured_id(options = {})
19
+ self.obscured_id_secret_token = options[:secret_token] || ActiveRecord::Base.obscured_id_secret_token
20
+ self.obscured_id_field = options[:field] || ActiveRecord::Base.obscured_id_field
21
+ self.record_obscured_ids = options.has_key?(:auto) ? options[:auto] : true
22
+
23
+ # Define the instance method set an obscured id for this model
24
+ define_method :set_obscured_id do
25
+ update_column( self.obscured_id_field,
26
+ OpenSSL::HMAC.hexdigest( OpenSSL::Digest.const_get(:SHA1).new,
27
+ self.obscured_id_secret_token.to_s,
28
+ "#{id}#{created_at.to_i}" ) )
29
+ end
30
+
31
+ define_method :safe_set_obscured_id do
32
+ set_obscured_id if ActiveRecord::Base.record_obscured_ids && self.record_obscured_ids
33
+ end
34
+
35
+ # Call set_obscured_id after create.
36
+ after_create :safe_set_obscured_id
37
+
38
+ # Reset all obscured ids
39
+ def self.set_obscured_ids
40
+ success = 0
41
+ fail = 0
42
+
43
+ begin
44
+ self.find_each do |record|
45
+ begin
46
+ record.set_obscured_id
47
+ success += 1
48
+ rescue
49
+ fail += 1
50
+ end
51
+ end
52
+ rescue
53
+ false
54
+ end
55
+
56
+ [success, fail]
57
+ end # set_obscure_ids
58
+
59
+ end # has_obscure_id
60
+
61
+ end # ClassMethods
62
+ end # HasObscuredId
63
+ end # ObscuredId
@@ -0,0 +1,26 @@
1
+ module ObscuredId
2
+ class Railtie < Rails::Railtie
3
+ railtie_name :obscured_id
4
+
5
+ initializer "obscured_id" do
6
+ ActiveRecord::Base.send :include, ObscuredId::HasObscuredId
7
+ set_defaults_from_configuration
8
+ end
9
+
10
+ def set_defaults_from_configuration
11
+ ActiveRecord::Base.obscured_id_secret_token = (Rails.configuration.respond_to?(:obscured_id_secret_token) ? Rails.configuration.obscured_id_secret_token : nil)
12
+ ActiveRecord::Base.obscured_id_field = (Rails.configuration.respond_to?(:obscured_id_field) ? Rails.configuration.obscured_id_field : :obscured_id)
13
+ ActiveRecord::Base.record_obscured_ids = (Rails.configuration.respond_to?(:record_obscured_ids) ? Rails.configuration.record_obscured_ids : true)
14
+ end
15
+
16
+ rake_tasks do
17
+ load "tasks/obscured_id.rake"
18
+ end
19
+
20
+ generators do
21
+ require 'generators/obscured_id/initializer_generator.rb'
22
+ require 'generators/obscured_id/migration_generator.rb'
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module ObscuredId
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'obscured_id/obscured_id'
2
+ require 'obscured_id/railtie' if defined?(Rails)
3
+
4
+ module ObscuredId
5
+ end
@@ -0,0 +1,18 @@
1
+ # desc "Explaining what the task does"
2
+ namespace :obscured_id do
3
+ desc "Update table with obscured ids"
4
+ task :populate, [:class_name] => :environment do |t, args|
5
+ klass = args[:class_name].classify.constantize
6
+
7
+ if klass.respond_to?(:set_obscured_ids)
8
+ ActiveRecord::Base.record_timestamps = false
9
+ success, fail = klass.set_obscured_ids
10
+ ActiveRecord::Base.record_timestamps = true
11
+ puts "#{success} #{'record'.pluralize(success)} succesfully updated. #{fail} #{'updates'.pluralize(fail)} failed."
12
+ else
13
+ puts "#{klass.name} does not appear to be has_obscured_id capable.\n\n"
14
+ end
15
+
16
+ STDOUT.flush
17
+ end
18
+ end
data/spec/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in obscured_id.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # jquery-rails is used by the dummy application
9
+ # gem "jquery-rails"
10
+
11
+ # Declare any dependencies that are still in development here instead of in
12
+ # your gemspec. These might include edge Rails or gems from your path or
13
+ # Git. Remember to move these dependencies to your gemspec before releasing
14
+ # your gem to rubygems.org.
15
+
16
+ # To use debugger
17
+ # gem 'ruby-debug'
data/spec/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ obscured_id (0.0.1)
5
+ rails (~> 3.2.13)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.13)
11
+ actionpack (= 3.2.13)
12
+ mail (~> 2.5.3)
13
+ actionpack (3.2.13)
14
+ activemodel (= 3.2.13)
15
+ activesupport (= 3.2.13)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.5)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.13)
24
+ activesupport (= 3.2.13)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.13)
27
+ activemodel (= 3.2.13)
28
+ activesupport (= 3.2.13)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.13)
32
+ activemodel (= 3.2.13)
33
+ activesupport (= 3.2.13)
34
+ activesupport (3.2.13)
35
+ i18n (= 0.6.1)
36
+ multi_json (~> 1.0)
37
+ arel (3.0.2)
38
+ builder (3.0.4)
39
+ diff-lcs (1.2.4)
40
+ erubis (2.7.0)
41
+ hike (1.2.2)
42
+ i18n (0.6.1)
43
+ journey (1.0.4)
44
+ jquery-rails (2.2.1)
45
+ railties (>= 3.0, < 5.0)
46
+ thor (>= 0.14, < 2.0)
47
+ json (1.7.7)
48
+ mail (2.5.3)
49
+ i18n (>= 0.4.0)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ mime-types (1.23)
53
+ multi_json (1.7.3)
54
+ polyglot (0.3.3)
55
+ rack (1.4.5)
56
+ rack-cache (1.2)
57
+ rack (>= 0.4)
58
+ rack-ssl (1.3.3)
59
+ rack
60
+ rack-test (0.6.2)
61
+ rack (>= 1.0)
62
+ rails (3.2.13)
63
+ actionmailer (= 3.2.13)
64
+ actionpack (= 3.2.13)
65
+ activerecord (= 3.2.13)
66
+ activeresource (= 3.2.13)
67
+ activesupport (= 3.2.13)
68
+ bundler (~> 1.0)
69
+ railties (= 3.2.13)
70
+ railties (3.2.13)
71
+ actionpack (= 3.2.13)
72
+ activesupport (= 3.2.13)
73
+ rack-ssl (~> 1.3.2)
74
+ rake (>= 0.8.7)
75
+ rdoc (~> 3.4)
76
+ thor (>= 0.14.6, < 2.0)
77
+ rake (10.0.4)
78
+ rdoc (3.12.2)
79
+ json (~> 1.4)
80
+ rspec-core (2.13.1)
81
+ rspec-expectations (2.13.0)
82
+ diff-lcs (>= 1.1.3, < 2.0)
83
+ rspec-mocks (2.13.1)
84
+ rspec-rails (2.13.1)
85
+ actionpack (>= 3.0)
86
+ activesupport (>= 3.0)
87
+ railties (>= 3.0)
88
+ rspec-core (~> 2.13.0)
89
+ rspec-expectations (~> 2.13.0)
90
+ rspec-mocks (~> 2.13.0)
91
+ sprockets (2.2.2)
92
+ hike (~> 1.2)
93
+ multi_json (~> 1.0)
94
+ rack (~> 1.0)
95
+ tilt (~> 1.1, != 1.3.0)
96
+ sqlite3 (1.3.7)
97
+ thor (0.18.1)
98
+ tilt (1.4.0)
99
+ treetop (1.4.12)
100
+ polyglot
101
+ polyglot (>= 0.3.1)
102
+ tzinfo (0.3.37)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ jquery-rails
109
+ obscured_id!
110
+ rspec-rails
111
+ sqlite3
data/spec/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/spec/README.md ADDED
@@ -0,0 +1,2 @@
1
+ obscured_id
2
+ ===========
data/spec/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = ObscuredId
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/spec/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ObscuredId'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test