Class: Pod::Command::Query
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::Query
- Defined in:
- lib/pod/command/query.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Query
constructor
A new instance of Query.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Query
Returns a new instance of Query.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pod/command/query.rb', line 44 def initialize(argv) super @name = argv.option('name') @version = argv.option('version') @author_email = argv.option('author-email') @author_name = argv.option('author-name') @summary = argv.option('summary') @description = argv.option('description') @source_file = argv.option('source-file') @swift = argv.flag?('swift') @local = argv.flag?('local') @case_insensitive = argv.flag?('case-insensitive', false) @substring = argv.flag?('substring', false) @to_yaml = argv.option('to-yaml') @to_json = argv.option('to-json') @cache = argv.option('cache') end |
Class Method Details
.options ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pod/command/query.rb', line 25 def self. [ ['--name=NAME', 'Include pods whose name matches the given string'], ['--version=VERSION', 'Include pods whose version matches the given string'], ['--author-email=EMAIL', 'Include pods having at least one author with the given email'], ['--author-name=NAME', 'Include pods having at least one author of the given name'], ['--summary=SUMMARY', 'Include pods whose summary matches the given string'], ['--description=DESCRIPTION', 'Include pods whose description matches the given string'], ['--source-file=FILE', 'Include pods whose source list includes the given file name'], ['--swift', 'Only include pods that use Swift (--no-swift for only pods that do not)'], ['--local', 'Only include locally sourced pods (--no-local for only remote pods)'], ['--case-insensitive', 'Don\'t consider case when matching strings'], ['--substring', 'Allow substring matching for string parameters'], ['--to-yaml=FILE', 'Output the results in YAML format with additional Podspec data (authors, source files, dependencies, etc.) to the given file'], ['--to-json=FILE', 'Output the results in JSON format with additional Podspec data (authors, source files, dependencies, etc.) to the given file'], ['--cache=FILE', 'Load the sandbox data from the given YAML file (created previously with the --to-yaml parameter) instead of from the current sandbox instance'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/pod/command/query.rb', line 62 def run UI.puts 'Loading targets...' matching_targets = all_targets(@cache).select do |target| (@name.nil? || str_match(@name, target[:name])) && (@version.nil? || str_match(@version, target[:version])) && (@author_name.nil? || target[:authors].any? { || ![:name].nil? && str_match(@author_name, [:name]) }) && (@author_email.nil? || target[:authors].any? { || ![:email].nil? && str_match(@author_email, [:email]) }) && (@summary.nil? || str_match(@summary, target[:summary])) && (@description.nil? || str_match(@description, target[:description])) && (@source_file.nil? || target[:source_files].nil? || target[:source_files].any? { |s| str_match(@source_file, s) }) && (@swift.nil? || @swift == target[:uses_swift]) && (@local.nil? || @local == target[:local]) end File.open(@to_yaml, 'w') { |file| file.write(matching_targets.to_yaml) } if @to_yaml File.open(@to_json, 'w') { |file| file.write(matching_targets.to_json) } if @to_json matching_targets.each { |target| UI.puts target[:name] } end |