openstax_utilities 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
- = OpenstaxUtilities
1
+ OpenstaxUtilities
2
+ =================
2
3
 
3
- This project rocks and uses MIT-LICENSE.
4
+ A set of common utilities for the various OpenStax projects.
5
+
6
+ Documentation available on [rdoc.info](http://rdoc.info/github/openstax/openstax_utilities/master/frames).
@@ -0,0 +1,45 @@
1
+
2
+ ActionController::Base.define_singleton_method(:protect_beta) do |options={}|
3
+ options[:username] ||= SecureRandom.hex
4
+ options[:password] ||= SecureRandom.hex
5
+ options[:enable_always] ||= false
6
+ options[:message] ||= ''
7
+
8
+ return if !(options[:enable_always] || Rails.env.production?)
9
+
10
+ prepend_before_filter do
11
+ authenticate_or_request_with_http_basic(options[:message]) do |username, password|
12
+ username == options[:username] && password == options[:password]
13
+ end
14
+ end
15
+ end
16
+
17
+ module OpenStax
18
+ module Utilities
19
+ module Access
20
+
21
+ # Called in a controller to provide an outer level of basic HTTP
22
+ # authentication, typically used when code is deployed during development
23
+ # and it is not yet ready for public consumption.
24
+ #
25
+ # Example:
26
+ #
27
+ # class ApplicationController < ActionController::Base
28
+ # protect_beta :username => 'bob',
29
+ # :password => '123'
30
+ #
31
+ # @param :username The authentication username; default value is a random hex string
32
+ # @param :password The authentication password; default value is a random hex string
33
+ # @param :enable_always The default is the authentication is only enabled
34
+ # in production, setting this to true will make it effective in all
35
+ # environments
36
+ # @param :message If given, this message will be displayed in the browser's
37
+ # authentication dialog box.
38
+ #
39
+ def self.protect_beta(options={})
40
+ # Just here for documentation purposes, see code above
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,8 @@
1
+ module OpenStax
2
+ module Utilities
3
+ module Development
4
+
5
+
6
+ end
7
+ end
8
+ end
@@ -1,4 +1,4 @@
1
- module Openstax
1
+ module OpenStax
2
2
  module Utilities
3
3
  class Engine < ::Rails::Engine
4
4
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module OpenStax
3
3
  module Utilities
4
- module File
4
+ module Settings
5
5
 
6
6
  # Reads and returns a hash of YAML settings from a file
7
7
  # @param calling_file This should always be __FILE__
@@ -10,7 +10,7 @@ module OpenStax
10
10
  # this method to look up one directory from the directory of calling_file
11
11
  # @param filename the plain filename, e.g. 'foobar.yml'
12
12
  #
13
- def load_settings(calling_file, relative_directory, filename)
13
+ def self.load_settings(calling_file, relative_directory, filename)
14
14
  settings = {}
15
15
 
16
16
  filename = File.join(File.dirname(calling_file), '..', 'developer_settings.yml')
@@ -1,5 +1,5 @@
1
1
  module Openstax
2
2
  module Utilities
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
1
  require "openstax/utilities/engine"
2
2
  require "openstax/utilities/version"
3
- require "openstax/utilities/file"
3
+ require "openstax/utilities/settings"
4
+ require "openstax/utilities/access"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,8 +18,10 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - lib/openstax/utilities/access.rb
22
+ - lib/openstax/utilities/development.rb
21
23
  - lib/openstax/utilities/engine.rb
22
- - lib/openstax/utilities/file.rb
24
+ - lib/openstax/utilities/settings.rb
23
25
  - lib/openstax/utilities/version.rb
24
26
  - lib/openstax_utilities.rb
25
27
  - MIT-LICENSE