onload 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +17 -0
- data/LICENSE +21 -0
- data/README.md +64 -0
- data/Rakefile +21 -0
- data/lib/onload/core_ext/kernel.rb +68 -0
- data/lib/onload/core_ext/kernel_zeitwerk.rb +61 -0
- data/lib/onload/ext/activesupport/dependencies.rb +48 -0
- data/lib/onload/ext/bootsnap/autoload.rb +28 -0
- data/lib/onload/ext/zeitwerk/loader.rb +42 -0
- data/lib/onload/file.rb +28 -0
- data/lib/onload/railtie.rb +27 -0
- data/lib/onload/tasks/transpile.rake +10 -0
- data/lib/onload/tasks/transpile_rails.rake +17 -0
- data/lib/onload/version.rb +5 -0
- data/lib/onload.rb +118 -0
- data/onload.gemspec +16 -0
- data/spec/fixtures/hello.rb.up +5 -0
- data/spec/rails/controllers/home_controller_spec.rb +42 -0
- data/spec/rails/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/rails/dummy/app/controllers/home_controller.rb +4 -0
- data/spec/rails/dummy/app/views/home/index.html.erb +1 -0
- data/spec/rails/dummy/app/views/layouts/application.html.erb +1 -0
- data/spec/rails/dummy/config/application.rb +15 -0
- data/spec/rails/dummy/config/routes.rb +3 -0
- data/spec/rails/dummy/config/secrets.yml +2 -0
- data/spec/rails/dummy/log/test.log +68081 -0
- data/spec/rails/spec_helper.rb +32 -0
- data/spec/ruby/onload_spec.rb +17 -0
- data/spec/ruby/spec_helper.rb +8 -0
- data/spec/spec_setup.rb +41 -0
- metadata +73 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] ||= "test"
|
4
|
+
|
5
|
+
require "rails"
|
6
|
+
require "action_controller/railtie"
|
7
|
+
|
8
|
+
require_relative "../spec_setup"
|
9
|
+
|
10
|
+
Dir.chdir(File.expand_path("dummy", __dir__)) do
|
11
|
+
require_relative File.join(*%w(dummy config application))
|
12
|
+
Onload::DummyApplication.initialize!
|
13
|
+
end
|
14
|
+
|
15
|
+
require "rspec/rails"
|
16
|
+
|
17
|
+
module Onload
|
18
|
+
module RailsTestHelpers
|
19
|
+
def with_file_contents(path, contents)
|
20
|
+
old_contents = ::File.read(path)
|
21
|
+
::File.write(path, contents)
|
22
|
+
yield
|
23
|
+
ensure
|
24
|
+
::File.write(path, old_contents)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
RSpec.configure do |config|
|
30
|
+
config.include(Onload::RailsTestHelpers)
|
31
|
+
config.include(Capybara::RSpecMatchers, type: :request)
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ruby/spec_helper"
|
4
|
+
|
5
|
+
describe Onload do
|
6
|
+
it "transpiles a .up file" do
|
7
|
+
require "hello"
|
8
|
+
expect(Hello.new.hello).to eq("HELLO")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "does not transpile when disabled" do
|
12
|
+
Onload.disable do
|
13
|
+
require "hello"
|
14
|
+
expect(Hello.new.hello).to eq("hello")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_setup.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "onload"
|
4
|
+
|
5
|
+
class UpcasePreprocessor
|
6
|
+
def self.call(source)
|
7
|
+
source.gsub(/(\"\w+\")/, '\1.upcase')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Onload.register(".up", UpcasePreprocessor)
|
12
|
+
|
13
|
+
module Onload
|
14
|
+
module TestHelpers
|
15
|
+
def with_clean_env
|
16
|
+
Onload.unprocessed_files_in(fixtures_path).each do |unprocessed_file|
|
17
|
+
processed_file = Onload::File.new(unprocessed_file).outfile
|
18
|
+
::File.unlink(processed_file) if ::File.exist?(processed_file)
|
19
|
+
$LOADED_FEATURES.delete(unprocessed_file)
|
20
|
+
end
|
21
|
+
|
22
|
+
yield
|
23
|
+
end
|
24
|
+
|
25
|
+
def fixtures_path
|
26
|
+
::File.expand_path(::File.join("fixtures"), __dir__)
|
27
|
+
end
|
28
|
+
|
29
|
+
extend(self)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
RSpec.configure do |config|
|
34
|
+
config.extend(Onload::TestHelpers)
|
35
|
+
|
36
|
+
config.around(:each) do |example|
|
37
|
+
Onload::TestHelpers.with_clean_env { example.run }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
$:.push(Onload::TestHelpers.fixtures_path)
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: onload
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cameron Dutro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A preprocessor system for Ruby.
|
14
|
+
email:
|
15
|
+
- camertron@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- CHANGELOG.md
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/onload.rb
|
26
|
+
- lib/onload/core_ext/kernel.rb
|
27
|
+
- lib/onload/core_ext/kernel_zeitwerk.rb
|
28
|
+
- lib/onload/ext/activesupport/dependencies.rb
|
29
|
+
- lib/onload/ext/bootsnap/autoload.rb
|
30
|
+
- lib/onload/ext/zeitwerk/loader.rb
|
31
|
+
- lib/onload/file.rb
|
32
|
+
- lib/onload/railtie.rb
|
33
|
+
- lib/onload/tasks/transpile.rake
|
34
|
+
- lib/onload/tasks/transpile_rails.rake
|
35
|
+
- lib/onload/version.rb
|
36
|
+
- onload.gemspec
|
37
|
+
- spec/fixtures/hello.rb.up
|
38
|
+
- spec/rails/controllers/home_controller_spec.rb
|
39
|
+
- spec/rails/dummy/app/controllers/application_controller.rb
|
40
|
+
- spec/rails/dummy/app/controllers/home_controller.rb
|
41
|
+
- spec/rails/dummy/app/views/home/index.html.erb
|
42
|
+
- spec/rails/dummy/app/views/layouts/application.html.erb
|
43
|
+
- spec/rails/dummy/config/application.rb
|
44
|
+
- spec/rails/dummy/config/routes.rb
|
45
|
+
- spec/rails/dummy/config/secrets.yml
|
46
|
+
- spec/rails/dummy/log/test.log
|
47
|
+
- spec/rails/spec_helper.rb
|
48
|
+
- spec/ruby/onload_spec.rb
|
49
|
+
- spec/ruby/spec_helper.rb
|
50
|
+
- spec/spec_setup.rb
|
51
|
+
homepage: http://github.com/camertron/onload
|
52
|
+
licenses: []
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubygems_version: 3.4.1
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: A preprocessor system for Ruby.
|
73
|
+
test_files: []
|