Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ end

APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)

if File.exists?(APP_RAKEFILE)
if File.exist?(APP_RAKEFILE)
load 'rails/tasks/engine.rake'
end

Expand Down
4 changes: 2 additions & 2 deletions core/lib/generators/refinery/cms/cms_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def append_asset_pipeline!
def append_gemfile!
if destination_path.join('Gemfile').file? &&
destination_path.join('Gemfile').read !~ %r{group :development, :test do\n.+?gem 'sqlite3'\nend}m
gsub_file 'Gemfile', %q{gem 'sqlite3'}, %q{group :development, :test do
gem 'sqlite3'
gsub_file 'Gemfile', /(gem\ ['|"]sqlite3['|"].*)$/, %q{group :development, :test do
\1
end} end
end

Expand Down
2 changes: 1 addition & 1 deletion core/lib/generators/refinery/dummy/dummy_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def module_name
def application_definition
@application_definition ||= begin
dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root)
unless options[:pretend] || !File.exists?(dummy_application_path)
unless options[:pretend] || !File.exist?(dummy_application_path)
contents = File.read(dummy_application_path)
contents[(contents.index("module #{module_name}"))..-1]
end
Expand Down
2 changes: 1 addition & 1 deletion core/lib/generators/refinery/engine/templates/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ end
ENGINE_PATH = File.dirname(__FILE__)
APP_RAKEFILE = File.expand_path "../spec/dummy/Rakefile", __FILE__

if File.exists? APP_RAKEFILE
if File.exist? APP_RAKEFILE
load 'rails/tasks/engine.rake'
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Refinery
end

def append_load_seed_data
create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
create_file 'db/seeds.rb' unless File.exist?(File.join(destination_root, 'db', 'seeds.rb'))
append_file 'db/seeds.rb', :verbose => true do
<<-EOH

Expand Down
2 changes: 1 addition & 1 deletion core/spec/lib/refinery/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
Array(spec_success_message).each do |message_fragment|
expect(msg).to include(message_fragment)
end
expect(File.exists?(Rails.root.join(copied_file_location))).to be_truthy
expect(File.exist?(Rails.root.join(copied_file_location))).to be_truthy
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion doc/guides/4 - Refinery Extensions/3 - Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Add the following lines to your extension's Rakefile
ENGINE_PATH = File.dirname(*FILE*)
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", *FILE*)

load 'rails/tasks/extension.rake' if File.exists?(APP_RAKEFILE)
load 'rails/tasks/extension.rake' if File.exist?(APP_RAKEFILE)

require "refinerycms-testing"
Refinery::Testing::Railtie.load_dummy_tasks ENGINE_PATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bundle exec puma -C config/puma.rb
```

Apply executable permission:
```
```
chmod +x bin/run.docker.sh
```

Expand All @@ -68,7 +68,7 @@ done
mkdir -p /app/shared/nginx/cache/dragonfly
```
Apply executable permission:
```
```
chmod +x run.symlinks.docker.sh
```

Expand Down Expand Up @@ -186,7 +186,7 @@ threads threads_min, threads_max
environment ENV.fetch("RAILS_ENV") { "development" }

# Executed in Docker container
if File.exists?('/.dockerenv')
if File.exist?('/.dockerenv')
app_dir = File.expand_path("../..", __FILE__)

stdout_redirect "#{app_dir}/log/puma.stdout.log", "#{app_dir}/log/puma.stderr.log", true
Expand Down Expand Up @@ -462,7 +462,7 @@ if you are going only to play with the droplet for few hours.
Install the `ufw` firewall via `apt-get install ufw` and do some initial settings:
```
ufw default deny incoming
ufw allow 22
ufw allow 22
ufw allow 5000
ufw allow 80
ufw allow 443
Expand Down Expand Up @@ -686,16 +686,16 @@ We can now delete the public allow 5433 rule in ufw:
```
To Action From
-- ------ ----
[ 1] 22 ALLOW IN Anywhere
[ 2] 5000 ALLOW IN Anywhere
[ 3] 80 ALLOW IN Anywhere
[ 4] 443 ALLOW IN Anywhere
[ 5] 5433 ALLOW IN Anywhere
[ 6] 5433 ALLOW IN 172.18.0.0/16
[ 7] 22 (v6) ALLOW IN Anywhere (v6)
[ 8] 5000 (v6) ALLOW IN Anywhere (v6)
[ 9] 80 (v6) ALLOW IN Anywhere (v6)
[10] 443 (v6) ALLOW IN Anywhere (v6)
[ 1] 22 ALLOW IN Anywhere
[ 2] 5000 ALLOW IN Anywhere
[ 3] 80 ALLOW IN Anywhere
[ 4] 443 ALLOW IN Anywhere
[ 5] 5433 ALLOW IN Anywhere
[ 6] 5433 ALLOW IN 172.18.0.0/16
[ 7] 22 (v6) ALLOW IN Anywhere (v6)
[ 8] 5000 (v6) ALLOW IN Anywhere (v6)
[ 9] 80 (v6) ALLOW IN Anywhere (v6)
[10] 443 (v6) ALLOW IN Anywhere (v6)
[11] 5433 (v6) ALLOW IN Anywhere (v6)
```
- to delete 5th and 11th rules, run `ufw delete 5` and `ufw delete 11`
Expand All @@ -705,7 +705,7 @@ use the Postgres with non-docker on `5432` and Postgres from Docker via `5433` o

Restart the docker-compose again, it should start correctly.

Now we will check, if the `5433` port is available from the public. From your local machine, run: (replace IP)
Now we will check, if the `5433` port is available from the public. From your local machine, run: (replace IP)
`nmap 46.101.99.215`

You should not see `5433` port available to public.
Expand Down
2 changes: 1 addition & 1 deletion pages/lib/generators/refinery/pages/pages_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def generate_pages_initializer
end

def append_load_seed_data
create_file "db/seeds.rb" unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
create_file "db/seeds.rb" unless File.exist?(File.join(destination_root, 'db', 'seeds.rb'))
append_file 'db/seeds.rb', :verbose => true do
<<-EOH

Expand Down
175 changes: 87 additions & 88 deletions pages/lib/refinery/pages/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,123 +57,122 @@ def translations_conditions(original_conditions)
translations_conditions
end

end
class FinderByTitle < Finder
def initialize(title)
@title = title
@conditions = default_conditions
end

class FinderByTitle < Finder
def initialize(title)
@title = title
@conditions = default_conditions
end
def default_conditions
{ :title => title }
end

def default_conditions
{ :title => title }
private
attr_accessor :title
end

private
attr_accessor :title
end
class FinderBySlug < Finder
def initialize(slug, conditions)
@slug = slug
@conditions = default_conditions.merge(conditions)
end

class FinderBySlug < Finder
def initialize(slug, conditions)
@slug = slug
@conditions = default_conditions.merge(conditions)
end
def default_conditions
{
:locale => Refinery::I18n.frontend_locales.map(&:to_s),
:slug => slug
}
end

def default_conditions
{
:locale => Refinery::I18n.frontend_locales.map(&:to_s),
:slug => slug
}
private
attr_accessor :slug
end

private
attr_accessor :slug
end

class FinderByPath
def initialize(path)
@path = path
end
class FinderByPath
def initialize(path)
@path = path
end

def find
if slugs_scoped_by_parent?
FinderByScopedPath.new(path).find
else
FinderByUnscopedPath.new(path).find
def find
if slugs_scoped_by_parent?
FinderByScopedPath.new(path).find
else
FinderByUnscopedPath.new(path).find
end
end
end

private
attr_accessor :path
private
attr_accessor :path

def slugs_scoped_by_parent?
::Refinery::Pages.scope_slug_by_parent
end
def slugs_scoped_by_parent?
::Refinery::Pages.scope_slug_by_parent
end

def by_slug(slug_path, conditions = {})
Finder.by_slug(slug_path, conditions)
def by_slug(slug_path, conditions = {})
Finder.by_slug(slug_path, conditions)
end
end
end

class FinderByScopedPath < FinderByPath
def find
# With slugs scoped to the parent page we need to find a page by its full path.
# For example with about/example we would need to find 'about' and then its child
# called 'example' otherwise it may clash with another page called /example.
page = parent_page
while page && path_segments.any? do
page = next_page(page)
class FinderByScopedPath < FinderByPath
def find
# With slugs scoped to the parent page we need to find a page by its full path.
# For example with about/example we would need to find 'about' and then its child
# called 'example' otherwise it may clash with another page called /example.
page = parent_page
while page && path_segments.any? do
page = next_page(page)
end
page
end
page
end

private
private

def path_segments
@path_segments ||= path.split('/').select(&:present?)
end
def path_segments
@path_segments ||= path.split('/').select(&:present?)
end

def parent_page
parent_page_segment = path_segments.shift
if parent_page_segment.friendly_id?
by_slug(parent_page_segment, :parent_id => nil).first
else
Page.find(parent_page_segment)
def parent_page
parent_page_segment = path_segments.shift
if parent_page_segment.friendly_id?
by_slug(parent_page_segment, :parent_id => nil).first
else
Page.find(parent_page_segment)
end
end
end

def next_page(page)
slug_or_id = path_segments.shift
page.children.by_slug(slug_or_id).first || page.children.find(slug_or_id)
def next_page(page)
slug_or_id = path_segments.shift
page.children.by_slug(slug_or_id).first || page.children.find(slug_or_id)
end
end
end

class FinderByUnscopedPath < FinderByPath
def find
by_slug(path).first
class FinderByUnscopedPath < FinderByPath
def find
by_slug(path).first
end
end
end

class FinderByPathOrId
def initialize(path, id)
@path = path
@id = id
end
class FinderByPathOrId
def initialize(path, id)
@path = path
@id = id
end

def find
if path.present?
if path.friendly_id?
FinderByPath.new(path).find
else
Page.friendly.find(path)
def find
if path.present?
if path.friendly_id?
FinderByPath.new(path).find
else
Page.friendly.find(path)
end
elsif id.present?
Page.friendly.find(id)
end
elsif id.present?
Page.friendly.find(id)
end
end

private
attr_accessor :id, :path
private
attr_accessor :id, :path
end
end
end
end
2 changes: 1 addition & 1 deletion pages/spec/support/refinery/pages/caching_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def cache_page(page)

RSpec::Matchers.define :be_cached do
match do |page|
File.exists?(cached_file_path(page))
File.exist?(cached_file_path(page))
end
end

Expand Down
2 changes: 1 addition & 1 deletion tasks/release.rake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ root = File.expand_path('../../', __FILE__)

task :clean do
package_dir = "#{root}/pkg"
mkdir_p package_dir unless File.exists?(package_dir)
mkdir_p package_dir unless File.exist?(package_dir)
rm_f gem_filename
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ guard 'spork', :wait => 60, :cucumber => false, :rspec_env => { 'RAILS_ENV' => '
end

guard 'rspec', :version => 2, :spec_paths => extensions.map{ |e| "#{e}/spec"},
:cli => (File.read('.rspec').split("\n").join(' ') if File.exists?('.rspec')) do
:cli => (File.read('.rspec').split("\n").join(' ') if File.exist?('.rspec')) do
extensions.each do |extension|
watch(%r{^#{extension}/spec/.+_spec\.rb$})
watch(%r{^#{extension}/app/(.+)\.rb$}) { |m| "#{extension}/spec/#{m[1]}_spec.rb" }
Expand Down
Loading