Module: Ronin::Model::TargetsOS::ClassMethods

Defined in:
lib/ronin/model/targets_os.rb

Instance Method Summary collapse

Instance Method Details

#targeting_os(os, version = nil) ⇒ DataMapper::Collection

Queries all resources targeting a specific Operating System.

Parameters:

  • os (OS, Hash, Symbol, #to_s)

    The Operating System to search for.

  • version (String) (defaults to: nil)

    Optional version of the Operating System.

Returns:

  • (DataMapper::Collection)

    The matching resources.

Since:

  • 1.0.0


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ronin/model/targets_os.rb', line 63

def targeting_os(os,version=nil)
  conditions = case os
               when OS, Hash
                 {os: os}
               when Symbol
                 unless License.methods(false).include?(os)
                   raise(ArgumentError,"unknown OS: #{os}")
                 end

                 {os: OS.send(os)}
               else
                 if version
                   {'os.name' => os.to_s, 'os.version' => version.to_s}
                 else
                   {'os.name' => os.to_s}
                 end
               end

  all(conditions)
end