lib/discourse_theme/uploader.rb in discourse_theme-0.3.2 vs lib/discourse_theme/uploader.rb in discourse_theme-0.3.3
- old
+ new
@@ -1,14 +1,15 @@
module DiscourseTheme
class Uploader
THEME_CREATOR_REGEX = /^https:\/\/theme-creator.discourse.org$/i
- def initialize(dir:, client:, theme_id: nil)
+ def initialize(dir:, client:, theme_id: nil, components: nil)
@dir = dir
@client = client
@theme_id = theme_id
+ @components = components
end
def compress_dir(gzip, dir)
sgz = Zlib::GzipWriter.new(File.open(gzip, 'wb'))
tar = Archive::Tar::Minitar::Output.new(sgz)
@@ -64,10 +65,10 @@
def upload_full_theme
filename = "#{Pathname.new(Dir.tmpdir).realpath}/bundle_#{SecureRandom.hex}.tar.gz"
compress_dir(filename, @dir)
File.open(filename) do |tgz|
- response = @client.upload_full_theme(tgz, theme_id: @theme_id)
+ response = @client.upload_full_theme(tgz, theme_id: @theme_id, components: @components)
json = JSON.parse(response.body)
@theme_id = json["theme"]["id"]
if diagnose_errors(json) != 0
Cli.error "(end of errors)"