Top Level Namespace

Defined Under Namespace

Modules: Soulmate

Instance Method Summary collapse

Instance Method Details

#add(type) ⇒ Object


49
50
51
52
53
54
55
56
57
# File 'bin/soulmate', line 49

def add(type)
  puts "Adding items of type #{type}..."
  loader = Soulmate::Loader.new(type)
  items = $stdin.read.split("\n").map { |l| MultiJson.decode(l) }
  items.each do |item|
    loader.add(item)
  end
  puts "Loaded a total of #{items.size} items"
end

#load(type) ⇒ Object


42
43
44
45
46
47
# File 'bin/soulmate', line 42

def load(type)
  puts "Loading items of type #{type}..."
  items = $stdin.read.split("\n").map { |l| MultiJson.decode(l) }
  loaded = Soulmate::Loader.new(type).load(items)
  puts "Loaded a total of #{loaded.size} items"
end

#query(type, query) ⇒ Object


69
70
71
72
73
74
75
76
77
# File 'bin/soulmate', line 69

def query(type, query)
  puts "> Querying '#{type}' for '#{query}'"
  matcher = Soulmate::Matcher.new(type)
  results = matcher.matches_for_term(query, :limit => 0)
  results.each do |item|
    puts MultiJson.encode(item)
  end
  puts "> Found #{results.size} matches"
end

#remove(type) ⇒ Object


59
60
61
62
63
64
65
66
67
# File 'bin/soulmate', line 59

def remove(type)
  puts "Removing items of type #{type}..."
  loader = Soulmate::Loader.new(type)
  items = $stdin.read.split("\n").map { |l| MultiJson.decode(l) }
  items.each do |item|
    loader.remove(item)
  end
  puts "Removed a total of #{items.size} items"
end