curlyq 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cfa73d5ba1b30f6b49b593c65306034ea6ce4e93d9d306e5a535009583f45638
4
- data.tar.gz: 76f451e89e6d9f5c3ffe3c1fb87621e1e90fec91ec259fa1d513d8fc6ddd5d40
3
+ metadata.gz: 38b735c7b0ead432ad659482e59c4e9385e82fc71063eedda37440dac537e211
4
+ data.tar.gz: f3337ceb067ec0460c8d5ad6fee7b1d088ac07ba15833f550b5b6ea19afc9e4c
5
5
  SHA512:
6
- metadata.gz: 5cb5c0aa1e5907a524328e3931cb01a501b9a49b36ddc45388e97a115c81c58e16b05c99dffc95870e47eab5ff81db9af809f4d962f8e33ae42a0c90c0bc7d55
7
- data.tar.gz: da161b3b81821bfc6c09615c66927905d1a4f590879613aba0ed526015f06c281c372528ed597c488afd7933ab78c116247ab5545c29099e160e2e49293af90f
6
+ metadata.gz: ac88bdf60364d157efbefdaa425c8467bd93a65d70ff884f9a6322172a6b3d1858f474eb2ebf30708a9bef18deb8a0cba6358e46e7c9c5af6f9ff80099461701
7
+ data.tar.gz: e2b2894bd450158aba7f62f778a34ac29958a3eef25d13db0b3b37b539165f00d2ea39515be57eb169ba7af93a602f06af6a7dc4d768201c9c5a90ad949580ab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ### 0.0.16
2
+
3
+ 2024-11-07 06:45
4
+
5
+ #### FIXED
6
+
7
+ - Encoding error
8
+
9
+ ### 0.0.15
10
+
11
+ 2024-10-25 10:31
12
+
13
+ #### IMPROVED
14
+
15
+ - Better error when no results, return nothing to STDOUT
16
+
1
17
  ### 0.0.14
2
18
 
3
19
  2024-10-25 10:26
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- curlyq (0.0.14)
4
+ curlyq (0.0.16)
5
5
  gli (~> 2.21.0)
6
6
  nokogiri (~> 1.16.0)
7
7
  selenium-webdriver (~> 4.16.0)
@@ -13,16 +13,16 @@ GEM
13
13
  gli (2.21.5)
14
14
  nokogiri (1.16.7-arm64-darwin)
15
15
  racc (~> 1.4)
16
- parallel (1.23.0)
16
+ parallel (1.26.3)
17
17
  parallel_tests (3.13.0)
18
18
  parallel
19
19
  pastel (0.8.0)
20
20
  tty-color (~> 0.5)
21
- power_assert (2.0.3)
21
+ power_assert (2.0.4)
22
22
  racc (1.8.1)
23
- rake (13.1.0)
24
- rdoc (6.3.3)
25
- rexml (3.3.7)
23
+ rake (13.2.1)
24
+ rdoc (6.3.4.1)
25
+ rexml (3.3.9)
26
26
  rubyzip (2.3.2)
27
27
  selenium-webdriver (4.16.0)
28
28
  rexml (~> 3.2, >= 3.2.5)
@@ -42,12 +42,13 @@ GEM
42
42
  tty-spinner (0.9.3)
43
43
  tty-cursor (~> 0.7)
44
44
  tty-which (0.5.0)
45
- unicode-display_width (2.5.0)
46
- websocket (1.2.10)
47
- yard (0.9.34)
45
+ unicode-display_width (2.6.0)
46
+ websocket (1.2.11)
47
+ yard (0.9.37)
48
48
 
49
49
  PLATFORMS
50
50
  arm64-darwin-20
51
+ x86_64-darwin-20
51
52
 
52
53
  DEPENDENCIES
53
54
  curlyq!
data/README.md CHANGED
@@ -13,7 +13,7 @@ _If you find this useful, feel free to [buy me some coffee][donate]._
13
13
  [jq]: https://github.com/jqlang/jq "Command-line JSON processor"
14
14
  [yq]: https://github.com/mikefarah/yq "yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor"
15
15
 
16
- The current version of `curlyq` is 0.0.14.
16
+ The current version of `curlyq` is 0.0.16.
17
17
 
18
18
  CurlyQ is a utility that provides a simple interface for curl, with additional features for things like extracting images and links, finding elements by CSS selector or XPath, getting detailed header info, and more. It's designed to be part of a scripting pipeline, outputting everything as structured data (JSON or YAML). It also has rudimentary support for making calls to JSON endpoints easier, but it's expected that you'll use something like [jq] to parse the output.
19
19
 
@@ -46,7 +46,7 @@ SYNOPSIS
46
46
  curlyq [global options] command [command options] [arguments...]
47
47
 
48
48
  VERSION
49
- 0.0.14
49
+ 0.0.16
50
50
 
51
51
  GLOBAL OPTIONS
52
52
  --help - Show this message
data/bin/curlyq CHANGED
@@ -149,10 +149,7 @@ command %i[html curl] do |c|
149
149
  output.delete_if(&:nil?)
150
150
  output.delete_if(&:empty?)
151
151
 
152
- if output.nil? || output.empty?
153
- print_out([], global_options[:yaml], raw: options[:raw], pretty: global_options[:pretty])
154
- Process.exit 1
155
- end
152
+ exit_now!('No results') if output.nil? || output.empty?
156
153
 
157
154
  output.map! { |o| o[options[:raw].to_sym] } if options[:raw]
158
155
 
@@ -492,10 +489,7 @@ command :images do |c|
492
489
  end
493
490
  end
494
491
 
495
- if output.nil? || output.empty?
496
- print_out([], global_options[:yaml], raw: options[:raw], pretty: global_options[:pretty])
497
- Process.exit 1
498
- end
492
+ exit_now!('No results') if output.nil? || output.empty?
499
493
 
500
494
  print_out(output, global_options[:yaml], pretty: global_options[:pretty])
501
495
  end
@@ -731,10 +731,11 @@ module Curl
731
731
  ]
732
732
  headers = @headers.nil? ? '' : @headers.map { |h, v| %(-H "#{h}: #{v}") }.join(' ')
733
733
  compress = @compressed ? '--compressed' : ''
734
- @source = `#{@curl} -#{flags} #{compress} #{headers} '#{@url}' 2>/dev/null`
734
+ @source = `#{@curl} -#{flags} #{compress} #{headers} '#{@url}' 2>/dev/null`.strip.utf8
735
735
  agent = 0
736
+
736
737
  while @source.nil? || @source.empty?
737
- @source = `#{@curl} -#{flags} #{compress} -A "#{agents[agent]}" #{headers} '#{@url}' 2>/dev/null`
738
+ @source = `#{@curl} -#{flags} #{compress} -A "#{agents[agent]}" #{headers} '#{@url}' 2>/dev/null`.strip.utf8
738
739
  break if agent >= agents.count - 1
739
740
  end
740
741
 
data/lib/curly/string.rb CHANGED
@@ -6,6 +6,24 @@
6
6
  ## @return [String] cleaned string
7
7
  ##
8
8
  class ::String
9
+ ##
10
+ ## Discard invalid characters and output a UTF-8 String
11
+ ##
12
+ ## @return [String] UTF-8 encoded string
13
+ ##
14
+ def utf8
15
+ encode('utf-16', invalid: :replace).encode('utf-8')
16
+ end
17
+
18
+ ##
19
+ ## Destructive version of #utf8
20
+ ##
21
+ ## @return [String] UTF-8 encoded string, in place
22
+ ##
23
+ def utf8!
24
+ replace utf8
25
+ end
26
+
9
27
  ## Remove extra spaces and newlines, compress space
10
28
  ## between tags
11
29
  ##
data/lib/curly/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # Top level module for CurlyQ
2
2
  module Curly
3
3
  # Current version number
4
- VERSION = '0.0.14'
4
+ VERSION = '0.0.16'
5
5
  end
data/src/_README.md CHANGED
@@ -13,7 +13,7 @@ _If you find this useful, feel free to [buy me some coffee][donate]._
13
13
  [jq]: https://github.com/jqlang/jq "Command-line JSON processor"
14
14
  [yq]: https://github.com/mikefarah/yq "yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor"
15
15
 
16
- The current version of `curlyq` is <!--VER-->0.0.13<!--END VER-->.
16
+ The current version of `curlyq` is <!--VER-->0.0.15<!--END VER-->.
17
17
 
18
18
  CurlyQ is a utility that provides a simple interface for curl, with additional features for things like extracting images and links, finding elements by CSS selector or XPath, getting detailed header info, and more. It's designed to be part of a scripting pipeline, outputting everything as structured data (JSON or YAML). It also has rudimentary support for making calls to JSON endpoints easier, but it's expected that you'll use something like [jq] to parse the output.
19
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curlyq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-25 00:00:00.000000000 Z
11
+ date: 2024-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake