Class: Appifier::Components::Dataset

Inherits:
Object
  • Object
show all
Extended by:
Carioca::Injector
Defined in:
lib/appifier/components/dataset.rb

Class Method Summary collapse

Class Method Details

.listObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/appifier/components/dataset.rb', line 9

def self.list
    output.info "List of available Datasets for user : #{current_user} :"
    templates_path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
    datasets_path = File.expand_path(Appifier::DEFAULT_DATASETS_PATH)
    templates = Dir.glob("#{templates_path}/*").map { |item| item.delete_prefix("#{templates_path}/") }
    Dir.glob("#{datasets_path}/*").map { |item| item.delete_prefix("#{datasets_path}/") }.each do |file|
        dataset = File::basename(file,'.yml')
        res = dataset; res << " [TEMPLATE MISSING]" unless templates.include? dataset 
        output.item res
    end
end

.pruneObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/appifier/components/dataset.rb', line 22

def self.prune
    output.info "Pruning Datasets for user : #{current_user} :"
    templates_path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
    datasets_path = File.expand_path(Appifier::DEFAULT_DATASETS_PATH)
    templates = Dir.glob("#{templates_path}/*").map { |item| item.delete_prefix("#{templates_path}/") }
    Dir.glob("#{datasets_path}/*").each do |file|
        dataset = File::basename(file,'.yml')
        unless templates.include? dataset 
            FileUtils::rm file 
            output.item "Pruned : #{dataset}"
        end
    end
end

.rm(dataset) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/appifier/components/dataset.rb', line 41

def self.rm(dataset)
    output.info "Removing dataset #{dataset} for user : #{current_user}"
    dataset_path = File.expand_path(Appifier::DEFAULT_DATASETS_PATH)
    begin
    if File::exist? "#{dataset_path}/#{dataset}.yml"
        FileUtils.rm_rf "#{dataset_path}/#{dataset}.yml"
        output.ok "Dataset #{dataset} deleted of bundle for user #{current_user}"
    else
        raise "Dataset #{dataset} not found in bundle for user #{current_user}"
    end
    rescue Errno::ENOENT
        raise "Dataset #{dataset} not found in bundle for user #{current_user}"
    end
end

.show(dataset) ⇒ Object



37
38
39
# File 'lib/appifier/components/dataset.rb', line 37

def self.show(dataset)
    raise "Not yet Implemented"
end