Compare commits
1 Commits
3057173370
...
16c9e1233a
Author | SHA1 | Date | |
---|---|---|---|
16c9e1233a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,7 +2,6 @@
|
|||||||
/.yardoc
|
/.yardoc
|
||||||
/_yardoc/
|
/_yardoc/
|
||||||
/coverage/
|
/coverage/
|
||||||
/dist/
|
|
||||||
/gen/
|
/gen/
|
||||||
/pkg/
|
/pkg/
|
||||||
/spec/reports/
|
/spec/reports/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2010-2023 Josh Holtrop
|
Copyright (c) 2010-2022 Josh Holtrop
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
4
Rakefile
4
Rakefile
@ -1,9 +1,5 @@
|
|||||||
require "rspec/core/rake_task"
|
require "rspec/core/rake_task"
|
||||||
|
|
||||||
task :build_dist do
|
|
||||||
sh "ruby rb/build_dist.rb"
|
|
||||||
end
|
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec, :example_pattern) do |task, args|
|
RSpec::Core::RakeTask.new(:spec, :example_pattern) do |task, args|
|
||||||
if args.example_pattern
|
if args.example_pattern
|
||||||
task.rspec_opts = %W[-e "#{args.example_pattern}" -f documentation]
|
task.rspec_opts = %W[-e "#{args.example_pattern}" -f documentation]
|
||||||
|
@ -14,4 +14,6 @@ WARNING: This user guide is meant to be preprocessed and rendered by a custom
|
|||||||
script.
|
script.
|
||||||
The markdown source file is not intended to be viewed directly and will not
|
The markdown source file is not intended to be viewed directly and will not
|
||||||
include all intended content.
|
include all intended content.
|
||||||
|
Visit [https://holtrop.github.io/rscons/index.html](https://holtrop.github.io/rscons/index.html)
|
||||||
|
to view the properly rendered version.
|
||||||
${/remove}
|
${/remove}
|
||||||
|
106
rb/build_dist.rb
106
rb/build_dist.rb
@ -1,106 +0,0 @@
|
|||||||
#!/usr/bin/env ruby
|
|
||||||
|
|
||||||
require "fileutils"
|
|
||||||
require "digest/md5"
|
|
||||||
|
|
||||||
if File.read("lib/propane/version.rb") =~ /VERSION = "(.+)"/
|
|
||||||
VERSION = $1
|
|
||||||
else
|
|
||||||
raise "Could not determine version."
|
|
||||||
end
|
|
||||||
PROG_NAME = "propane"
|
|
||||||
START_FILE = "bin/#{PROG_NAME}"
|
|
||||||
LIB_DIR = "lib"
|
|
||||||
DIST = "dist"
|
|
||||||
|
|
||||||
files_processed = {}
|
|
||||||
combined_file = []
|
|
||||||
|
|
||||||
combine_files = lambda do |file|
|
|
||||||
File.read(file, mode: "rb").each_line do |line|
|
|
||||||
if line =~ /^\s*require(?:_relative)?\s*"(.*)"$/
|
|
||||||
require_name = $1
|
|
||||||
if require_name =~ %r{^#{PROG_NAME}(?:/.*)?$}
|
|
||||||
path = "#{LIB_DIR}/#{require_name}.rb"
|
|
||||||
if File.exist?(path)
|
|
||||||
unless files_processed[path]
|
|
||||||
files_processed[path] = true
|
|
||||||
combine_files[path]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise "require path #{path.inspect} not found"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
combined_file << line
|
|
||||||
end
|
|
||||||
else
|
|
||||||
combined_file << line
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
combine_files[START_FILE]
|
|
||||||
|
|
||||||
# Strip Ruby comment lines and empty lines to save some space, but do not
|
|
||||||
# remove lines that are in heredoc sections. This isn't terribly robust to be
|
|
||||||
# used in the wild, but works for the heredoc instances for this project.
|
|
||||||
stripped = []
|
|
||||||
heredoc_end = nil
|
|
||||||
combined_file.each do |line|
|
|
||||||
if line =~ /<<-?([A-Z]+)/
|
|
||||||
heredoc_end = $1
|
|
||||||
end
|
|
||||||
if heredoc_end and line =~ /^\s*#{heredoc_end}/
|
|
||||||
heredoc_end = nil
|
|
||||||
end
|
|
||||||
if line !~ /#\sspecs/
|
|
||||||
if heredoc_end or line !~ /^\s*(#[^!].*)?$/
|
|
||||||
stripped << line
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
license = File.read("LICENSE.txt").gsub(/^(.*?)$/) do |line|
|
|
||||||
if line.size > 0
|
|
||||||
"# #{line}"
|
|
||||||
else
|
|
||||||
"#"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require "zlib"
|
|
||||||
require "base64"
|
|
||||||
compressed_script = Zlib::Deflate.deflate(stripped.join)
|
|
||||||
encoded_compressed_script = Base64.encode64(compressed_script).gsub("\n", "")
|
|
||||||
hash = Digest::MD5.hexdigest(encoded_compressed_script)
|
|
||||||
|
|
||||||
FileUtils.rm_rf(DIST)
|
|
||||||
FileUtils.mkdir_p(DIST)
|
|
||||||
File.open("#{DIST}/#{PROG_NAME}", "wb", 0755) do |fh|
|
|
||||||
fh.write(<<EOF)
|
|
||||||
#!/usr/bin/env ruby
|
|
||||||
|
|
||||||
#{license}
|
|
||||||
|
|
||||||
script = File.join(File.dirname(__FILE__), ".propane-#{VERSION}-#{hash}.rb")
|
|
||||||
unless File.exist?(script)
|
|
||||||
if File.read(__FILE__, mode: "rb") =~ /^#==>(.*)/
|
|
||||||
require "zlib"
|
|
||||||
require "base64"
|
|
||||||
encoded_compressed = $1
|
|
||||||
unescaped_compressed = Base64.decode64(encoded_compressed)
|
|
||||||
inflated = Zlib::Inflate.inflate(unescaped_compressed)
|
|
||||||
File.open(script, "wb") do |fh|
|
|
||||||
fh.write(inflated)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise "Could not decompress."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
load script
|
|
||||||
if __FILE__ == $0
|
|
||||||
Propane::CLI.new.run(ARGV)
|
|
||||||
end
|
|
||||||
#==>#{encoded_compressed_script}
|
|
||||||
EOF
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user