Skip to content
This repository

rename public_folder to public_dir #427

Closed
wants to merge 1 commit into from

3 participants

Gabriel Andretta Konstantin Haase Zachary Scott
Gabriel Andretta

No description provided.

Zachary Scott zzak commented on the diff
lib/sinatra/base.rb
@@ -1112,8 +1112,13 @@ def condition(name = "#{caller.first[/`.*'/]} condition", &block)
1112 1112 end
1113 1113
1114 1114 def public=(value)
1115   - warn ":public is no longer used to avoid overloading Module#public, use :public_folder instead"
1116   - set(:public_folder, value)
  1115 + warn ":public is no longer used to avoid overloading Module#public, use :public_dir instead"
3
Zachary Scott Collaborator
zzak added a note

Should there be a similar warning for public_folder too then?

@zzak Do you mean like the one that it's a few lines below? (from lines 1119 to 1122)

Zachary Scott Collaborator
zzak added a note

Hahahaha, yup! Must have missed that..

Good look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Konstantin Haase
Owner
rkh commented

OK, I will except this if public_folder is a valid alias (i.e. both getter and setter, no warning), otherwise this will be to annoying for people that already switched.

Gabriel Andretta gnandretta referenced this pull request
Merged

public_dir alias #481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 10, 2011
Gabriel Andretta gnandretta rename public_folder to public_dir e6824ee
This page is out of date. Refresh to see the latest.
8 README.de.rdoc
Source Rendered
@@ -244,9 +244,9 @@ Oder unter Verwendung eines negativen look ahead:
244 244
245 245 Statische Dateien werden aus dem <tt>./public</tt>-Ordner ausgeliefert. Es ist
246 246 möglich, einen anderen Ort zu definieren, indem man die
247   -<tt>:public_folder</tt>-Option setzt:
  247 +<tt>:public_dir</tt>-Option setzt:
248 248
249   - set :public_folder, File.dirname(__FILE__) + '/static'
  249 + set :public_dir, File.dirname(__FILE__) + '/static'
250 250
251 251 Zu beachten ist, dass der Ordnername public nicht Teil der URL ist. Die Datei
252 252 <tt>./public/css/style.css</tt> ist unter
@@ -1299,8 +1299,8 @@ Schutzmechanismen zu deaktivieren:
1299 1299 wird oder nicht. Weitere Informationen im vorhergehenden
1300 1300 Abschnitt.
1301 1301
1302   -[public_folder] Das öffentliche Verzeichnis, aus dem Daten zur
1303   - Verfügung gestellt werden können.
  1302 +[public_dir] Das öffentliche Verzeichnis, aus dem Daten zur Verfügung
  1303 + gestellt werden können.
1304 1304
1305 1305 [reload_templates] Im development-Modus aktiviert.
1306 1306
6 README.es.rdoc
Source Rendered
@@ -240,9 +240,9 @@ O, usando un lookahead negativo:
240 240
241 241 Los archivos estáticos son servidos desde el directorio público
242 242 <tt>./public</tt>. Podés especificar una ubicación diferente ajustando la
243   -opción <tt>:public_folder</tt>:
  243 +opción <tt>:public_dir</tt>:
244 244
245   - set :public_folder, File.dirname(__FILE__) + '/estaticos'
  245 + set :public_dir, File.dirname(__FILE__) + '/estaticos'
246 246
247 247 Notá que el nombre del directorio público no está incluido en la URL. Por
248 248 ejemplo, el archivo <tt>./public/css/style.css</tt> se accede a través de
@@ -1387,7 +1387,7 @@ O varias:
1387 1387 sección sobre la configuración de protección de ataques
1388 1388 más arriba.
1389 1389
1390   -[public_folder] path del directorio desde donde se sirven los archivos
  1390 +[public_dir] path del directorio desde donde se sirven los archivos
1391 1391 públicos. Solo se utiliza cuando se sirven archivos
1392 1392 estáticos (ver la opción <tt>static</tt>). Si no
1393 1393 está presente, se infiere del valor de la opción
6 README.fr.rdoc
Source Rendered
@@ -245,9 +245,9 @@ Ou bien en utilisant la forme négative :
245 245
246 246 Les fichiers du dossier <tt>./public</tt> sont servis de façon statique. Vous
247 247 avez la possibilité d'utiliser un autre répertoire en définissant le paramètre
248   -<tt>:public_folder</tt> :
  248 +<tt>:public_dir</tt> :
249 249
250   - set :public_folder, File.dirname(__FILE__) + '/statique'
  250 + set :public_dir, File.dirname(__FILE__) + '/statique'
251 251
252 252 Notez que le nom du dossier public n'apparait pas dans l'URL. Le fichier
253 253 <tt>./public/css/style.css</tt> sera appelé via l'URL :
@@ -1365,7 +1365,7 @@ Vous pouvez accéder à ces paramètres via <tt>settings</tt> :
1365 1365 comportera comme <tt>redirect to('/foo')</tt>.
1366 1366 Désactivé par défaut.
1367 1367
1368   -[public_folder] dossier duquel les fichiers publics sont servis
  1368 +[public_dir] dossier duquel les fichiers publics sont servis
1369 1369
1370 1370 [reload_templates] si oui ou non les templates doivent être rechargés
1371 1371 entre les requêtes. Activé en mode développement.
4 README.hu.rdoc
Source Rendered
@@ -99,9 +99,9 @@ tervezhetők, így például az user agent karakterláncot alapul véve:
99 99
100 100 A statikus fájlok kiszolgálása a <tt>./public</tt> könyvtárból
101 101 történik, de természetesen más könyvtárat is megadhatsz erre a célra,
102   -mégpedig a <tt>:public_folder</tt> kapcsoló beállításával:
  102 +mégpedig a <tt>:public_dir</tt> kapcsoló beállításával:
103 103
104   - set :public_folder, File.dirname(__FILE__) + '/static'
  104 + set :public_dir, File.dirname(__FILE__) + '/static'
105 105
106 106 Fontos mgejegyezni, hogy a nyilvános könyvtár neve nem szerepel az URL-ben.
107 107 A <tt>./public/css/style.css</tt> fájl az
4 README.jp.rdoc
Source Rendered
@@ -153,9 +153,9 @@ Rackレスポンス、Rackボディオブジェクト、HTTPステータスコ
153 153 == 静的ファイル
154 154
155 155 静的ファイルは<tt>./public</tt>ディレクトリから配信されます。
156   -<tt>:public_folder</tt>オプションを指定することで別の場所を指定することができます。
  156 +<tt>:public_dir</tt>オプションを指定することで別の場所を指定することができます。
157 157
158   - set :public_folder, File.dirname(__FILE__) + '/static'
  158 + set :public_dir, File.dirname(__FILE__) + '/static'
159 159
160 160 注意: この静的ファイル用のディレクトリ名はURL中に含まれません。
161 161 例えば、<tt>./public/css/style.css</tt>は<tt>http://example.com/css/style.css</tt>でアクセスできます。
4 README.pt-br.rdoc
Source Rendered
@@ -95,9 +95,9 @@ Rotas podem incluir uma variedade de condições correspondes, tal como o agente
95 95 == Arquivos estáticos
96 96
97 97 Arquivos estáticos são disponibilizados a partir do diretório <tt>./public</tt>. Você pode especificar
98   -um local diferente pela opção <tt>:public_folder</tt>
  98 +um local diferente pela opção <tt>:public_dir</tt>
99 99
100   - set :public_folder, File.dirname(__FILE__) + '/estatico'
  100 + set :public_dir, File.dirname(__FILE__) + '/estatico'
101 101
102 102 Note que o nome do diretório público não é incluido na URL. Um arquivo
103 103 <tt>./public/css/style.css</tt> é disponibilizado como
4 README.pt-pt.rdoc
Source Rendered
@@ -95,9 +95,9 @@ Rotas podem incluir uma variedade de condições correspondentes, por exemplo, o
95 95 == Arquivos estáticos
96 96
97 97 Arquivos estáticos são disponibilizados a partir do directório <tt>./public</tt>. Você pode especificar
98   -um local diferente através da opção <tt>:public_folder</tt>
  98 +um local diferente através da opção <tt>:public_dir</tt>
99 99
100   - set :public_folder, File.dirname(__FILE__) + '/estatico'
  100 + set :public_dir, File.dirname(__FILE__) + '/estatico'
101 101
102 102 Note que o nome do directório público não é incluido no URL. Um arquivo
103 103 <tt>./public/css/style.css</tt> é disponibilizado como
6 README.rdoc
Source Rendered
@@ -238,9 +238,9 @@ Or, using negative look ahead:
238 238 == Static Files
239 239
240 240 Static files are served from the <tt>./public</tt> directory. You can specify
241   -a different location by setting the <tt>:public_folder</tt> option:
  241 +a different location by setting the <tt>:public_dir</tt> option:
242 242
243   - set :public_folder, File.dirname(__FILE__) + '/static'
  243 + set :public_dir, File.dirname(__FILE__) + '/static'
244 244
245 245 Note that the public directory name is not included in the URL. A file
246 246 <tt>./public/css/style.css</tt> is made available as
@@ -1335,7 +1335,7 @@ You can also hand in an array in order to disable a list of protections:
1335 1335 [protection] Whether or not to enable web attack protections. See
1336 1336 protection section above.
1337 1337
1338   -[public_folder] Path to the folder public files are served from. Only
  1338 +[public_dir] Path to the folder public files are served from. Only
1339 1339 used if static file serving is enabled (see
1340 1340 <tt>static</tt> setting below). Inferred from
1341 1341 <tt>app_file</tt> setting if not set.
6 README.ru.rdoc
Source Rendered
@@ -206,9 +206,9 @@ Thin - это более производительный и функциона
206 206 == Статические файлы
207 207
208 208 Статические файлы отдаются из <tt>./public</tt> директории. Вы можете указать другое место,
209   -указав его через опцию <tt>:public_folder</tt>:
  209 +указав его через опцию <tt>:public_dir</tt>:
210 210
211   - set :public_folder, File.dirname(__FILE__) + '/static'
  211 + set :public_dir, File.dirname(__FILE__) + '/static'
212 212
213 213 Учтите, что имя директории со статическими файлами не включено в URL. Например, файл
214 214 <tt>./public/css/style.css</tt> будет доступен как
@@ -1182,7 +1182,7 @@ Thin - это более производительный и функциона
1182 1182 если не задан абсолютный путь. Таким образом, <tt>redirect '/foo'</tt>
1183 1183 будет вести себя как <tt>redirect to('/foo')</tt>. Отключено по умолчанию.
1184 1184
1185   -[public_folder] директория, откуда будут раздаваться статические файлы.
  1185 +[public_dir] директория, откуда будут раздаваться статические файлы.
1186 1186
1187 1187 [reload_templates] перезагружать или нет шаблоны на каждый запрос.
1188 1188 Включено в режиме разработки.
6 README.zh.rdoc
Source Rendered
@@ -194,10 +194,10 @@ Rack body对象或者HTTP状态码:
194 194
195 195 == 静态文件
196 196
197   -静态文件是从 <tt>./public_folder</tt> 目录提供服务。你可以通过设置<tt>:public</tt>
  197 +静态文件是从 <tt>./public_dir</tt> 目录提供服务。你可以通过设置<tt>:public</tt>
198 198 选项设定一个不同的位置:
199 199
200   - set :public_folder, File.dirname(__FILE__) + '/static'
  200 + set :public_dir, File.dirname(__FILE__) + '/static'
201 201
202 202 请注意public目录名并没有被包含在URL之中。文件
203 203 <tt>./public/css/style.css</tt>是通过
@@ -1269,7 +1269,7 @@ Sinatra会自动处理range请求。
1269 1269 <tt>redirect '/foo'</tt> 会和
1270 1270 <tt>redirect to('/foo')</tt>起相同作用。默认禁用。
1271 1271
1272   -[public_folder] public文件夹的位置。
  1272 +[public_dir] public文件夹的位置。
1273 1273
1274 1274 [reload_templates] 是否每个请求都重新载入模板。
1275 1275 在development mode和 Ruby 1.8.6 中被企业(用来
15 lib/sinatra/base.rb
@@ -831,7 +831,7 @@ def route_missing
831 831 # Attempt to serve static files from public directory. Throws :halt when
832 832 # a matching file is found, returns nil otherwise.
833 833 def static!
834   - return if (public_dir = settings.public_folder).nil?
  834 + return if (public_dir = settings.public_dir).nil?
835 835 public_dir = File.expand_path(public_dir)
836 836
837 837 path = File.expand_path(public_dir + unescape(request.path_info))
@@ -1112,8 +1112,13 @@ def condition(name = "#{caller.first[/`.*'/]} condition", &block)
1112 1112 end
1113 1113
1114 1114 def public=(value)
1115   - warn ":public is no longer used to avoid overloading Module#public, use :public_folder instead"
1116   - set(:public_folder, value)
  1115 + warn ":public is no longer used to avoid overloading Module#public, use :public_dir instead"
  1116 + set(:public_dir, value)
  1117 + end
  1118 +
  1119 + def public_folder=(value)
  1120 + warn ":public_folder has been renamed to :public_dir"
  1121 + set(:public_dir, value)
1117 1122 end
1118 1123
1119 1124 private
@@ -1516,8 +1521,8 @@ class << self
1516 1521 set :lock, false
1517 1522 set :threaded, true
1518 1523
1519   - set :public_folder, Proc.new { root && File.join(root, 'public') }
1520   - set :static, Proc.new { public_folder && File.exist?(public_folder) }
  1524 + set :public_dir, Proc.new { root && File.join(root, 'public') }
  1525 + set :static, Proc.new { public_dir && File.exist?(public_dir) }
1521 1526 set :static_cache_control, false
1522 1527
1523 1528 error ::Exception do
4 test/filter_test.rb
@@ -125,7 +125,7 @@ class BeforeFilterTest < Test::Unit::TestCase
125 125 mock_app {
126 126 before { ran_filter = true }
127 127 set :static, true
128   - set :public_folder, File.dirname(__FILE__)
  128 + set :public_dir, File.dirname(__FILE__)
129 129 }
130 130 get "/#{File.basename(__FILE__)}"
131 131 assert ok?
@@ -248,7 +248,7 @@ class AfterFilterTest < Test::Unit::TestCase
248 248 mock_app {
249 249 after { ran_filter = true }
250 250 set :static, true
251   - set :public_folder, File.dirname(__FILE__)
  251 + set :public_dir, File.dirname(__FILE__)
252 252 }
253 253 get "/#{File.basename(__FILE__)}"
254 254 assert ok?
22 test/settings_test.rb
@@ -359,13 +359,13 @@ def foo=(value)
359 359 assert ! @base.static?
360 360 end
361 361
362   - it 'is enabled on Base when public_folder is set and exists' do
  362 + it 'is enabled on Base when public_dir is set and exists' do
363 363 @base.set :environment, :development
364   - @base.set :public_folder, File.dirname(__FILE__)
  364 + @base.set :public_dir, File.dirname(__FILE__)
365 365 assert @base.static?
366 366 end
367 367
368   - it 'is enabled on Base when root is set and root/public_folder exists' do
  368 + it 'is enabled on Base when root is set and root/public_dir exists' do
369 369 @base.set :environment, :development
370 370 @base.set :root, File.dirname(__FILE__)
371 371 assert @base.static?
@@ -375,13 +375,13 @@ def foo=(value)
375 375 assert ! @application.static?
376 376 end
377 377
378   - it 'is enabled on Application when public_folder is set and exists' do
  378 + it 'is enabled on Application when public_dir is set and exists' do
379 379 @application.set :environment, :development
380   - @application.set :public_folder, File.dirname(__FILE__)
  380 + @application.set :public_dir, File.dirname(__FILE__)
381 381 assert @application.static?
382 382 end
383 383
384   - it 'is enabled on Application when root is set and root/public_folder exists' do
  384 + it 'is enabled on Application when root is set and root/public_dir exists' do
385 385 @application.set :environment, :development
386 386 @application.set :root, File.dirname(__FILE__)
387 387 assert @application.static?
@@ -469,18 +469,18 @@ def pub; end
469 469 end
470 470 end
471 471
472   - describe 'public_folder' do
  472 + describe 'public_dir' do
473 473 it 'is nil if root is not set' do
474   - assert @base.public_folder.nil?
475   - assert @application.public_folder.nil?
  474 + assert @base.public_dir.nil?
  475 + assert @application.public_dir.nil?
476 476 end
477 477
478 478 it 'is set to root joined with public/' do
479 479 @base.root = File.dirname(__FILE__)
480   - assert_equal File.dirname(__FILE__) + "/public", @base.public_folder
  480 + assert_equal File.dirname(__FILE__) + "/public", @base.public_dir
481 481
482 482 @application.root = File.dirname(__FILE__)
483   - assert_equal File.dirname(__FILE__) + "/public", @application.public_folder
  483 + assert_equal File.dirname(__FILE__) + "/public", @application.public_dir
484 484 end
485 485 end
486 486
6 test/static_test.rb
@@ -4,7 +4,7 @@ class StaticTest < Test::Unit::TestCase
4 4 setup do
5 5 mock_app {
6 6 set :static, true
7   - set :public_folder, File.dirname(__FILE__)
  7 + set :public_dir, File.dirname(__FILE__)
8 8 }
9 9 end
10 10
@@ -66,7 +66,7 @@ class StaticTest < Test::Unit::TestCase
66 66 end
67 67
68 68 it 'passes to the next handler when the public option is nil' do
69   - @app.set :public_folder, nil
  69 + @app.set :public_dir, nil
70 70 get "/#{File.basename(__FILE__)}"
71 71 assert not_found?
72 72 end
@@ -85,7 +85,7 @@ class StaticTest < Test::Unit::TestCase
85 85 it '404s when .. path traverses outside of public directory' do
86 86 mock_app {
87 87 set :static, true
88   - set :public_folder, File.dirname(__FILE__) + '/data'
  88 + set :public_dir, File.dirname(__FILE__) + '/data'
89 89 }
90 90 get "/../#{File.basename(__FILE__)}"
91 91 assert not_found?

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.