christiank-sinatra-entries-visible 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sinatra/entries_visible.rb +33 -0
- metadata +55 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
module Sinatra
|
4
|
+
module EntriesVisibleHelper
|
5
|
+
|
6
|
+
# Returns an array of only the visible contents of a directory. Ignores .,
|
7
|
+
# .., .DS_Store, .git, or dot-whatever.
|
8
|
+
#
|
9
|
+
# require 'sinatra'
|
10
|
+
# require 'sinatra/entries_visible'
|
11
|
+
#
|
12
|
+
# get '/' do
|
13
|
+
# @photos_dir = options.public + '/photos'
|
14
|
+
# erb :index
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# __END__
|
18
|
+
#
|
19
|
+
# @@index
|
20
|
+
# <h1>My photos!</h1>
|
21
|
+
# <% Dir.entries_visible(@photos_dir).each do |photo| %>
|
22
|
+
# <img src="photos/<%= photo %>">
|
23
|
+
# <% end %>
|
24
|
+
class Dir
|
25
|
+
def Dir.entries_visible dir
|
26
|
+
Dir.entries(dir).delete_if { |entry| entry[0, 1] == '.' }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
helpers EntriesVisibleHelper
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: christiank-sinatra-entries-visible
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Koch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-31 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: ckoch002@student.ucr.edu
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/sinatra
|
26
|
+
- lib/sinatra/entries_visible.rb
|
27
|
+
has_rdoc: false
|
28
|
+
homepage: http://github.com/christiank/sinatra-entries-visible
|
29
|
+
licenses:
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
version:
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.3.5
|
51
|
+
signing_key:
|
52
|
+
specification_version: 2
|
53
|
+
summary: A Sinatra extension which returns only the visible contents of a directory
|
54
|
+
test_files: []
|
55
|
+
|