Class: Pandan::Query
- Defined in:
- lib/pandan/command/query.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Query
constructor
A new instance of Query.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Query
Returns a new instance of Query.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pandan/command/query.rb', line 28 def initialize(argv) @target = argv.shift_argument @xcworkspace = argv.option('xcworkspace') @xcworkspace ||= XCWorkspace.find_workspace @reverse = argv.flag?('reverse') @implicit_deps = argv.flag?('implicit-dependencies') @comma_separated = argv.flag?('comma-separated') @filter = argv.option('filter') @filter ||= '.*' # Match everything super end |
Class Method Details
.options ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/pandan/command/query.rb', line 14 def self. [ ['--xcworkspace=path/to/workspace', 'If not set, Pandan will try to find a workspace'], ['--reverse', 'If set, pandan will output the targets that depend on the argument'], ['--implicit-dependencies', 'If set, pandan will look up for linker flags in all build configurations'], ['--comma-separated', 'If set, Pandan outputs a comma-separated list instead of multiple lines'], ['--filter=expression', 'If set, pandan will select all targets whose name match the regular expression'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pandan/command/query.rb', line 47 def run parser = Parser.new(@xcworkspace, @filter) graph = Graph.new(@reverse) targets = parser.all_targets graph.add_target_info(targets) if @implicit_deps ld_flags_info = parser.other_linker_flags graph.add_other_ld_flags_info(ld_flags_info) end deps = graph.resolve_dependencies(@target).map(&:name) deps.select! do |dep| dep =~ /#{@filter}/ end if @comma_separated puts deps.join ',' else puts deps end end |
#validate! ⇒ Object
40 41 42 43 44 45 |
# File 'lib/pandan/command/query.rb', line 40 def validate! super help! 'A target is required to retrieve the dependency information' unless @target help! 'Could not find the workspace. Try setting it manually using the --xcworkspace option.' unless @xcworkspace end |