diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-07-19 18:00:54 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-07-19 18:00:54 -0400 |
commit | 0b9227f43d4803ad183789f484006247573a3439 (patch) | |
tree | 681cf2ee170db12e293b2e775b7127425e8301d7 | |
parent | 28ea5cdfd9676ba090eb84a77933559bd4a427a0 (diff) | |
download | guff-0b9227f43d4803ad183789f484006247573a3439.tar.bz2 guff-0b9227f43d4803ad183789f484006247573a3439.zip |
refactor theme into packer and installer
-rw-r--r-- | src/guff/cli.cr | 2 | ||||
-rw-r--r-- | src/guff/theme/installer/file-info.cr | 7 | ||||
-rw-r--r-- | src/guff/theme/installer/manifest.cr | 19 | ||||
-rw-r--r-- | src/guff/theme/packer/file-info.cr (renamed from src/guff/theme/file-info.cr) | 2 | ||||
-rw-r--r-- | src/guff/theme/packer/manifest.cr (renamed from src/guff/theme/source-manifest.cr) | 4 |
5 files changed, 30 insertions, 4 deletions
diff --git a/src/guff/cli.cr b/src/guff/cli.cr index 15ff5a4..600f5d4 100644 --- a/src/guff/cli.cr +++ b/src/guff/cli.cr @@ -112,7 +112,7 @@ module Guff::CLI class ThemePackAction < Action def run - Theme::SourceManifest.save( + Theme::Packer::Manifest.save( src_dir: @config.theme_src_dir.not_nil!, dst_path: @config.theme_dst_path.not_nil!, ) diff --git a/src/guff/theme/installer/file-info.cr b/src/guff/theme/installer/file-info.cr new file mode 100644 index 0000000..dfbd9d8 --- /dev/null +++ b/src/guff/theme/installer/file-info.cr @@ -0,0 +1,7 @@ +class Guff::Theme::Installer::FileInfo + JSON.mapping( + name: String, + size: Int64, + hash: String, + ) +end diff --git a/src/guff/theme/installer/manifest.cr b/src/guff/theme/installer/manifest.cr new file mode 100644 index 0000000..5e7e07f --- /dev/null +++ b/src/guff/theme/installer/manifest.cr @@ -0,0 +1,19 @@ +class Guff::Theme::Installer::Manifest + JSON.mapping( + format: Int32, + metadata: Hash(String, String), + files: Array(FileInfo), + assets: Assets, + templates: Hash(String, String), + ) + + def self.load(zip_path : String) : Manifest + json = "" + Zip::Archive.open(zip_path) do |zip| + json = zip.read("guff-manifest.json") + end + + # return result + from_json(json) + end +end diff --git a/src/guff/theme/file-info.cr b/src/guff/theme/packer/file-info.cr index 768d625..c274f01 100644 --- a/src/guff/theme/file-info.cr +++ b/src/guff/theme/packer/file-info.cr @@ -1,4 +1,4 @@ -class Guff::Theme::FileInfo +class Guff::Theme::Packer::FileInfo getter :size, :hash def initialize(src_dir : String, @path : String) diff --git a/src/guff/theme/source-manifest.cr b/src/guff/theme/packer/manifest.cr index bfa3486..21fbda7 100644 --- a/src/guff/theme/source-manifest.cr +++ b/src/guff/theme/packer/manifest.cr @@ -1,4 +1,4 @@ -class Guff::Theme::SourceManifest +class Guff::Theme::Packer::Manifest getter :format, :metadata, :assets JSON.mapping( @@ -17,7 +17,7 @@ class Guff::Theme::SourceManifest load(src_dir).save(dst_path, src_dir) end - def self.load(src_dir : String) : SourceManifest + def self.load(src_dir : String) : Manifest r = from_json(File.read(File.join(src_dir, "guff-manifest.json"))) # check format version |