rails_build 1.0.0 → 2.4.2

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,33 @@
1
+ <<~________
2
+
3
+ this file should to enumerate all the urls you'd like to build
4
+
5
+ the contents of your ./public directory, and any assets, are automaticaly included
6
+
7
+ therefore you need only declare which dynamic urls, that is to say, 'routes'
8
+
9
+ you would like included in your build
10
+
11
+ it is not loaded except during build time, and will not affect your normal rails app in any way
12
+
13
+ ________
14
+
15
+
16
+ RailsBuild.configure do |config|
17
+
18
+ # most of the time you are going to want your route included, which will
19
+ # translate into an ./index.html being output in the build
20
+ #
21
+
22
+ config.urls << '/'
23
+
24
+ # include any/all additional routes youd' like built thusly
25
+ #
26
+
27
+ Post.each do |post|
28
+ config.urls << "/posts/#{ post.id }"
29
+ end
30
+
31
+ # thats it! - now just run `rails_build` and you are GTG
32
+
33
+ end
@@ -0,0 +1,87 @@
1
+ module RailsBuild
2
+ VERSION = '2.4.2' 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,18 +1,54 @@
1
- require "rails_build/engine"
1
+ require_relative 'rails_build/_lib.rb'
2
2
 
3
- module RailsBuild
4
- Fattr(:application){ defined?(Rails.application) ? Rails.application : nil }
3
+ RailsBuild.load_dependencies!
5
4
 
5
+ module RailsBuild
6
6
  def RailsBuild.configure(&block)
7
- block.call(configuration)
7
+ @configure = block
8
+ end
9
+
10
+ def RailsBuild.dump_config!(path: config_path, dump: config_dump_path)
11
+ config = RailsBuild.load_config!(path:)
12
+
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
8
20
  end
9
21
 
10
- def RailsBuild.load_config!(path = nil)
11
- path ||= application.root.join('config/rails_build.rb').to_s
22
+ def RailsBuild.load_config!(path: config_path)
23
+ Kernel.load(path)
12
24
 
13
- if test(?s, path)
14
- Kernel.load(path)
25
+ if @configure
26
+ @configure.call(RailsBuild.configuration)
15
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
16
52
  end
17
53
 
18
54
  def RailsBuild.configuration
@@ -23,15 +59,152 @@ module RailsBuild
23
59
  RailsBuild.configuration
24
60
  end
25
61
 
26
- class Configuration
27
- fattr(:urls){ [] }
28
- 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
+ __
29
206
 
30
- def urls(*args, &block)
31
- @urls ||= []
32
- args.join(' ').scan(/[^\s]+/).each{|arg| @urls << arg}
33
- @urls.uniq!
34
- block ? @urls.each(&block) : @urls
207
+ return script
35
208
  end
36
209
  end
37
210
  end
@@ -0,0 +1,42 @@
1
+ ## rails_build.gemspec
2
+ #
3
+
4
+ Gem::Specification::new do |spec|
5
+ spec.name = "rails_build"
6
+ spec.version = "2.4.2"
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 = "Ruby"
12
+
13
+ spec.files =
14
+ ["LICENSE",
15
+ "README.md",
16
+ "Rakefile",
17
+ "bin",
18
+ "bin/rails_build",
19
+ "config",
20
+ "config/rails_build.rb",
21
+ "lib",
22
+ "lib/rails_build",
23
+ "lib/rails_build.rb",
24
+ "lib/rails_build/_lib.rb",
25
+ "rails_build.gemspec"]
26
+
27
+ spec.executables = ["rails_build"]
28
+
29
+ spec.require_path = "lib"
30
+
31
+
32
+ spec.add_dependency(*["parallel", "~> 1.26"])
33
+
34
+ spec.add_dependency(*["getoptlong", "~> 0.2"])
35
+
36
+
37
+ spec.extensions.push(*[])
38
+
39
+ spec.author = "Ara T. Howard"
40
+ spec.email = "ara.t.howard@gmail.com"
41
+ spec.homepage = "https://github.com/ahoward/rails_build"
42
+ end
metadata CHANGED
@@ -1,111 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_build
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.4.2
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: 2016-10-23 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.0.0
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 5.0.0.1
19
+ version: '1.26'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 5.0.0
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 5.0.0.1
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.5
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 1.4.5
26
+ version: '1.26'
47
27
  - !ruby/object:Gem::Dependency
48
- name: passenger
28
+ name: getoptlong
49
29
  requirement: !ruby/object:Gem::Requirement
50
30
  requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 5.0.30
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 5.0.30
61
- - !ruby/object:Gem::Dependency
62
- name: persistent_http
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
31
+ - - "~>"
66
32
  - !ruby/object:Gem::Version
67
- version: 2.0.1
33
+ version: '0.2'
68
34
  type: :runtime
69
35
  prerelease: false
70
36
  version_requirements: !ruby/object:Gem::Requirement
71
37
  requirements:
72
- - - ">="
38
+ - - "~>"
73
39
  - !ruby/object:Gem::Version
74
- version: 2.0.1
75
- description: a teeny engine that turns your rails 5 application into a lean, mean,
76
- static site building machine
77
- email:
78
- - 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
79
52
  executables:
80
53
  - rails_build
81
54
  extensions: []
82
55
  extra_rdoc_files: []
83
56
  files:
84
- - MIT-LICENSE
57
+ - LICENSE
85
58
  - README.md
86
59
  - Rakefile
87
- - app/assets/config/rails_build_manifest.js
88
- - app/assets/javascripts/rails_build/application.js
89
- - app/assets/stylesheets/rails_build/application.css
90
- - app/controllers/rails_build/application_controller.rb
91
- - app/helpers/rails_build/application_helper.rb
92
- - app/jobs/rails_build/application_job.rb
93
- - app/mailers/rails_build/application_mailer.rb
94
- - app/models/rails_build/application_record.rb
95
- - app/views/layouts/rails_build/application.html.erb
96
- - app/views/rails_build/application/index.html.erb
97
- - bin/rails
98
60
  - bin/rails_build
99
- - config/routes.rb
61
+ - config/rails_build.rb
100
62
  - lib/rails_build.rb
101
- - lib/rails_build/engine.rb
102
- - lib/rails_build/version.rb
103
- - lib/tasks/rails_build_tasks.rake
63
+ - lib/rails_build/_lib.rb
64
+ - rails_build.gemspec
104
65
  homepage: https://github.com/ahoward/rails_build
105
66
  licenses:
106
- - MIT
67
+ - Ruby
107
68
  metadata: {}
108
- post_install_message:
69
+ post_install_message:
109
70
  rdoc_options: []
110
71
  require_paths:
111
72
  - lib
@@ -113,18 +74,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
74
  requirements:
114
75
  - - ">="
115
76
  - !ruby/object:Gem::Version
116
- version: '0'
77
+ version: '3.0'
117
78
  required_rubygems_version: !ruby/object:Gem::Requirement
118
79
  requirements:
119
80
  - - ">="
120
81
  - !ruby/object:Gem::Version
121
82
  version: '0'
122
83
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.5.1
125
- signing_key:
84
+ rubygems_version: 3.5.22
85
+ signing_key:
126
86
  specification_version: 4
127
- summary: a teeny engine that turns your rails 5 application into a lean, mean, static
128
- site building machine
87
+ summary: a small, simple, bullet proof, and fast enough static site generator built
88
+ on top of the rails you already know and love
129
89
  test_files: []
130
- has_rdoc:
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>