Class: Plum::ThemePackageInstaller
- Inherits:
-
Object
- Object
- Plum::ThemePackageInstaller
- Defined in:
- app/services/plum/theme_package_installer.rb
Defined Under Namespace
Classes: PackageEntry
Constant Summary collapse
- HANDLE_PATTERN =
/\A[a-z0-9][a-z0-9-]*\z/- SETTING_HANDLE_PATTERN =
/\A[a-z][a-z0-9_]*\z/
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
-
#initialize(package, install_root: nil) ⇒ ThemePackageInstaller
constructor
A new instance of ThemePackageInstaller.
- #install ⇒ Object
Constructor Details
#initialize(package, install_root: nil) ⇒ ThemePackageInstaller
Returns a new instance of ThemePackageInstaller.
15 16 17 18 19 20 |
# File 'app/services/plum/theme_package_installer.rb', line 15 def initialize(package, install_root: nil) @package = package @install_root = Pathname(install_root || default_install_root) @errors = [] @theme = nil end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
13 14 15 |
# File 'app/services/plum/theme_package_installer.rb', line 13 def errors @errors end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
13 14 15 |
# File 'app/services/plum/theme_package_installer.rb', line 13 def theme @theme end |
Instance Method Details
#install ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/services/plum/theme_package_installer.rb', line 22 def install errors.clear with_zip_entries do |entries| manifest = load_manifest(entries) next false if errors.any? handle = validate_manifest(manifest) validate_renderable_files(entries) validate_screenshot(manifest, entries) validate_settings(manifest) next false if errors.any? target_root = validate_target(handle) next false if errors.any? extract_entries(entries, target_root) @theme = Theme.new(root: target_root, manifest: manifest) true end end |