Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
DataPaths is a library to manage the paths to data/ directories within projects.
Ruby
Tag: 0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
History.rdoc
Manifest.txt
README.rdoc
Rakefile

README.rdoc

static_paths

DESCRIPTION:

StaticPaths is a library to manage the paths of directories containing static-content within multiple projects.

For example, StaticPaths can manage the static/ directories of multiple RubyGems, in much the same way RubyGems manages the paths of lib/ directories using $LOAD_PATH.

FEATURES:

  • Allows libraries to register static-content directories using the register_static_dir class or instance method.

  • Allows libraries to unregister a single path using unregister_static_dir or all paths registered by that library with unregister_static_dirs.

  • Provides helper methods in {StaticPaths::Finders} for searching through the registered static-content directories.

  • Does not use global variables.

EXAMPLES:

  • Register a directory containing static-content:

    require 'static_paths'
    
    module MyLibrary
      include StaticPaths
    
      # define the static dir(s)
      register_static_dir File.join(File.dirname(__FILE__),'..','..','static')
    end
  • List previously registered static-content directories:

    # all static directories
    StaticPaths.paths
    # => #<Set: {...}>
    
    # the static directories registeed in MyLibrary
    MyLibrary.static_paths
    # => #<Set: {...}>
    
    # list static directories registered in an object
    lib = MyLibrary.new
    lib.register_static_dir File.join('path','to','static')
    
    lib.static_paths
    # => #<Set: {...}>
  • Using {StaticPaths::Finders} to access content from within the static-content directories:

    module MyLibrary
      class UsesContent
    
        include StaticPaths::Finders
    
        def index
          find_static_file('index.html')
        end
    
        def file_dirs
          all_static_dirs('extra')
        end
    
      end
    end

INSTALL:

$ sudo gem install static_paths

LICENSE:

(The MIT License)

Copyright © 2010 Hal Brodigan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.