partial_compiler 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +34 -0
- data/lib/partial_compiler/compiler.rb +53 -0
- data/lib/partial_compiler/file_copier.rb +31 -0
- data/lib/partial_compiler/partial_reader.rb +70 -0
- data/lib/partial_compiler/plugin.rb +21 -0
- data/lib/partial_compiler/railtie.rb +13 -0
- data/lib/partial_compiler/version.rb +5 -0
- data/lib/partial_compiler.rb +26 -0
- data/lib/tasks/partial_compiler_tasks.rake +6 -0
- data/spec/dummy/506076a33d1bf2ff3c0cc6f54dd044a6.jpg +0 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/items.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/assets/stylesheets/items.css +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/items_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/items_helper.rb +2 -0
- data/spec/dummy/app/views/items/_partial_one.html.erb +7 -0
- data/spec/dummy/app/views/items/basic.compiled.html.erb +1 -0
- data/spec/dummy/app/views/items/basic.uc.html.erb +1 -0
- data/spec/dummy/app/views/items/contains_bad_file_path.compiled.html.erb +1 -0
- data/spec/dummy/app/views/items/contains_bad_file_path.uc.html.erb +1 -0
- data/spec/dummy/app/views/items/different_file.compiled.html.erb +1 -0
- data/spec/dummy/app/views/items/different_file.uc.html.erb +1 -0
- data/spec/dummy/app/views/items/dont_compile.html.erb +0 -0
- data/spec/dummy/app/views/items/indentation.compiled.html.erb +9 -0
- data/spec/dummy/app/views/items/indentation.uc.html.erb +5 -0
- data/spec/dummy/app/views/items/index.compiled.html.erb +12 -0
- data/spec/dummy/app/views/items/index.uc.html.erb +6 -0
- data/spec/dummy/app/views/items/multiple.compiled.html.erb +7 -0
- data/spec/dummy/app/views/items/multiple.uc.html.erb +7 -0
- data/spec/dummy/app/views/items/partials/_basic_partial.html.erb +1 -0
- data/spec/dummy/app/views/items/partials/_indentation_partial.html.erb +5 -0
- data/spec/dummy/app/views/items/partials/_multiple_first_partial.html.erb +1 -0
- data/spec/dummy/app/views/items/partials/_multiple_second_partial.html.erb +1 -0
- data/spec/dummy/app/views/items/partials/_partial_with_locals.html.erb +4 -0
- data/spec/dummy/app/views/items/with_locals.compiled.html.erb +7 -0
- data/spec/dummy/app/views/items/with_locals.uc.html.erb +3 -0
- data/spec/dummy/app/views/layouts/_different_file_partial.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +19 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/test/controllers/items_controller_test.rb +7 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2T/2TvyB7oCl45DgkqrOmVbcm7yOh9lByBQlhTlAE1aW_4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2Z/2ZLOKOJiwnIinAqhbzRKh1IEETiZREr1YQCFyxYFbN4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4_/4_dJBa_7QKLBIH0jjg65cebTAuY_sLVo_iQQ0fps8js.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4e/4e49Lfrtv8PSiOHv2GUFdvcmdkIS4BoTchZLv5i0tio.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DI/DIDMTMwEVtUVb-ITNF4QSqI7XzdufrpRJsaSsXsR6Oo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DS/DSOLSc6A5RVSmvM415eEWAWG_AgOvZcLZOXQjsXyWQA.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Fk/FknohZHEdWUMw4HSUB3lC41QMsEub5BAxzqByuFalTo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Fp/Fp9Oou-zxL8DBeFhErfzZn_n3uuxvXRnbDdfDqTjH2s.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Iz/Izw6_7mFleuiGKShX69gMYO9Ycvlf40MiJmOxjzTHmk.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lh/Lhz4lqOT-V39qOS7NLUbcm0zro3pI89tjgetnWOy6J8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lp/LpVVHFy8fsU4uEWj6lUrWVys_fZa6GGsAqHetorFs70.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ms/MsFgmP1VPAADfJsOCG9kWoNeupnJrCzbQPmDH8uNQ18.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/N6/N6MLwUPB6cVIotbqabmrqnSqvR-p2QRv-mbGyuLTP7Q.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/W3/W3cHMqKo_nr5qJKR0V308_tcplrQSnxUmMDfQglGwWI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wv/WvJk4Iot2igCSrbfApqrmStuSQOffzWBG_RYTqQop70.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_C/_CT--lr3faMfLwjijTYy0pr0HzoPHvtHTc6qgI4t8p0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_p/_pmchTL85UhaPBE5s8b54TEwsaoxFVsMb-7moIiCSco.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bz/bz9GlwV9YVGmZmMz8QCbkM054HyMw3mKt9QwHu7-rAU.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/d_/d__pyZ59nw3OcLIeBQa9I1BICeS1U0TYych01h_EmwQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gZ/gZp3uXMHuYQC4hzCr7bQfetKNdJAtbQmg3so2KpW1Dw.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/kK/kKighvnHFWJvvAkczrnpVfPbGBtzU3Lht7C0_9jTW5A.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pU/pU5LSxsCI1T-Tm2QnWGrW6j9AO0pUdFUT6rzFgt6gv4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qS/qS5uuVKc-Cov8_EtzIk6lQ3mMZTbaXBG6O2EhNo6PQY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/s_/s_AOM3l5j9AJz822ydKG2I2iyDE-kKBAkGowYlI9Cxs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xb/xbafQVqcZegyme7hswguXLz08ireksM0iHrrg9cM_vs.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yi/yiIIWnhCkd_bdi7bbNGLmnOjLZQ2i338IFSWQmx67b8.cache +1 -0
- data/spec/expected_file_contents.rb +12 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/tests/compiler_spec.rb +60 -0
- data/spec/tests/plugin_spec.rb +30 -0
- metadata +323 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea61ca2744f267a516fa1bbdf0509ca403d6da93
|
4
|
+
data.tar.gz: fcaa34f7fd2c0d80d44ba9ad564c5aa3319c05a7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2351b4a326e1b91200ee7846ad524f242db014fd4d8629f6ee42b3fdc1566a31a2c83a61efebd96fbddd5cdbd6614618373601d080c8abb3a17e50eed3af4bea
|
7
|
+
data.tar.gz: 553d23d029889c944c8462b05353c3b9c5a155f1382841b9b1d63ffa028a76fc175fa5cd8c47bd1d32fc356e80362b02161ad3d2fbcaa5355d5935122b0328bf
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Noah Kochanowicz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'PartialCompiler'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
3
|
+
module PartialCompiler
|
4
|
+
class Compiler
|
5
|
+
attr_accessor :files
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@files = FileCopier.create_files
|
9
|
+
@files.each do |file|
|
10
|
+
find_partials(file)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def find_partials compiled_file_path
|
17
|
+
text = File.open(compiled_file_path).read
|
18
|
+
compiled_content = ""
|
19
|
+
text.each_line do |line|
|
20
|
+
compiled_content += read_each_line(line, compiled_file_path)
|
21
|
+
end
|
22
|
+
compiled_content.to_s.force_encoding('UTF-8')
|
23
|
+
File.open(compiled_file_path, "w") {|file| file.puts compiled_content }
|
24
|
+
end
|
25
|
+
|
26
|
+
def read_each_line line, compiled_file_path
|
27
|
+
if line.include? PartialCompiler.config[:rendering_engine_partial_format]
|
28
|
+
the_partial = PartialReader.new(line, compiled_file_path)
|
29
|
+
if the_partial.contents
|
30
|
+
locals_line = generate_locals(the_partial.locals, line, the_partial.indentation)
|
31
|
+
content_with_locals = [locals_line, the_partial.contents].compact.join("\n")
|
32
|
+
return content_with_locals
|
33
|
+
end
|
34
|
+
end
|
35
|
+
line
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate_locals locals, original_line, indentation
|
39
|
+
if locals
|
40
|
+
condensed_locals = locals.map{|local, value| "#{local}=#{get_local_value(local, original_line)}"}.join(";")
|
41
|
+
return "#{(" " * indentation)}<% #{condensed_locals} %>"
|
42
|
+
else
|
43
|
+
return nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_local_value local, original_line
|
48
|
+
find_value_of_local = /#{local}:([^,}]*)/
|
49
|
+
original_line.match(find_value_of_local)[-1]
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
3
|
+
module PartialCompiler
|
4
|
+
class FileCopier
|
5
|
+
def self.create_files
|
6
|
+
files_to_compile = []
|
7
|
+
find_files_by_extension.each do |file|
|
8
|
+
compiled_file_path = find_compiled_file(file)
|
9
|
+
files_to_compile << compiled_file_path
|
10
|
+
end
|
11
|
+
files_to_compile
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.find_files_by_extension
|
17
|
+
views_directory = Rails.root.join("app", "views")
|
18
|
+
original_extension = PartialCompiler.config[:original_extension]
|
19
|
+
Find.find(views_directory).select do |p|
|
20
|
+
/.*\.uc.#{original_extension}$|.*\.uncompiled.#{original_extension}$/ =~ p
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find_compiled_file file_path
|
25
|
+
compiled_file_path = file_path.gsub(/uc|uncompiled/, "compiled")
|
26
|
+
FileUtils.cp(file_path, compiled_file_path)
|
27
|
+
return compiled_file_path
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "safe_ruby"
|
2
|
+
require "find"
|
3
|
+
|
4
|
+
module PartialCompiler
|
5
|
+
class PartialReader
|
6
|
+
attr_accessor :path, :locals, :contents, :indentation
|
7
|
+
|
8
|
+
# @path: Where the partial file is located
|
9
|
+
# @locals: The locals set in the uncompiled file
|
10
|
+
# @contents: The actual guts of the partial which will be placed in the compiled file
|
11
|
+
# @indentation: The indentation on the line where 'render partial' is called
|
12
|
+
|
13
|
+
def initialize original_string, file_called_from
|
14
|
+
code_to_eval = original_string.match(PartialCompiler.config[:regex_partial_eval_match])[1]
|
15
|
+
path_to_partial, partial_name, @locals = execute_safe_ruby(code_to_eval)
|
16
|
+
set_path(path_to_partial, partial_name, file_called_from)
|
17
|
+
get_indentation(original_string)
|
18
|
+
set_contents(@indentation)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def execute_safe_ruby code_to_eval
|
24
|
+
render_method = "def render *args
|
25
|
+
arguments = args[0]
|
26
|
+
split_partial_name = arguments[:partial].split('/')
|
27
|
+
return split_partial_name[0...-1], split_partial_name[-1], arguments[:locals]
|
28
|
+
end
|
29
|
+
#{code_to_eval}"
|
30
|
+
partial_name, locals = SafeRuby.eval(render_method)
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_path(path_to_partial, partial_name, calling_file)
|
34
|
+
# Find a file in the same directory as the parent
|
35
|
+
calling_file_path = calling_file.split("/")[0...-1].join("/")
|
36
|
+
path_to_search = [calling_file_path, path_to_partial].compact.join("/")
|
37
|
+
@path = find_file_in_path(partial_name, path_to_search)
|
38
|
+
# If the path hasn't been found by now, it's likely because it's a layout file
|
39
|
+
if !@path
|
40
|
+
path_to_search = [Rails.root.join("app", "views"), path_to_partial].compact.join("/")
|
41
|
+
@path = find_file_in_path(partial_name, path_to_search)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_indentation original_string
|
46
|
+
@indentation = original_string[/\A */].size
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_contents indentation
|
50
|
+
if @path
|
51
|
+
file = File.open(@path, "rb")
|
52
|
+
@contents = add_indentation(file.read, indentation)
|
53
|
+
file.close
|
54
|
+
else
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_indentation contents, indentation
|
60
|
+
return (" " * indentation) + contents.gsub("\n", "\n" + (" " * indentation)).strip + "\n"
|
61
|
+
end
|
62
|
+
|
63
|
+
def find_file_in_path file_name, path_to_search
|
64
|
+
Find.find(path_to_search) do |path|
|
65
|
+
return path if path =~ /_(#{file_name})/
|
66
|
+
end rescue nil
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PartialCompiler
|
2
|
+
class Plugin
|
3
|
+
def initialize
|
4
|
+
original_extension = PartialCompiler.config[:original_extension]
|
5
|
+
template_engine = PartialCompiler.config[:template_engine]
|
6
|
+
if !PartialCompiler.config[:run_compiled]
|
7
|
+
ActionView::Template.register_template_handler(
|
8
|
+
"uc.#{original_extension}".to_sym, "uncompiled.#{original_extension}".to_sym,
|
9
|
+
template_engine.send(:new)
|
10
|
+
)
|
11
|
+
else
|
12
|
+
ActionView::Template.register_template_handler("compiled.#{original_extension}".to_sym, template_engine.send(:new))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.start
|
18
|
+
Plugin.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module PartialCompiler
|
2
|
+
require 'partial_compiler/railtie' if defined?(Rails)
|
3
|
+
@config = {
|
4
|
+
template_engine: ActionView::Template::Handlers::ERB,
|
5
|
+
original_extension: "html.erb",
|
6
|
+
rendering_engine_partial_format: "= render partial:",
|
7
|
+
# This code would be the code that's executing inside your template, e.g. `render partial: 'my_partial'`
|
8
|
+
regex_partial_eval_match: /(render .*)%>/,
|
9
|
+
run_compiled: !Rails.env.development?
|
10
|
+
}
|
11
|
+
|
12
|
+
@valid_config_keys = @config.keys
|
13
|
+
|
14
|
+
def self.configure(opts = {})
|
15
|
+
opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.config
|
19
|
+
@config
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require "partial_compiler/plugin"
|
24
|
+
require "partial_compiler/file_copier"
|
25
|
+
require "partial_compiler/partial_reader"
|
26
|
+
require "partial_compiler/compiler"
|
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
I'm so basic it hurts
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: "partials/basic_partial" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: "i_dont_exist" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: "i_dont_exist" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
I'm in a different directory
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: "layouts/different_file_partial" %>
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
I'm so basic it hurts
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello from file one
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello from file two
|
@@ -0,0 +1 @@
|
|
1
|
+
I'm in a different directory
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "partial_compiler"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
|
22
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
|
+
config.active_record.raise_in_transactional_callbacks = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|