wor 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/Gemfile.lock +127 -0
- data/lib/wor/collection.rb +22 -0
- data/lib/wor/collection_item.rb +125 -0
- data/lib/wor.rb +3 -2
- data/log/test.log +0 -0
- data/spec/rails_app/Rakefile +6 -0
- data/spec/rails_app/config/application.rb +41 -0
- data/spec/rails_app/config/boot.rb +20 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +30 -0
- data/spec/rails_app/config/environments/production.rb +86 -0
- data/spec/rails_app/config/environments/test.rb +45 -0
- data/spec/rails_app/config/locales/wor.en.yml +2 -0
- data/spec/rails_app/config/locales/wor.pt.yml +2 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/content/courses/curso-teste.md +5 -0
- data/spec/rails_app/content/pages/index.md +7 -0
- data/spec/rails_app/log/test.log +0 -0
- data/spec/test_helper.rb +4 -0
- data/spec/wor_spec.rb +56 -0
- data/wor.gemspec +14 -0
- metadata +22 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c6c0153991d04b7e5455702cbe0791b867d7e70
|
4
|
+
data.tar.gz: cb25136401a2339342fbda30215edca734143fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2257badb3676c73687323a5f1221f4aafff0caa9f25532dffe4ee06ad983a807cf696163c2def7b362af92c58ec55f20eba17c24dbc41a8dfa9aac59c937395
|
7
|
+
data.tar.gz: 163588ab97a54f854507af0a7042792b313238206c02d708f419fd77d5ec7759b3f7acc228242ac44fc70040bcb1b1f804d2cb38b79b5d853d82913aee82e9c7
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wor (0.0.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actioncable (5.1.0)
|
10
|
+
actionpack (= 5.1.0)
|
11
|
+
nio4r (~> 2.0)
|
12
|
+
websocket-driver (~> 0.6.1)
|
13
|
+
actionmailer (5.1.0)
|
14
|
+
actionpack (= 5.1.0)
|
15
|
+
actionview (= 5.1.0)
|
16
|
+
activejob (= 5.1.0)
|
17
|
+
mail (~> 2.5, >= 2.5.4)
|
18
|
+
rails-dom-testing (~> 2.0)
|
19
|
+
actionpack (5.1.0)
|
20
|
+
actionview (= 5.1.0)
|
21
|
+
activesupport (= 5.1.0)
|
22
|
+
rack (~> 2.0)
|
23
|
+
rack-test (~> 0.6.3)
|
24
|
+
rails-dom-testing (~> 2.0)
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
26
|
+
actionview (5.1.0)
|
27
|
+
activesupport (= 5.1.0)
|
28
|
+
builder (~> 3.1)
|
29
|
+
erubi (~> 1.4)
|
30
|
+
rails-dom-testing (~> 2.0)
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
32
|
+
activejob (5.1.0)
|
33
|
+
activesupport (= 5.1.0)
|
34
|
+
globalid (>= 0.3.6)
|
35
|
+
activemodel (5.1.0)
|
36
|
+
activesupport (= 5.1.0)
|
37
|
+
activerecord (5.1.0)
|
38
|
+
activemodel (= 5.1.0)
|
39
|
+
activesupport (= 5.1.0)
|
40
|
+
arel (~> 8.0)
|
41
|
+
activesupport (5.1.0)
|
42
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
43
|
+
i18n (~> 0.7)
|
44
|
+
minitest (~> 5.1)
|
45
|
+
tzinfo (~> 1.1)
|
46
|
+
arel (8.0.0)
|
47
|
+
builder (3.2.3)
|
48
|
+
concurrent-ruby (1.0.5)
|
49
|
+
diff-lcs (1.3)
|
50
|
+
erubi (1.6.0)
|
51
|
+
globalid (0.4.0)
|
52
|
+
activesupport (>= 4.2.0)
|
53
|
+
i18n (0.8.1)
|
54
|
+
loofah (2.0.3)
|
55
|
+
nokogiri (>= 1.5.9)
|
56
|
+
mail (2.6.5)
|
57
|
+
mime-types (>= 1.16, < 4)
|
58
|
+
method_source (0.8.2)
|
59
|
+
mime-types (3.1)
|
60
|
+
mime-types-data (~> 3.2015)
|
61
|
+
mime-types-data (3.2016.0521)
|
62
|
+
mini_portile2 (2.1.0)
|
63
|
+
minitest (5.10.1)
|
64
|
+
nio4r (2.0.0)
|
65
|
+
nokogiri (1.7.1)
|
66
|
+
mini_portile2 (~> 2.1.0)
|
67
|
+
rack (2.0.1)
|
68
|
+
rack-test (0.6.3)
|
69
|
+
rack (>= 1.0)
|
70
|
+
rails (5.1.0)
|
71
|
+
actioncable (= 5.1.0)
|
72
|
+
actionmailer (= 5.1.0)
|
73
|
+
actionpack (= 5.1.0)
|
74
|
+
actionview (= 5.1.0)
|
75
|
+
activejob (= 5.1.0)
|
76
|
+
activemodel (= 5.1.0)
|
77
|
+
activerecord (= 5.1.0)
|
78
|
+
activesupport (= 5.1.0)
|
79
|
+
bundler (>= 1.3.0, < 2.0)
|
80
|
+
railties (= 5.1.0)
|
81
|
+
sprockets-rails (>= 2.0.0)
|
82
|
+
rails-dom-testing (2.0.2)
|
83
|
+
activesupport (>= 4.2.0, < 6.0)
|
84
|
+
nokogiri (~> 1.6)
|
85
|
+
rails-html-sanitizer (1.0.3)
|
86
|
+
loofah (~> 2.0)
|
87
|
+
railties (5.1.0)
|
88
|
+
actionpack (= 5.1.0)
|
89
|
+
activesupport (= 5.1.0)
|
90
|
+
method_source
|
91
|
+
rake (>= 0.8.7)
|
92
|
+
thor (>= 0.18.1, < 2.0)
|
93
|
+
rake (12.0.0)
|
94
|
+
rspec (2.99.0)
|
95
|
+
rspec-core (~> 2.99.0)
|
96
|
+
rspec-expectations (~> 2.99.0)
|
97
|
+
rspec-mocks (~> 2.99.0)
|
98
|
+
rspec-core (2.99.2)
|
99
|
+
rspec-expectations (2.99.2)
|
100
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
101
|
+
rspec-mocks (2.99.4)
|
102
|
+
sprockets (3.7.1)
|
103
|
+
concurrent-ruby (~> 1.0)
|
104
|
+
rack (> 1, < 3)
|
105
|
+
sprockets-rails (3.2.0)
|
106
|
+
actionpack (>= 4.0)
|
107
|
+
activesupport (>= 4.0)
|
108
|
+
sprockets (>= 3.0.0)
|
109
|
+
thor (0.19.4)
|
110
|
+
thread_safe (0.3.6)
|
111
|
+
tzinfo (1.2.3)
|
112
|
+
thread_safe (~> 0.1)
|
113
|
+
websocket-driver (0.6.5)
|
114
|
+
websocket-extensions (>= 0.1.0)
|
115
|
+
websocket-extensions (0.1.2)
|
116
|
+
|
117
|
+
PLATFORMS
|
118
|
+
ruby
|
119
|
+
|
120
|
+
DEPENDENCIES
|
121
|
+
bundler (>= 1.0.0)
|
122
|
+
rails (~> 5.1)
|
123
|
+
rspec (~> 2.6)
|
124
|
+
wor!
|
125
|
+
|
126
|
+
BUNDLED WITH
|
127
|
+
1.14.5
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module WOR
|
2
|
+
class Collection
|
3
|
+
attr_accessor :name
|
4
|
+
|
5
|
+
def initialize collection_name
|
6
|
+
@name = collection_name
|
7
|
+
end
|
8
|
+
|
9
|
+
def items
|
10
|
+
files = Dir.glob("#{Rails.root}/content/#{self.name.downcase}/*")
|
11
|
+
|
12
|
+
@items = Array.new
|
13
|
+
|
14
|
+
files.each do | file |
|
15
|
+
item = CollectionItem.new file
|
16
|
+
@items << item
|
17
|
+
end
|
18
|
+
|
19
|
+
return @items
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
module WOR
|
2
|
+
class CollectionItem
|
3
|
+
attr_accessor :path, :body, :layout, :name
|
4
|
+
|
5
|
+
def initialize path
|
6
|
+
self.path = path
|
7
|
+
self.body = Hash.new
|
8
|
+
self.layout = "application"
|
9
|
+
self.name = "Null"
|
10
|
+
|
11
|
+
if (!File.exists?(path))
|
12
|
+
puts 'File not exists'
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
if (File.file?(path))
|
17
|
+
extn = File.extname path
|
18
|
+
self.name = File.basename path, extn
|
19
|
+
create_custom_properties(self.path, true)
|
20
|
+
else
|
21
|
+
directory_initialize self.path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def directory_initialize path
|
26
|
+
files = Dir.glob(path + "/*")
|
27
|
+
|
28
|
+
files.each do | file |
|
29
|
+
extn = File.extname file
|
30
|
+
name = File.basename file, extn
|
31
|
+
if (name == "_meta")
|
32
|
+
create_custom_properties(file, false)
|
33
|
+
else
|
34
|
+
self.add_language File.read(file), name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def content (language = "default")
|
40
|
+
language = language.to_s
|
41
|
+
|
42
|
+
lang_content = self.body[language]
|
43
|
+
|
44
|
+
if (!lang_content.nil?)
|
45
|
+
return lang_content
|
46
|
+
end
|
47
|
+
|
48
|
+
lang_content = self.body["default"]
|
49
|
+
|
50
|
+
if (!lang_content.nil?)
|
51
|
+
return lang_content
|
52
|
+
else
|
53
|
+
return ""
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_permalink locale
|
58
|
+
begin
|
59
|
+
permalink = self.send("permalink_" + locale)
|
60
|
+
if (permalink.present?)
|
61
|
+
return permalink
|
62
|
+
else
|
63
|
+
return self.permalink
|
64
|
+
end
|
65
|
+
rescue
|
66
|
+
return self.permalink
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_language file_data, language
|
71
|
+
if (language == "")
|
72
|
+
language = "default"
|
73
|
+
end
|
74
|
+
|
75
|
+
self.body[language] = file_data
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
def create_custom_properties file, get_body
|
80
|
+
results = File.read(file).match(/(---.+---)(.*)/m)
|
81
|
+
|
82
|
+
if (results.nil?)
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
meta_data = results[1]
|
87
|
+
if (get_body)
|
88
|
+
self.add_language(results[2], "")
|
89
|
+
end
|
90
|
+
|
91
|
+
lines = meta_data.split("\n")
|
92
|
+
|
93
|
+
@meta = Hash.new
|
94
|
+
|
95
|
+
lines.each do | line |
|
96
|
+
if (line.strip != "---")
|
97
|
+
results = line.match(/(.+):(.*)/)
|
98
|
+
|
99
|
+
if (results.nil?)
|
100
|
+
next
|
101
|
+
end
|
102
|
+
|
103
|
+
key = results[1].strip
|
104
|
+
|
105
|
+
create_attr(key)
|
106
|
+
self.send("#{key}=", results[2].strip)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def create_method( name, &block )
|
112
|
+
self.class.send( :define_method, name, &block )
|
113
|
+
end
|
114
|
+
|
115
|
+
def create_attr( name )
|
116
|
+
create_method( "#{name}=".to_sym ) { |val|
|
117
|
+
instance_variable_set( "@" + name, val)
|
118
|
+
}
|
119
|
+
|
120
|
+
create_method( name.to_sym ) {
|
121
|
+
instance_variable_get( "@" + name )
|
122
|
+
}
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/wor.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'rails'
|
2
|
-
require 'wor/collection'
|
3
|
-
require 'wor/collection_item'
|
4
2
|
|
5
3
|
module WOR
|
4
|
+
autoload :Collection, 'wor/collection'
|
5
|
+
autoload :CollectionItem, 'wor/collection_item'
|
6
|
+
|
6
7
|
class Core
|
7
8
|
def self.find params
|
8
9
|
collection = self.get_collection(locale: params[:locale], collection: params[:collection])
|
data/log/test.log
ADDED
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "action_controller/railtie"
|
4
|
+
require "action_mailer/railtie"
|
5
|
+
require "rails/test_unit/railtie"
|
6
|
+
|
7
|
+
#Bundler.require :default, DEVISE_ORM
|
8
|
+
|
9
|
+
#begin
|
10
|
+
# require "#{DEVISE_ORM}/railtie"
|
11
|
+
#rescue LoadError
|
12
|
+
#end
|
13
|
+
|
14
|
+
#require "wor"
|
15
|
+
|
16
|
+
module RailsApp
|
17
|
+
class Application < Rails::Application
|
18
|
+
I18n.config.available_locales = [:pt, :en]
|
19
|
+
# Add additional load paths for your own custom dirs
|
20
|
+
#config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers mailers views).include?($1) }
|
21
|
+
#config.autoload_paths += ["#{config.root}/app/#{DEVISE_ORM}"]
|
22
|
+
|
23
|
+
# Configure generators values. Many other options are available, be sure to check the documentation.
|
24
|
+
# config.generators do |g|
|
25
|
+
# g.orm :active_record
|
26
|
+
# g.template_engine :erb
|
27
|
+
# g.test_framework :test_unit, fixture: true
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
31
|
+
config.filter_parameters << :password
|
32
|
+
# config.assets.enabled = false
|
33
|
+
|
34
|
+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
|
35
|
+
|
36
|
+
# This was used to break devise in some situations
|
37
|
+
#config.to_prepare do
|
38
|
+
# Devise::SessionsController.layout "application"
|
39
|
+
#end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#unless defined?(DEVISE_ORM)
|
2
|
+
# DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
|
3
|
+
#end
|
4
|
+
|
5
|
+
module WOR
|
6
|
+
module Test
|
7
|
+
# Detection for minor differences between Rails 4 and 5, and 5.1 in tests.
|
8
|
+
def self.rails51?
|
9
|
+
Rails.version.start_with? '5.1'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.rails5?
|
13
|
+
Rails.version.start_with? '5'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Set up gems listed in the Gemfile.
|
19
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
20
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
@@ -0,0 +1,30 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send.
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers.
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Raise an error on page load if there are pending migrations
|
26
|
+
config.active_record.migration_error = :page_load
|
27
|
+
|
28
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
29
|
+
config.assets.debug = true
|
30
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both thread web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
21
|
+
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
+
if Rails.version >= "5.0.0"
|
24
|
+
config.public_file_server.enabled = false
|
25
|
+
elsif Rails.version >= "4.2.0"
|
26
|
+
config.serve_static_files = false
|
27
|
+
else
|
28
|
+
config.serve_static_assets = false
|
29
|
+
end
|
30
|
+
|
31
|
+
# Compress JavaScripts and CSS.
|
32
|
+
config.assets.js_compressor = :uglifier
|
33
|
+
# config.assets.css_compressor = :sass
|
34
|
+
|
35
|
+
# Whether to fallback to assets pipeline if a precompiled asset is missed.
|
36
|
+
config.assets.compile = false
|
37
|
+
|
38
|
+
# Generate digests for assets URLs.
|
39
|
+
config.assets.digest = true
|
40
|
+
|
41
|
+
# Version of your assets, change this if you want to expire all your assets.
|
42
|
+
config.assets.version = '1.0'
|
43
|
+
|
44
|
+
# Specifies the header that your server uses for sending files.
|
45
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
46
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
47
|
+
|
48
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
49
|
+
# config.force_ssl = true
|
50
|
+
|
51
|
+
# Set to :debug to see everything in the log.
|
52
|
+
config.log_level = :info
|
53
|
+
|
54
|
+
# Prepend all log lines with the following tags.
|
55
|
+
# config.log_tags = [:subdomain, :uuid]
|
56
|
+
|
57
|
+
# Use a different logger for distributed setups.
|
58
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
59
|
+
|
60
|
+
# Use a different cache store in production.
|
61
|
+
# config.cache_store = :mem_cache_store
|
62
|
+
|
63
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
64
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
65
|
+
|
66
|
+
# Precompile additional assets.
|
67
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
68
|
+
# config.assets.precompile += %w( search.js )
|
69
|
+
|
70
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
71
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
72
|
+
# config.action_mailer.raise_delivery_errors = false
|
73
|
+
|
74
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
75
|
+
# the I18n.default_locale when a translation can not be found).
|
76
|
+
config.i18n.fallbacks = true
|
77
|
+
|
78
|
+
# Send deprecation notices to registered listeners.
|
79
|
+
config.active_support.deprecation = :notify
|
80
|
+
|
81
|
+
# Disable automatic flushing of the log to improve performance.
|
82
|
+
# config.autoflush_log = false
|
83
|
+
|
84
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
85
|
+
config.log_formatter = ::Logger::Formatter.new
|
86
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Disable serving static files from the `/public` folder by default since
|
16
|
+
# Apache or NGINX already handles this.
|
17
|
+
if Rails.version >= "5.0.0"
|
18
|
+
config.public_file_server.enabled = true
|
19
|
+
config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
|
20
|
+
elsif Rails.version >= "4.2.0"
|
21
|
+
config.serve_static_files = true
|
22
|
+
config.static_cache_control = "public, max-age=3600"
|
23
|
+
else
|
24
|
+
config.serve_static_assets = true
|
25
|
+
config.static_cache_control = "public, max-age=3600"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Show full error reports and disable caching.
|
29
|
+
config.consider_all_requests_local = true
|
30
|
+
config.action_controller.perform_caching = false
|
31
|
+
|
32
|
+
# Raise exceptions instead of rendering exception templates.
|
33
|
+
config.action_dispatch.show_exceptions = false
|
34
|
+
|
35
|
+
# Disable request forgery protection in test environment.
|
36
|
+
config.action_controller.allow_forgery_protection = false
|
37
|
+
|
38
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
39
|
+
# The :test delivery method accumulates sent emails in the
|
40
|
+
# ActionMailer::Base.deliveries array.
|
41
|
+
config.action_mailer.delivery_method = :test
|
42
|
+
|
43
|
+
# Print deprecation notices to the stderr.
|
44
|
+
config.active_support.deprecation = :stderr
|
45
|
+
end
|
File without changes
|
data/spec/test_helper.rb
ADDED
data/spec/wor_spec.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'wor'
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
describe WOR::Core do
|
5
|
+
it 'get permalink' do
|
6
|
+
item = WOR::CollectionItem.new "#{Rails.root}/content/courses/curso-teste.md"
|
7
|
+
|
8
|
+
expect(item.get_permalink("en")).to eql("test")
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'get permalink index in pt' do
|
12
|
+
item_index = WOR::CollectionItem.new "#{Rails.root}/content/pages/index.md"
|
13
|
+
expect(item_index.get_permalink("pt")).to eql("/")
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'get collection folder name in default language' do
|
17
|
+
collection_folder_name = WOR::Core.get_collection_folder_name('en', 'courses')
|
18
|
+
expect(collection_folder_name).to eql("courses")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'get collection folder name in pt language' do
|
22
|
+
collection_folder_name = WOR::Core.get_collection_folder_name('pt', 'cursos')
|
23
|
+
expect(collection_folder_name).to eql("courses")
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'read locale file that exists' do
|
27
|
+
locale_file = WOR::Core.read_locale_file('en')
|
28
|
+
expect(locale_file).not_to be(nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'read locale file that not exists' do
|
32
|
+
locale_file = WOR::Core.read_locale_file('fr')
|
33
|
+
expect(locale_file).to be(nil)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'find' do
|
37
|
+
params = { collection: "pages", locale: "en", page_name: "index"}
|
38
|
+
target = WOR::Core.find(params)
|
39
|
+
|
40
|
+
expect(target.permalink).not_to be(nil)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'find with basename' do
|
44
|
+
params = { collection: "cursos", locale: "pt", page_name: "teste"}
|
45
|
+
target = WOR::Core.find(params)
|
46
|
+
|
47
|
+
expect(target).not_to be(nil)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'find with basename without item have permalink on language' do
|
51
|
+
params = { collection: "courses", locale: "en", page_name: "test" }
|
52
|
+
target = WOR::Core.find(params)
|
53
|
+
|
54
|
+
expect(target.permalink).not_to be(nil)
|
55
|
+
end
|
56
|
+
end
|
data/wor.gemspec
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'wor'
|
3
|
+
s.version = '0.0.4'
|
4
|
+
s.date = '2017-05-07'
|
5
|
+
s.summary = "To do summary!"
|
6
|
+
s.description = "To do description"
|
7
|
+
s.authors = ["Rodrigo Vargas"]
|
8
|
+
s.email = 'rodrigo@rodrigovargas.me'
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.homepage = 'http://rubygems.org/gems/wor'
|
11
|
+
|
12
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
13
|
+
s.add_development_dependency "rspec", "~> 2.6"
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Vargas
|
@@ -44,7 +44,28 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
+
- Gemfile
|
48
|
+
- Gemfile.lock
|
47
49
|
- lib/wor.rb
|
50
|
+
- lib/wor/collection.rb
|
51
|
+
- lib/wor/collection_item.rb
|
52
|
+
- log/test.log
|
53
|
+
- spec/rails_app/Rakefile
|
54
|
+
- spec/rails_app/config.ru
|
55
|
+
- spec/rails_app/config/application.rb
|
56
|
+
- spec/rails_app/config/boot.rb
|
57
|
+
- spec/rails_app/config/environment.rb
|
58
|
+
- spec/rails_app/config/environments/development.rb
|
59
|
+
- spec/rails_app/config/environments/production.rb
|
60
|
+
- spec/rails_app/config/environments/test.rb
|
61
|
+
- spec/rails_app/config/locales/wor.en.yml
|
62
|
+
- spec/rails_app/config/locales/wor.pt.yml
|
63
|
+
- spec/rails_app/content/courses/curso-teste.md
|
64
|
+
- spec/rails_app/content/pages/index.md
|
65
|
+
- spec/rails_app/log/test.log
|
66
|
+
- spec/test_helper.rb
|
67
|
+
- spec/wor_spec.rb
|
68
|
+
- wor.gemspec
|
48
69
|
homepage: http://rubygems.org/gems/wor
|
49
70
|
licenses: []
|
50
71
|
metadata: {}
|