Skip to content

Commit 46cc998

Browse files
authored
Merge pull request #8 from coatless/feature/add-ixsearch
Added search portal `search_ixquick()` (close #6)
2 parents 943438d + 071b136 commit 46cc998

File tree

6 files changed

+135
-4
lines changed

6 files changed

+135
-4
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export(search_duckduckgo)
88
export(search_gh)
99
export(search_github)
1010
export(search_google)
11+
export(search_ixquick)
1112
export(search_site)
1213
export(search_so)
1314
export(search_stackoverflow)

NEWS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
# searcher 0.0.3
2+
3+
## Features
4+
5+
- Added search portal `search_ixquick()`: Searches with [ixquick](https://www.ixquick.com/). (#6)
6+
7+
## Changes
8+
9+
- Add `ixquick` as a valid engine to `search_site()`. (#6)
10+
- Included link to repository and bug tracker to `DESCRIPTION`.
11+
112
# searcher 0.0.2
213

14+
## Features
15+
316
- Added search portal functions
417
- `search_site()`: Looks up search portal and _then_ searches with it.
518
- `search_google()`: Searches with [Google](https://google.com/)
@@ -10,5 +23,8 @@
1023
- `search_stackoverflow()` or `search_so()`: Searches questions on [StackOverflow](https://stackoverflow.com/)
1124
- Add function generator `searcher()` to create function objects that can be
1225
used as error handlers in `option(error = )` and task call-backs.
26+
27+
## UX
28+
1329
- Created a `browse_url()` that checks to see if it is in interactive mode before
1430
trying to open a web browser 0.5 seconds after call.

R/search-functions.R

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#' # Search DuckDuckGo
2929
#' search_duckduckgo("R language")
3030
#'
31+
#' # Search ixquick
32+
#' search_ixquick("RStudio IDE")
33+
#'
3134
#' # Search StackOverflow for Convolutions in the r tag
3235
#' search_stackoverflow("convolutions")
3336
#'
@@ -59,7 +62,8 @@ search_site = function(query,
5962
"duckduckgo",
6063
"ddg",
6164
"bitbucket",
62-
"bb"
65+
"bb",
66+
"ixquick"
6367
),
6468
rlang = TRUE) {
6569
site = tolower(site)
@@ -81,6 +85,7 @@ search_site = function(query,
8185
duckduckgo = ,
8286
# empty case carried below
8387
ddg = search_duckduckgo(query),
88+
ixquick = search_ixquick(query),
8489
search_google(query)
8590
)
8691
}
@@ -122,14 +127,18 @@ searcher = function(site = c(
122127
"duckduckgo",
123128
"stackoverflow",
124129
"github",
125-
"bitbucket"
130+
"bitbucket",
131+
"ixquick"
126132
),
127133
rlang = TRUE) {
128134
function(query = geterrmessage()) {
129135
search_site(query, site, rlang = rlang)
130136
}
131137
}
132138

139+
140+
########################### Start Search Engines
141+
133142
#' @rdname search_site
134143
#' @export
135144
#' @section Google Search:
@@ -179,6 +188,31 @@ search_duckduckgo = function(query = geterrmessage()) {
179188
#' @export
180189
search_ddg = search_duckduckgo
181190

191+
192+
#' @rdname search_site
193+
#' @export
194+
#' @section ixquick Search:
195+
#' The `search_ixquick()` function searches
196+
#' [ixquick](https://ixquick.com) using:
197+
#' \code{https://ixquick.com/do/dsearch?query=<query>}
198+
#'
199+
#' For additional details regarding [ixquick](https://ixquick.com)'s
200+
#' search interface please see:
201+
#' \url{https://support.ixquick.com/index.php?/Knowledgebase/Article/View/201/0/how-do-i-make-startpage-by-ixquick-my-default-search-engine-in-chrome}
202+
search_ixquick = function(query = geterrmessage()) {
203+
if (!valid_query(query)) {
204+
message("Please provide only 1 `query` term that is not empty.")
205+
return(invisible(""))
206+
}
207+
208+
browse_url("https://ixquick.com/do/dsearch?query=", query)
209+
}
210+
211+
########################### End Search Engines
212+
213+
214+
########################### Start Search Code Repos
215+
182216
#' @rdname search_site
183217
#' @export
184218
#' @section StackOverflow Search:
@@ -262,3 +296,5 @@ search_bitbucket = function(query = geterrmessage(), rlang = TRUE) {
262296
#' @rdname search_site
263297
#' @export
264298
search_bb = search_bitbucket
299+
300+
########################### End Search Code Repos

man/search_site.Rd

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/searcher.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-searcher.R

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ test_that("Check link generation", {
2323
"https://duckduckgo.com/?q=toad"
2424
)
2525

26+
##### ixquick
27+
28+
expect_identical(
29+
search_ixquick("toad"),
30+
"https://ixquick.com/do/dsearch?query=toad"
31+
)
32+
2633
##### StackOverflow
2734

2835
expect_identical(
@@ -61,14 +68,68 @@ test_that("Check link generation", {
6168

6269
})
6370

71+
test_that("Validate selection", {
72+
73+
expect_identical(
74+
search_site("toad", "bb", rlang = FALSE),
75+
"https://bitbucket.com/search?q=toad"
76+
)
77+
78+
expect_identical(
79+
search_site("", rlang = FALSE),
80+
"",
81+
"Verify empty query fall through"
82+
)
83+
84+
})
85+
6486

6587
test_that("Malformed search query validation", {
88+
6689
expect_identical(
6790
search_google(""),
6891
"",
6992
"Empty string check if no error messages"
7093
)
7194

95+
96+
expect_identical(
97+
search_bing(""),
98+
"",
99+
"Empty string check if no error messages"
100+
)
101+
102+
103+
expect_identical(
104+
search_ddg(""),
105+
"",
106+
"Empty string check if no error messages"
107+
)
108+
109+
expect_identical(
110+
search_ixquick(""),
111+
"",
112+
"Empty string check if no error messages"
113+
)
114+
115+
expect_identical(
116+
search_so(""),
117+
"",
118+
"Empty string check if no error messages"
119+
)
120+
121+
expect_identical(
122+
search_gh(""),
123+
"",
124+
"Empty string check if no error messages"
125+
)
126+
127+
expect_identical(
128+
search_bb(""),
129+
"",
130+
"Empty string check if no error messages"
131+
)
132+
72133
expect_identical(
73134
search_google(NULL),
74135
"",

0 commit comments

Comments
 (0)