Class: SafariBookmarksParser::Commands::DupsCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/safari_bookmarks_parser/commands/dups_command.rb

Instance Attribute Summary collapse

Attributes inherited from BaseCommand

#output_format, #output_path, #plist_path

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ DupsCommand

Returns a new instance of DupsCommand.



8
9
10
11
12
# File 'lib/safari_bookmarks_parser/commands/dups_command.rb', line 8

def initialize(argv)
  @exclude_reading_list = false

  super
end

Instance Attribute Details

#exclude_reading_listObject (readonly)

Returns the value of attribute exclude_reading_list.



6
7
8
# File 'lib/safari_bookmarks_parser/commands/dups_command.rb', line 6

def exclude_reading_list
  @exclude_reading_list
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/safari_bookmarks_parser/commands/dups_command.rb', line 14

def run
  plist_parser = Parser.parse(@plist_path)

  bookmarks = bookmarks_to_process(plist_parser).to_a

  duplicated_bookmark_groups = Services::FindDuplicatedBookmarks.call(bookmarks: bookmarks)

  return if duplicated_bookmark_groups.empty?

  duplicated_bookmark_groups = duplicated_bookmark_groups.map do |group|
    group.map(&:to_h)
  end

  text = format_to_text(duplicated_bookmark_groups)

  output_text(text)
end