rails_build 1.2.0 → 2.4.3

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.
@@ -0,0 +1,87 @@
1
+ module RailsBuild
2
+ VERSION = '2.4.3' unless defined?(VERSION)
3
+
4
+ class << self
5
+ def version
6
+ VERSION
7
+ end
8
+
9
+ def repo
10
+ 'https://github.com/ahoward/rails_build'
11
+ end
12
+
13
+ def summary
14
+ <<~____
15
+ a small, simple, bullet proof, and fast enough static site generator built on top of the rails you already know and love
16
+ ____
17
+ end
18
+
19
+ def description
20
+ <<~____
21
+ rails_build is a very small, fast enough, static site generator built
22
+ on top of the rails you already know and love.
23
+
24
+ it's been in production usage for close to a decade but i've been too
25
+ busy to relase it until now. also, #wtf is up with javascript land?!
26
+
27
+ it has a small set of dependencies, namely the `parallel` gem, and
28
+ requires absolutely minimal configuration. it should be pretty darn
29
+ self explanatory:
30
+ ____
31
+ end
32
+
33
+ def libs
34
+ %w[
35
+ fileutils pathname thread socket timeout time uri etc securerandom logger json tempfile net/http
36
+ ]
37
+ end
38
+
39
+ def dependencies
40
+ {
41
+ 'parallel' =>
42
+ ['parallel', '~> 1.26'],
43
+
44
+ 'getoptlong' =>
45
+ ['getoptlong', '~> 0.2'],
46
+ }
47
+ end
48
+
49
+ def libdir(*args, &block)
50
+ @libdir ||= File.dirname(File.expand_path(__FILE__))
51
+ args.empty? ? @libdir : File.join(@libdir, *args)
52
+ ensure
53
+ if block
54
+ begin
55
+ $LOAD_PATH.unshift(@libdir)
56
+ block.call
57
+ ensure
58
+ $LOAD_PATH.shift
59
+ end
60
+ end
61
+ end
62
+
63
+ def load(*libs)
64
+ libs = libs.join(' ').scan(/[^\s+]+/)
65
+ libdir { libs.each { |lib| Kernel.load(lib) } }
66
+ end
67
+
68
+ def load_dependencies!
69
+ libs.each do |lib|
70
+ require lib
71
+ end
72
+
73
+ begin
74
+ require 'rubygems'
75
+ rescue LoadError
76
+ nil
77
+ end
78
+
79
+ has_rubygems = defined?(gem)
80
+
81
+ dependencies.each do |lib, dependency|
82
+ gem(*dependency) if has_rubygems
83
+ require(lib)
84
+ end
85
+ end
86
+ end
87
+ end
data/lib/rails_build.rb CHANGED
@@ -1,20 +1,54 @@
1
- require "rails_build/engine"
1
+ require_relative 'rails_build/_lib.rb'
2
+
3
+ RailsBuild.load_dependencies!
2
4
 
3
5
  module RailsBuild
4
- require "fattr"
6
+ def RailsBuild.configure(&block)
7
+ @configure = block
8
+ end
5
9
 
6
- Fattr(:application){ defined?(Rails.application) ? Rails.application : nil }
10
+ def RailsBuild.dump_config!(path: config_path, dump: config_dump_path)
11
+ config = RailsBuild.load_config!(path:)
7
12
 
8
- def RailsBuild.configure(&block)
9
- block.call(configuration)
13
+ json = JSON.pretty_generate(config.as_json)
14
+
15
+ dirname = File.dirname(dump)
16
+ FileUtils.mkdir_p(dirname)
17
+ IO.binwrite(dump, json)
18
+
19
+ dump
10
20
  end
11
21
 
12
- def RailsBuild.load_config!(path = nil)
13
- path ||= application.root.join('config/rails_build.rb').to_s
22
+ def RailsBuild.load_config!(path: config_path)
23
+ Kernel.load(path)
14
24
 
15
- if test(?s, path)
16
- Kernel.load(path)
25
+ if @configure
26
+ @configure.call(RailsBuild.configuration)
17
27
  end
28
+
29
+ RailsBuild.configuration
30
+ end
31
+
32
+ def RailsBuild.config_path
33
+ case
34
+ when ENV['RAILS_BUILD_CONFIG']
35
+ ENV['RAILS_BUILD_CONFIG']
36
+ when defined?(Rails)
37
+ Rails.application.root.join('config/rails_build.rb')
38
+ else
39
+ './config/rails_build.rb'
40
+ end.to_s
41
+ end
42
+
43
+ def RailsBuild.config_dump_path
44
+ case
45
+ when ENV['RAILS_BUILD_CONFIG_DUMP']
46
+ ENV['RAILS_BUILD_CONFIG_DUMP']
47
+ when defined?(Rails)
48
+ Rails.application.root.join('tmp/rails_build.json')
49
+ else
50
+ './tmp/rails_build.json'
51
+ end.to_s
18
52
  end
19
53
 
20
54
  def RailsBuild.configuration
@@ -25,15 +59,152 @@ module RailsBuild
25
59
  RailsBuild.configuration
26
60
  end
27
61
 
28
- class Configuration
29
- fattr(:urls){ [] }
30
- fattr(:trailing_slash){ true }
62
+ class Configuration < Hash
63
+ ATTRS = %w[
64
+ path
65
+ trailing_slash
66
+ force_ssl
67
+ urls
68
+ index_html
69
+ ]
70
+
71
+ def Configuration.defaults
72
+ defaults = {
73
+ path: RailsBuild.config_path,
74
+ trailing_slash: (defined?(Rails) ? !!Rails.application.default_url_options[:trailing_slash] : false),
75
+ force_ssl: (defined?(Rails) ? !!Rails.configuration.force_ssl : true),
76
+ urls: %w[ / ],
77
+ index_html: true,
78
+ }
79
+ end
80
+
81
+ def Configuration.stringify_keys!(hash)
82
+ hash.transform_keys!(&:to_s)
83
+
84
+ hash.each do |key, val|
85
+ if val.is_a?(Hash)
86
+ Configuration.stringify_keys!(val)
87
+ end
88
+ end
89
+
90
+ hash
91
+ end
92
+
93
+ def initialize(hash = {})
94
+ if hash.empty?
95
+ hash = Configuration.defaults
96
+ end
97
+
98
+ hash.each{|attr, value| send("#{ attr }=", value)}
99
+
100
+ Configuration.stringify_keys!(self)
101
+ end
102
+
103
+ ATTRS.each do |attr|
104
+ getter = "#{ attr }"
105
+ setter = "#{ attr }="
106
+ query = "#{ attr }?"
107
+
108
+ define_method(getter) do |*args|
109
+ case
110
+ when args.size == 0
111
+ fetch(attr)
112
+ when args.size == 1
113
+ value = args.first
114
+ send(setter, value)
115
+ else
116
+ raise ArguementError.new(args.inspect)
117
+ end
118
+ end
119
+
120
+ define_method(setter) do |value|
121
+ update(attr => value)
122
+ end
123
+
124
+ define_method(query) do
125
+ !!fetch(attr)
126
+ end
127
+ end
128
+
129
+ def to_json(*args, **kws, &block)
130
+ JSON.pretty_generate(self)
131
+ end
132
+ end
133
+
134
+ class Assassin
135
+ def Assassin.ate(*args, &block)
136
+ new(*args, &block)
137
+ end
138
+
139
+ attr_accessor :parent_pid
140
+ attr_accessor :child_pid
141
+ attr_accessor :pid
142
+ attr_accessor :path
143
+
144
+ def initialize(child_pid, options = {})
145
+ @child_pid = child_pid.to_s.to_i
146
+ @parent_pid = Process.pid
147
+ @options = Assassin.options_for(options)
148
+ @pid, @path = Assassin.generate(@child_pid, @options)
149
+ end
150
+
151
+ def Assassin.options_for(options)
152
+ options.inject({}){|h, kv| k,v = kv; h.update(k.to_s.to_sym => v)}
153
+ end
154
+
155
+ def Assassin.generate(child_pid, options = {})
156
+ path = File.join(Dir.tmpdir, "assassin-#{ child_pid }-#{ SecureRandom.uuid }.rb")
157
+ script = Assassin.script_for(child_pid, options)
158
+ IO.binwrite(path, script)
159
+ pid = Process.spawn "ruby #{ path }"
160
+ [pid, path]
161
+ end
162
+
163
+ def Assassin.script_for(child_pid, options = {})
164
+ parent_pid = Process.pid
165
+ delay = (options[:delay] || 0.42).to_f
166
+
167
+ script = <<-__
168
+ Process.daemon
169
+
170
+ require 'fileutils'
171
+ at_exit{ FileUtils.rm_f(__FILE__) }
172
+
173
+ parent_pid = #{ parent_pid }
174
+ child_pid = #{ child_pid }
175
+ delay = #{ delay }
176
+
177
+ m = 24*60*60
178
+ n = 42
179
+
180
+ m.times do
181
+ begin
182
+ Process.kill(0, parent_pid)
183
+ rescue Object => e
184
+ sleep(delay)
185
+
186
+ if e.is_a?(Errno::ESRCH)
187
+ n.times do
188
+ begin
189
+ Process.kill(15, child_pid) rescue nil
190
+ sleep(rand + rand)
191
+ Process.kill(9, child_pid) rescue nil
192
+ sleep(rand + rand)
193
+ Process.kill(0, child_pid)
194
+ rescue Errno::ESRCH
195
+ break
196
+ end
197
+ end
198
+ end
199
+
200
+ exit
201
+ end
202
+
203
+ sleep(1)
204
+ end
205
+ __
31
206
 
32
- def urls(*args, &block)
33
- @urls ||= []
34
- args.join(' ').scan(/[^\s]+/).each{|arg| @urls << arg}
35
- @urls.uniq!
36
- block ? @urls.each(&block) : @urls
207
+ return script
37
208
  end
38
209
  end
39
210
  end
@@ -0,0 +1,40 @@
1
+ ## rails_build.gemspec
2
+ #
3
+
4
+ Gem::Specification::new do |spec|
5
+ spec.name = "rails_build"
6
+ spec.version = "2.4.3"
7
+ spec.required_ruby_version = '>= 3.0'
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.summary = "a small, simple, bullet proof, and fast enough static site generator built on top of the rails you already know and love"
10
+ spec.description = "rails_build is a very small, fast enough, static site generator built\non top of the rails you already know and love.\n\nit's been in production usage for close to a decade but i've been too\nbusy to relase it until now. also, #wtf is up with javascript land?!\n\nit has a small set of dependencies, namely the `parallel` gem, and\nrequires absolutely minimal configuration. it should be pretty darn\nself explanatory:"
11
+ spec.license = "Nonstandard"
12
+
13
+ spec.files =
14
+ ["LICENSE",
15
+ "README.md",
16
+ "Rakefile",
17
+ "bin",
18
+ "bin/rails_build",
19
+ "lib",
20
+ "lib/rails_build",
21
+ "lib/rails_build.rb",
22
+ "lib/rails_build/_lib.rb",
23
+ "rails_build.gemspec"]
24
+
25
+ spec.executables = ["rails_build"]
26
+
27
+ spec.require_path = "lib"
28
+
29
+
30
+ spec.add_dependency(*["parallel", "~> 1.26"])
31
+
32
+ spec.add_dependency(*["getoptlong", "~> 0.2"])
33
+
34
+
35
+ spec.extensions.push(*[])
36
+
37
+ spec.author = "Ara T. Howard"
38
+ spec.email = "ara.t.howard@gmail.com"
39
+ spec.homepage = "https://github.com/ahoward/rails_build"
40
+ end
metadata CHANGED
@@ -1,149 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_build
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
- - ahoward
8
- autorequire:
7
+ - Ara T. Howard
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-03 00:00:00.000000000 Z
11
+ date: 2024-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: parallel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: '5'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '5'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '5'
33
- - !ruby/object:Gem::Dependency
34
- name: threadify
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.4'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.4.5
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '1.4'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 1.4.5
53
- - !ruby/object:Gem::Dependency
54
- name: fattr
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '2.3'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 2.3.0
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '2.3'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 2.3.0
73
- - !ruby/object:Gem::Dependency
74
- name: passenger
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '5.0'
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 5.0.30
19
+ version: '1.26'
83
20
  type: :runtime
84
21
  prerelease: false
85
22
  version_requirements: !ruby/object:Gem::Requirement
86
23
  requirements:
87
24
  - - "~>"
88
25
  - !ruby/object:Gem::Version
89
- version: '5.0'
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 5.0.30
26
+ version: '1.26'
93
27
  - !ruby/object:Gem::Dependency
94
- name: persistent_http
28
+ name: getoptlong
95
29
  requirement: !ruby/object:Gem::Requirement
96
30
  requirements:
97
31
  - - "~>"
98
32
  - !ruby/object:Gem::Version
99
- version: '2.0'
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: 2.0.1
33
+ version: '0.2'
103
34
  type: :runtime
104
35
  prerelease: false
105
36
  version_requirements: !ruby/object:Gem::Requirement
106
37
  requirements:
107
38
  - - "~>"
108
39
  - !ruby/object:Gem::Version
109
- version: '2.0'
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: 2.0.1
113
- description: a teeny engine that turns your rails 5 application into a lean, mean,
114
- static site building machine.
115
- email:
116
- - ara.t.howard@gmail.com
40
+ version: '0.2'
41
+ description: |-
42
+ rails_build is a very small, fast enough, static site generator built
43
+ on top of the rails you already know and love.
44
+
45
+ it's been in production usage for close to a decade but i've been too
46
+ busy to relase it until now. also, #wtf is up with javascript land?!
47
+
48
+ it has a small set of dependencies, namely the `parallel` gem, and
49
+ requires absolutely minimal configuration. it should be pretty darn
50
+ self explanatory:
51
+ email: ara.t.howard@gmail.com
117
52
  executables:
118
53
  - rails_build
119
54
  extensions: []
120
55
  extra_rdoc_files: []
121
56
  files:
122
- - MIT-LICENSE
57
+ - LICENSE
123
58
  - README.md
124
59
  - Rakefile
125
- - app/assets/config/rails_build_manifest.js
126
- - app/assets/javascripts/rails_build/application.js
127
- - app/assets/stylesheets/rails_build/application.css
128
- - app/controllers/rails_build/application_controller.rb
129
- - app/helpers/rails_build/application_helper.rb
130
- - app/jobs/rails_build/application_job.rb
131
- - app/mailers/rails_build/application_mailer.rb
132
- - app/models/rails_build/application_record.rb
133
- - app/views/layouts/rails_build/application.html.erb
134
- - app/views/rails_build/application/index.html.erb
135
- - bin/rails
136
60
  - bin/rails_build
137
- - config/routes.rb
138
61
  - lib/rails_build.rb
139
- - lib/rails_build/engine.rb
140
- - lib/rails_build/version.rb
141
- - lib/tasks/rails_build_tasks.rake
62
+ - lib/rails_build/_lib.rb
63
+ - rails_build.gemspec
142
64
  homepage: https://github.com/ahoward/rails_build
143
65
  licenses:
144
- - MIT
66
+ - Nonstandard
145
67
  metadata: {}
146
- post_install_message:
68
+ post_install_message:
147
69
  rdoc_options: []
148
70
  require_paths:
149
71
  - lib
@@ -151,17 +73,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
73
  requirements:
152
74
  - - ">="
153
75
  - !ruby/object:Gem::Version
154
- version: '0'
76
+ version: '3.0'
155
77
  required_rubygems_version: !ruby/object:Gem::Requirement
156
78
  requirements:
157
79
  - - ">="
158
80
  - !ruby/object:Gem::Version
159
81
  version: '0'
160
82
  requirements: []
161
- rubyforge_project:
162
- rubygems_version: 2.6.8
163
- signing_key:
83
+ rubygems_version: 3.5.22
84
+ signing_key:
164
85
  specification_version: 4
165
- summary: a teeny engine that turns your rails 5 application into a lean, mean, static
166
- site building machine
86
+ summary: a small, simple, bullet proof, and fast enough static site generator built
87
+ on top of the rails you already know and love
167
88
  test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2016 ahoward
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.
@@ -1,2 +0,0 @@
1
- //= link_directory ../javascripts/rails_build .js
2
- //= link_directory ../stylesheets/rails_build .css
@@ -1,13 +0,0 @@
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. JavaScript code in this file should be added after the last require_* statement.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,32 +0,0 @@
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 other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
16
-
17
- body{
18
- font-size: 150%;
19
- }
20
-
21
- a:link,
22
- a:visited,
23
- a:active
24
- {
25
- color: black;
26
- }
27
- a:hover
28
- {
29
- color: #FF69B4;
30
- }
31
-
32
-
@@ -1,12 +0,0 @@
1
- module RailsBuild
2
- class ApplicationController < ActionController::Base
3
- protect_from_forgery with: :exception
4
-
5
- def index
6
- end
7
-
8
- def configuration
9
- render :json => RailsBuild.configuration, :layout => false
10
- end
11
- end
12
- end
@@ -1,4 +0,0 @@
1
- module RailsBuild
2
- module ApplicationHelper
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module RailsBuild
2
- class ApplicationJob < ActiveJob::Base
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module RailsBuild
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- module RailsBuild
2
- class ApplicationRecord < ActiveRecord::Base
3
- self.abstract_class = true
4
- end
5
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Rails build</title>
5
- <%= stylesheet_link_tag "rails_build/application", media: "all" %>
6
- <%= javascript_include_tag "rails_build/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>