Module: TinkitFileSystemViews

Defined in:
lib/glue_envs/filesystem_glue_env.rb

Overview

class ViewsMgr

Constant Summary collapse

@@log =

Set Logger

TinkitLog.set(self.name, :warn)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#model_actorObject

Dependency on TinkitInfoDocEnvMethods



12
13
14
# File 'lib/glue_envs/filesystem_glue_env.rb', line 12

def model_actor
  @model_actor
end

Class Method Details

.by_my_category(moab_data, user_datastore_location, match_keys) ⇒ Object

TODO create an index to speed queries? sync issues?



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/glue_envs/filesystem_glue_env.rb', line 22

def self.by_my_category(moab_data, user_datastore_location, match_keys)
  data_file = moab_data[:moab_datastore_name]
  #raise "nt: #{nodetest.my_category.inspect}" if nodetest
  #raise "No category provided for search" unless my_cat
  #puts "Searching for #{my_cat.inspect}"
  match_keys = [match_keys].flatten
  my_dir = user_datastore_location
  bfss = nil
  match_keys.each do |match_key|
    my_cat_dir = match_key
    wkg_dir = File.join(my_dir, my_cat_dir)
    if File.exists?(wkg_dir)
	bfss = bfss || []
	data_file_path = File.join(wkg_dir, data_file)
	node_data  = JSON.parse(File.open(data_file_path){|f| f.read})
	#bfs = self.new(node_data)
	bfss << node_data #bfs
    end
    #return bfss   #returned as an array for compatibility with other search and node types
  #else
  #  puts "Warning: #{wkg_dir.inspect} was not found"
  #  return nil
  end
  return bfss
end

.by_parent_categories(moab_data, user_datastore_location, match_keys) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/glue_envs/filesystem_glue_env.rb', line 48

def self.by_parent_categories(moab_data, user_datastore_location, match_keys)
  data_file = moab_data[:moab_datastore_name]
  match_keys = [match_keys].flatten
  #all_nodes = all collection method when all is moved into here
  matching_node_data = []
  all_wkg_entries = Dir.working_entries(user_datastore_location)
  all_wkg_entries.each do |entry|
    wkg_dir = File.join(user_datastore_location, entry)
    if File.exists?(wkg_dir)
     data_file_path = File.join(wkg_dir, data_file)
     json_data  = JSON.parse(File.open(data_file_path){|f| f.read})
     node_data = HashKeys.str_to_sym(json_data)
       match_keys.each do |k|
       pc = node_data[:parent_categories]
       if pc && pc.include?(k)
         matching_node_data << node_data
         break  #we don't need to loop through each parent cat, if one already matches
       end
      end
    end
  end
  #we now have all mathcing data
  return matching_node_data
end