Sha256: 1df01c1b0055b2bd21e77d4763cfb534fd6a336c991dfad8dc8755d1b2e245e5
Contents?: true
Size: 1.17 KB
Versions: 8
Compression:
Stored size: 1.17 KB
Contents
class Fanforce::CLI::Plugin attr_reader :_id, :dir, :dir_name, :dir_root, :root_domain, :name def self.parse_dir_name(dir_name) return if dir_name !~ /^(plugin-([a-z0-9-]+))\/?$/ {_id: $2, dir_name: $1} end def self.load(dir); self.new(dir) end ###################################################################################################################### def initialize(dir) raise "This is an invalid directory name for a fanforce addon: #{dir}" if dir !~ /^(.*)\/([a-z0-9-]+)\/?$/ @_id = $2 @dir = "#{$1}/#{$2}" @dir_root = $1 @dir_name = $2 @dir_relative = @dir.gsub(Fanforce::CLI::DIR, '') @root_domain = Fanforce.plugins_base_domain @name = @_id.gsub('-', ' ').titleize end def config @config ||= begin file_path = "#{@dir}/config.json" return {} if !File.exists?(file_path) file = File.open(file_path).read MultiJson.load(file, symbolize_keys: true) end end def to_hash { _id: @_id, name: @name, dir_name: @dir_name, dir_root: @dir_root, dir: @dir } end def to_json to_hash.to_json end end
Version data entries
8 entries across 8 versions & 1 rubygems