cani 0.4.1 → 0.4.2

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: 76133edfe3fbbd09fbab2328f52ce8f3e90fd56af8991764900d0a7b05c5c738
4
- data.tar.gz: 735dcc7e1a6ef0dd05d0ab591588691922c777b704b3d09bb4d63dd0fa861045
3
+ metadata.gz: ae8ae8c652d00d36462bc6061152f8fc0ace6a1ef2a60829454e36a13724c61b
4
+ data.tar.gz: 57c8faa58ecee7055cd551cd04c22ec716741ffe4efdc8d1a2c039dd63fe6392
5
5
  SHA512:
6
- metadata.gz: 37003678fd7735a27edfaa096809853355aa518ae2694beca61e3292b2722cc7cd87f2fd94331e6b1cac22f10a8e7aa400b24cac136dbe9120cdadf324f6d966
7
- data.tar.gz: f3d7841d99e3d221e495f852bf383f1c560468d07cfc5f0531cef3594b6ee47a817c11c8661d5d5f3331d4491e1e762dda758b8f89e7cc0f43dfd38f680f62ec
6
+ metadata.gz: 4b1a3afd03c2ee8a129ed679693f4c632c64221297ae2467194c41dad11baa1fb579a4288871613d0afe4bb759a8859b4a4771bb085438c072a156248e336532
7
+ data.tar.gz: 89939e8bceaf23bcd3e94317de9ed73231da669d339c828a06932d3864fe3b2a268fba435498b1a642e00b3411711f36577742662985e99145f44f448a976ad2
data/cani.gemspec CHANGED
@@ -3,24 +3,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'cani/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'cani'
7
- spec.version = Cani::VERSION
8
- spec.authors = ['Sidney Liebrand']
9
- spec.email = ['sidneyliebrand@gmail.com']
6
+ spec.required_ruby_version = '>= 2.1'
7
+ spec.name = 'cani'
8
+ spec.version = Cani::VERSION
9
+ spec.authors = ['Sidney Liebrand']
10
+ spec.email = ['sidneyliebrand@gmail.com']
10
11
 
11
- spec.summary = 'A simple caniuse CLI.'
12
- spec.description = 'A rework of the ruby script from my medium post: https://medium.com/@sidneyliebrand/combining-caniuse-with-fzf-fb93ad235bae'
13
- spec.homepage = 'https://github.com/SidOfc/cani'
14
- spec.license = 'MIT'
12
+ spec.summary = 'A simple caniuse CLI.'
13
+ spec.description = 'An interactive TUI (using FZF / Curses) for exploring caniuse.com in your terminal.'
14
+ spec.homepage = 'https://github.com/SidOfc/cani'
15
+ spec.license = 'MIT'
15
16
 
16
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
18
  `git ls-files -z`.split("\x0").reject do |f|
18
19
  f.match(%r{^(test|spec|features|assets)/})
19
20
  end
20
21
  end
21
- spec.bindir = 'exe'
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ['lib']
22
+
23
+ spec.bindir = 'exe'
24
+ spec.require_paths = ['lib']
25
+ spec.executables << 'cani'
24
26
 
25
27
  spec.add_runtime_dependency 'colorize'
26
28
  spec.add_runtime_dependency 'curses'
data/exe/cani CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
4
  require 'cani'
6
5
 
7
6
  Cani.exec! ARGV[0], *ARGV[1..-1]
@@ -270,7 +270,7 @@ module Cani
270
270
 
271
271
  notes_chunked = feature.notes.map { |nt| nt.chars.each_slice(outer_width).map(&:join).map(&:strip) }
272
272
  num_chunked = feature.notes_by_num.each_with_object({}) { |(k, nt), h| h[k] = nt.chars.each_slice(outer_width - 5).map(&:join).map(&:strip) }
273
- notes_total = notes_chunked.map(&:size).sum + num_chunked.map(&:size).sum
273
+ notes_total = (notes_chunked.map(&:size) + num_chunked.map(&:size)).reduce(0) { |total, add| total + add }
274
274
 
275
275
  if height > cy + 2 && (notes_chunked.any? || num_chunked.any?)
276
276
  # print notes header
data/lib/cani/api.rb CHANGED
@@ -56,7 +56,7 @@ module Cani
56
56
  def find_feature(name)
57
57
  name = Regexp.new name.to_s.downcase.gsub(/(\W)/, '.*'), :i
58
58
  idx = features.find_index do |ft|
59
- ft.title.downcase.match?(name) || ft.name.downcase.match?(name)
59
+ ft.title.downcase.match(name) || ft.name.downcase.match(name)
60
60
  end
61
61
 
62
62
  features[idx] if idx
@@ -90,7 +90,7 @@ module Cani
90
90
  shellrc = File.join Dir.home, ".#{shell}rc"
91
91
  lines = File.read(shellrc).split "\n"
92
92
  comp_path = File.join Cani.config.comp_dir, "_cani.#{shell}"
93
- rm_idx = lines.find_index { |l| l.match? comp_path }
93
+ rm_idx = lines.find_index { |l| l.match comp_path }
94
94
 
95
95
  lines.delete_at rm_idx unless rm_idx.nil?
96
96
  File.write shellrc, lines.join("\n")
@@ -102,7 +102,7 @@ module Cani
102
102
  shellrc = File.join Dir.home, ".#{shell}rc"
103
103
  lines = File.read(shellrc).split "\n"
104
104
  comp_path = File.join Cani.config.comp_dir, "_cani.#{shell}"
105
- slidx = lines.find_index { |l| l.match? comp_path }
105
+ slidx = lines.find_index { |l| l.match comp_path }
106
106
 
107
107
  if slidx
108
108
  lines[slidx] =
data/lib/cani/fzf.rb CHANGED
@@ -41,7 +41,7 @@ module Cani
41
41
 
42
42
  def self.browser_rows
43
43
  @browser_rows ||= Cani.api.browsers.map do |bwsr|
44
- [bwsr.title, 'usage: ' + format('%.4f%%', bwsr.usage.values.sum)]
44
+ [bwsr.title, 'usage: ' + format('%.4f%%', bwsr.usage.values.reduce(0) { |total, add| total + add })]
45
45
  end
46
46
  end
47
47
 
data/lib/cani/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cani
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/cani.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'io/console'
4
+ require 'fileutils'
4
5
  require 'curses'
5
6
  require 'colorize'
6
7
  require 'json'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sidney Liebrand
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-27 00:00:00.000000000 Z
11
+ date: 2018-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -108,7 +108,8 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.0'
111
- description: 'A rework of the ruby script from my medium post: https://medium.com/@sidneyliebrand/combining-caniuse-with-fzf-fb93ad235bae'
111
+ description: An interactive TUI (using FZF / Curses) for exploring caniuse.com in
112
+ your terminal.
112
113
  email:
113
114
  - sidneyliebrand@gmail.com
114
115
  executables:
@@ -152,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
153
  requirements:
153
154
  - - ">="
154
155
  - !ruby/object:Gem::Version
155
- version: '0'
156
+ version: '2.1'
156
157
  required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  requirements:
158
159
  - - ">="