Module: RailsBuild
- Defined in:
- lib/rails_build.rb,
lib/rails_build/_lib.rb
Defined Under Namespace
Classes: Assassin, Configuration
Constant Summary
collapse
- VERSION =
'2.4.5'
Class Method Summary
collapse
Class Method Details
.config_dump_path ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/rails_build.rb', line 43
def RailsBuild.config_dump_path
case
when ENV['RAILS_BUILD_CONFIG_DUMP']
ENV['RAILS_BUILD_CONFIG_DUMP']
when defined?(Rails)
Rails.application.root.join('tmp/rails_build.json')
else
'./tmp/rails_build.json'
end.to_s
end
|
.config_path ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/rails_build.rb', line 32
def RailsBuild.config_path
case
when ENV['RAILS_BUILD_CONFIG']
ENV['RAILS_BUILD_CONFIG']
when defined?(Rails)
Rails.application.root.join('config/rails_build.rb')
else
'./config/rails_build.rb'
end.to_s
end
|
6
7
8
|
# File 'lib/rails_build.rb', line 6
def RailsBuild.configure(&block)
@configure = block
end
|
.dependencies ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/rails_build/_lib.rb', line 39
def dependencies
{
'parallel' =>
['parallel', '~> 1.26'],
'getoptlong' =>
['getoptlong', '~> 0.2'],
}
end
|
.description ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/rails_build/_lib.rb', line 19
def description
<<~____
rails_build is a very small, fast enough, static site generator built
on top of the rails you already know and love.
it's been in production usage for close to a decade but i've been too
busy to relase it until now. also, #wtf is up with javascript land?!
it has a small set of dependencies, namely the `parallel` gem, and
requires absolutely minimal configuration. it should be pretty darn
self explanatory:
____
end
|
.dump_config!(path: config_path, dump: config_dump_path) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/rails_build.rb', line 10
def RailsBuild.dump_config!(path: config_path, dump: config_dump_path)
config = RailsBuild.load_config!(path:)
json = JSON.pretty_generate(config.as_json)
dirname = File.dirname(dump)
FileUtils.mkdir_p(dirname)
IO.binwrite(dump, json)
dump
end
|
.libdir(*args, &block) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/rails_build/_lib.rb', line 49
def libdir(*args, &block)
@libdir ||= File.dirname(File.expand_path(__FILE__))
args.empty? ? @libdir : File.join(@libdir, *args)
ensure
if block
begin
$LOAD_PATH.unshift(@libdir)
block.call
ensure
$LOAD_PATH.shift
end
end
end
|
.libs ⇒ Object
33
34
35
36
37
|
# File 'lib/rails_build/_lib.rb', line 33
def libs
%w[
fileutils pathname thread socket timeout time uri etc securerandom logger json tempfile net/http
]
end
|
.load(*libs) ⇒ Object
63
64
65
66
|
# File 'lib/rails_build/_lib.rb', line 63
def load(*libs)
libs = libs.join(' ').scan(/[^\s+]+/)
libdir { libs.each { |lib| Kernel.load(lib) } }
end
|
.load_config!(path: config_path) ⇒ Object
.load_dependencies! ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/rails_build/_lib.rb', line 68
def load_dependencies!
libs.each do |lib|
require lib
end
begin
require 'rubygems'
rescue LoadError
nil
end
has_rubygems = defined?(gem)
dependencies.each do |lib, dependency|
gem(*dependency) if has_rubygems
require(lib)
end
end
|
.repo ⇒ Object
9
10
11
|
# File 'lib/rails_build/_lib.rb', line 9
def repo
'https://github.com/ahoward/rails_build'
end
|
.summary ⇒ Object
13
14
15
16
17
|
# File 'lib/rails_build/_lib.rb', line 13
def summary
<<~____
a small, simple, bullet proof, and fast enough static site generator built on top of the rails you already know and love
____
end
|
.version ⇒ Object
5
6
7
|
# File 'lib/rails_build/_lib.rb', line 5
def version
VERSION
end
|