phew 0.0.3 → 0.0.4

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
- SHA1:
3
- metadata.gz: 163b79015f30a7af7db5e50634043dd713ea4747
4
- data.tar.gz: c3f9fdd68ebfe6225a6b01e48ac7880679a419a5
2
+ SHA256:
3
+ metadata.gz: 76bdc848ba00cbe93dcbd8bd4f18255af08e7b11eb35704404a4e80fe9d3d06a
4
+ data.tar.gz: a15961a04d5673672b9d3deec4f58e9ec559a9c925b2608648def511249aab82
5
5
  SHA512:
6
- metadata.gz: a062cbf070fb5fe243389b431c41fa46d756194bb5cf62eee84ffa543aee1c4da25a46866b68c5b81f369e937cc5e81c02d64173a6120e6b4cddcc21c4252e5c
7
- data.tar.gz: 52534feb77e7db63f8fdc3ffaec0019b50bb499e86e02e3e9b4bb568af785cf57d8a4390fcac7d1b1e2dff1c2ea15e0d6fd22c6ccfd5d08d03a2ddc68c4051fc
6
+ metadata.gz: 6999d0de88e2e3feae5d92d7556821dbeff21f3fbb3968ab698a0f28611f0d098ef03414d3d8691761cd748300af5495812afcb4161ada42d05df4426df0933d
7
+ data.tar.gz: fc76fd22022ef3883ffae54df23e0a207c3d836de672a47def2204e3d3e48a5032e759945c082b3fafce5dbbaea7aec8b0cf9e3af61492411958bfdf63e3d40f
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # The gem's dependencies are specified in the gemspec
4
6
  gemspec
5
-
6
- gem 'pry', '~> 0.10.0', type: :development
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake/clean'
2
4
  require 'bundler/gem_helper'
3
5
  require 'rake/testtask'
@@ -7,17 +9,17 @@ Bundler::GemHelper.install_tasks
7
9
  namespace :test do
8
10
  Rake::TestTask.new(:unit) do |t|
9
11
  t.libs = ['lib']
10
- t.test_files = FileList['test/unit/*_test.rb']
12
+ t.test_files = FileList['test/**/*_test.rb']
11
13
  t.warning = true
12
14
  end
13
15
 
14
- Rake::TestTask.new(:end_to_end) do |t|
16
+ Rake::TestTask.new(:features) do |t|
15
17
  t.libs = ['lib']
16
- t.test_files = FileList['test/end_to_end/*_test.rb']
18
+ t.test_files = FileList['features/**/*_test.rb']
17
19
  t.warning = true
18
20
  end
19
21
 
20
- task all: [:unit, :end_to_end]
22
+ task all: [:unit, :features]
21
23
  end
22
24
 
23
25
  task test: 'test:all'
data/bin/phew CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  require 'phew'
3
5
 
4
6
  Gtk.init
@@ -29,7 +31,7 @@ module Phew
29
31
  false
30
32
  end
31
33
 
32
- def on_key_press_event evt
34
+ def on_key_press_event(evt)
33
35
  destroy if evt.state[:control_mask] && evt.keyval == 'q'.ord
34
36
  false
35
37
  end
@@ -112,24 +114,30 @@ module Phew
112
114
  win.show_all
113
115
  end
114
116
 
115
- def fill_font_list script
117
+ def fill_font_list(script)
116
118
  scriptmodel.clear
117
119
 
118
- fontmap = @context.get_font_map
119
-
120
- fontmap.list_families.each do |fam|
120
+ font_families.each do |fam|
121
121
  font = @font_repository.get_font fam.name
122
122
 
123
- sample_cov = font.coverage_summary script.sample_string
124
- mostly = [:none, :fallback, :approximate, :exact].max_by { |i| sample_cov[i] }
125
-
126
- if mostly == :exact
123
+ if sample_coverage(font, script) == :exact
127
124
  row = scriptmodel.append
128
125
  scriptmodel.set_value row, 0, fam.name
129
126
  end
130
127
  end
131
128
  end
132
129
 
130
+ def sample_coverage(font, script)
131
+ sample_cov = font.coverage_summary script.sample_string
132
+ [:none, :fallback, :approximate, :exact].max_by { |i| sample_cov[i] }
133
+ end
134
+
135
+ def font_families
136
+ fontmap = @context.get_font_map
137
+
138
+ fontmap.list_families
139
+ end
140
+
133
141
  def run
134
142
  Gtk.main
135
143
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gir_ffi-gtk3'
2
4
  require 'gir_ffi-pango'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Phew
2
4
  # Font family. Handles coverage, among other things.
3
5
  class Font
@@ -6,7 +8,7 @@ module Phew
6
8
  #
7
9
  # @param [Pango::Context] context Pango context to retrieve font from.
8
10
  # @param [String] text_description Description of the font to create.
9
- def initialize context, text_description
11
+ def initialize(context, text_description)
10
12
  fd = Pango::FontDescription.from_string text_description
11
13
  fontmap = context.get_font_map
12
14
  @font = fontmap.load_font context, fd
@@ -16,7 +18,7 @@ module Phew
16
18
  #
17
19
  # @return A hash with keys :none, :fallback, :approximate, :exact, and values
18
20
  # indicating the number of characters in the text that have that coverage.
19
- def coverage_summary text
21
+ def coverage_summary(text)
20
22
  lang = Pango::Language.new
21
23
  cov = @font.get_coverage lang
22
24
  text_cov = text.each_codepoint.map { |cp| cov.get cp }
@@ -1,16 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Phew
2
4
  # Cache for font information retrieved from a Pango context
3
5
  class FontRepository
4
6
  # @param [Pango::Context] context Pango context to retrieve fonts from.
5
- def initialize context
7
+ def initialize(context)
6
8
  @store = {}
7
9
  @context = context
8
10
  end
11
+
9
12
  # Retrieve a font based on the given text description. The text description
10
13
  # should be in the format accepted by Font#new.
11
14
  #
12
15
  # @param [String] text_description Description of the font to retrieve.
13
- def get_font text_description
16
+ def get_font(text_description)
14
17
  @store[text_description] ||= Font.new @context, text_description
15
18
  end
16
19
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Phew
2
4
  # A script.
3
5
  class Script
4
- def initialize name
6
+ def initialize(name)
5
7
  symbol = name.to_sym
6
8
  @symbol = symbol
7
9
  @lang = Pango.script_get_sample_language symbol
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../test_helper'
2
4
 
3
5
  describe Phew::FontRepository do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../test_helper'
2
4
 
3
5
  describe Phew::Font do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
 
3
5
  require 'phew'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phew
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matijs van Zuijlen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-16 00:00:00.000000000 Z
11
+ date: 2018-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gir_ffi-gtk
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.11.0
19
+ version: 0.12.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.11.0
26
+ version: 0.12.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gir_ffi-pango
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.9
33
+ version: 0.0.10
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.9
40
+ version: 0.0.10
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: atspi_app_driver
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '12.0'
47
+ version: 0.3.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '12.0'
54
+ version: 0.3.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '5.5'
69
69
  - !ruby/object:Gem::Dependency
70
- name: atspi_app_driver
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.0.7
75
+ version: '12.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.0.7
82
+ version: '12.0'
83
83
  description: List and compare installed fonts on GNOME
84
84
  email:
85
85
  - matijs@matijs.net
@@ -103,10 +103,9 @@ files:
103
103
  - lib/phew/font.rb
104
104
  - lib/phew/font_repository.rb
105
105
  - lib/phew/script.rb
106
- - test/end_to_end/basic_run_test.rb
106
+ - test/phew/font_repository_test.rb
107
+ - test/phew/font_test.rb
107
108
  - test/test_helper.rb
108
- - test/unit/font_repository_test.rb
109
- - test/unit/font_test.rb
110
109
  homepage: http://www.github.com/mvz/phew-font-viewer
111
110
  licenses:
112
111
  - GPL-3
@@ -122,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
121
  requirements:
123
122
  - - ">="
124
123
  - !ruby/object:Gem::Version
125
- version: 1.9.3
124
+ version: 2.3.0
126
125
  required_rubygems_version: !ruby/object:Gem::Requirement
127
126
  requirements:
128
127
  - - ">="
@@ -130,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
129
  version: '0'
131
130
  requirements: []
132
131
  rubyforge_project:
133
- rubygems_version: 2.6.8
132
+ rubygems_version: 2.7.6
134
133
  signing_key:
135
134
  specification_version: 4
136
135
  summary: A GNOME Font Viewer
@@ -1,53 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'atspi_app_driver'
3
-
4
- # Test driver for the Phew application.
5
- class PhewDriver < AtspiAppDriver
6
- def initialize
7
- verbose = ENV['VERBOSE'] == 'true'
8
- super 'phew', verbose: verbose
9
- end
10
- end
11
-
12
- describe 'The Phew application' do
13
- before do
14
- @driver = PhewDriver.new
15
- @driver.boot
16
- end
17
-
18
- it 'starts and can be quit with Ctrl-q' do
19
- sleep 0.05
20
- @driver.press_ctrl_q
21
-
22
- status = @driver.cleanup
23
- status.exitstatus.must_equal 0
24
- end
25
-
26
- it 'shows a dropdown list of scripts' do
27
- frame = @driver.frame
28
-
29
- box = frame.find_role :combo_box
30
-
31
- latin = box.find_role :menu_item, /latin/
32
- latin.wont_be_nil
33
-
34
- textbox = frame.find_role :text
35
- textbox.wont_be_nil
36
- textbox.get_text(0, 100).must_equal ''
37
-
38
- box.get_action_name(0).must_equal 'press'
39
- box.do_action 0
40
- latin.get_action_name(0).must_equal 'click'
41
- latin.do_action 0
42
-
43
- textbox.get_text(0, 100).must_equal 'The quick brown fox jumps over the lazy dog.'
44
-
45
- @driver.press_ctrl_q
46
- status = @driver.cleanup
47
- status.exitstatus.must_equal 0
48
- end
49
-
50
- after do
51
- @driver.cleanup
52
- end
53
- end