Module: Pod::Command::PluginsHelper
- Defined in:
- lib/pod/command/plugins_helper.rb
Overview
This module is used by Command::Plugins::List and Command::Plugins::Search to download and parse the JSON describing the plugins list and manipulate it
Constant Summary collapse
- PLUGINS_JSON_REPO_NAME =
'CocoaPods/cocoapods-plugins'
- PLUGINS_JSON_REPO =
'https://github.com/' + PLUGINS_JSON_REPO_NAME
- PLUGINS_JSON_REL_URL =
'/master/plugins.json'
- PLUGINS_RAW_URL =
'https://raw.githubusercontent.com/' \ + PLUGINS_JSON_REPO_NAME + PLUGINS_JSON_REL_URL
Class Method Summary collapse
-
.download_json ⇒ Hash
Force-download the JSON.
-
.known_plugins ⇒ Array
The list of all known plugins, according to the JSON hosted on github’s cocoapods-plugins.
-
.matching_plugins(query, full_text_search) ⇒ Array
Filter plugins to return only matching ones.
-
.print_plugin(plugin, verbose = false) ⇒ Object
Display information about a plugin.
Class Method Details
.download_json ⇒ Hash
Force-download the JSON
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pod/command/plugins_helper.rb', line 21 def self.download_json UI.puts 'Downloading Plugins list...' response = REST.get(PLUGINS_RAW_URL) if response.ok? parse_json(response.body) else raise Informative, 'Could not download plugins list ' \ "from cocoapods-plugins: #{response.inspect}" end end |
.known_plugins ⇒ Array
The list of all known plugins, according to the JSON hosted on github’s cocoapods-plugins
37 38 39 40 |
# File 'lib/pod/command/plugins_helper.rb', line 37 def self.known_plugins json = download_json json['plugins'] end |
.matching_plugins(query, full_text_search) ⇒ Array
Filter plugins to return only matching ones
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pod/command/plugins_helper.rb', line 53 def self.matching_plugins(query, full_text_search) query_regexp = /#{query}/i known_plugins.reject do |plugin| texts = [plugin['name']] if full_text_search texts << plugin['author'] if plugin['author'] texts << plugin['description'] if plugin['description'] end texts.grep(query_regexp).empty? end end |
.print_plugin(plugin, verbose = false) ⇒ Object
Display information about a plugin
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/pod/command/plugins_helper.rb', line 74 def self.print_plugin(plugin, verbose = false) plugin_colored_name = plugin_title(plugin) UI.title(plugin_colored_name, '', 1) do UI.puts_indented plugin['description'] ljust = verbose ? 16 : 11 UI.labeled('Gem', plugin['gem'], ljust) UI.labeled('URL', plugin['url'], ljust) print_verbose_plugin(plugin, ljust) if verbose end end |