liorviz (owner)

Fork Of

gist: 9310 by davidwp... rspec ubiquity search

Revisions

gist: 169036 Download_button fork
public
Description:
updated to API V.2 Ubiquity V.5.x
Public Clone URL: git://gist.github.com/169036.git
Embed All Files: show embed
rspec-search.ubiquity-command.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
CmdUtils.CreateCommand(
            {
                name: ['rspec'],
                arguments: [{role: 'object', nountype: noun_arb_text, label: 'function'}],
                icon: "http://ruby-doc.org/favicon.ico",
                homepage: "http://davidwparker.com",
                author: {name: "Jack Dempsey, fork by muni", email: "2bmuni@gmail.com"},
                license: "MPL,GPL",
                description: "Search rspec functions documentation",
                help: "Select a rspec function",
                execute: function(args)
                {
                    var url = "http://apidock.com/rspec/search?query={QUERY}&commit=Search"
                    var urlString = url.replace("{QUERY}", args.object.text);
                    Utils.openUrlInBrowser(urlString);
                },
                preview: function(pblock, args)
                {
                    searchText = jQuery.trim(args.object.text);
                    if(searchText.length <= 0)
                    {
                      pblock.innerHTML = "Search rspec function documentation";
                      return;
                    }
                    var previewTemplate = "Search rspec function documentation of ${query}";
                    var previewData = {query: searchText};
                    pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
                }
            });