yast-rake 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/tasks/spellcheck.rake +124 -0
- data/lib/yast/rake.rb +2 -1
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d21f098ea9abcb68f50188222c8db49635459f68
|
4
|
+
data.tar.gz: 0ad9c9c3b5e6dd035f6cab2931f3ffff0b504b6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e827363e7edfb10fc8923590422e629a754f3135544ad084bdf4b140a6c6c2d64b07f60bce54ccca1d18402d80e971827a0a8851228e4f51ffd7e237fb85eb41
|
7
|
+
data.tar.gz: 08f63ec226bc118b21fdbd102e40f755fa74e5ec9fbd88534b5943b2b38757f7083c4c32083500eb30a8001605b3ae238fe0dff83c74563e4b259bb82f5b958c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#--
|
2
|
+
# Yast rake
|
3
|
+
#
|
4
|
+
# Copyright (C) 2015 Novell, Inc.
|
5
|
+
# This library is free software; you can redistribute it and/or modify
|
6
|
+
# it only under the terms of version 2.1 of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# This library is distributed in the hope that it will be useful, but WITHOUT
|
10
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
11
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
12
|
+
# details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this library; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
17
|
+
#++
|
18
|
+
#
|
19
|
+
# Rake task for checking spelling in the documentation files.
|
20
|
+
# By default checks all *.md and *.html files.
|
21
|
+
#
|
22
|
+
# Supports custom dictionaries:
|
23
|
+
#
|
24
|
+
# - global dictionary located in the tasks gem (lib/tasks/.spell.dict)
|
25
|
+
# - repository specific dictionary (.spell.dict in the root directory)
|
26
|
+
#
|
27
|
+
# The custom dictionaries contains one word per line.
|
28
|
+
# The lines starting with '#' character are ignored (used for comments),
|
29
|
+
#
|
30
|
+
|
31
|
+
GLOBAL_DICTIONARY_FILE = "spell.dict"
|
32
|
+
CUSTOM_DICTIONARY_FILE = ".spell.dict"
|
33
|
+
|
34
|
+
def read_dictionary_file(file)
|
35
|
+
puts "Loading custom dictionary (#{file})..." if verbose == true
|
36
|
+
words = File.read(file).split("\n")
|
37
|
+
|
38
|
+
# remove comments
|
39
|
+
words.reject! { |word| word.start_with?("#")}
|
40
|
+
words.each(&:chomp!)
|
41
|
+
end
|
42
|
+
|
43
|
+
# read the global and the repository custom dictionary
|
44
|
+
def read_custom_words
|
45
|
+
# read the global default custom dictionary
|
46
|
+
dict_path = File.expand_path("../#{GLOBAL_DICTIONARY_FILE}", __FILE__)
|
47
|
+
custom_words = read_dictionary_file(dict_path)
|
48
|
+
|
49
|
+
# read the custom dictionary from the project directory if present
|
50
|
+
dict_path = CUSTOM_DICTIONARY_FILE
|
51
|
+
if File.exist?(dict_path)
|
52
|
+
local_dict = read_dictionary_file(dict_path)
|
53
|
+
duplicates = custom_words & local_dict
|
54
|
+
|
55
|
+
if !duplicates.empty?
|
56
|
+
$stderr.puts "Warning: Found duplicates in the local dictionary (#{dict_path}):\n"
|
57
|
+
duplicates.each {|duplicate| $stderr.puts " #{duplicate}" }
|
58
|
+
$stderr.puts
|
59
|
+
end
|
60
|
+
|
61
|
+
custom_words += local_dict - duplicates
|
62
|
+
end
|
63
|
+
|
64
|
+
custom_words
|
65
|
+
end
|
66
|
+
|
67
|
+
def aspell_speller
|
68
|
+
# raspell is an optional dependency, handle the missing case nicely
|
69
|
+
begin
|
70
|
+
require "raspell"
|
71
|
+
rescue LoadError
|
72
|
+
$stderr.puts "ERROR: Ruby gem \"raspell\" is not installed."
|
73
|
+
exit 1
|
74
|
+
end
|
75
|
+
|
76
|
+
# initialize aspell
|
77
|
+
speller = Aspell.new("en_US")
|
78
|
+
speller.suggestion_mode = Aspell::NORMAL
|
79
|
+
# ignore the HTML tags in the text
|
80
|
+
speller.set_option("mode", "html")
|
81
|
+
|
82
|
+
speller
|
83
|
+
end
|
84
|
+
|
85
|
+
namespace :check do
|
86
|
+
desc "Run spell checker (by default for *.md and *.html files in Git)"
|
87
|
+
task :spelling, :regexp do |t, args|
|
88
|
+
regexp = args[:regexp] || /\.(md|html)\z/
|
89
|
+
success = true
|
90
|
+
|
91
|
+
files = `git ls-files . | grep -v \\.gitignore`.split("\n")
|
92
|
+
files.select!{|file| file.match(regexp)}
|
93
|
+
|
94
|
+
custom_words = read_custom_words
|
95
|
+
speller = aspell_speller
|
96
|
+
|
97
|
+
files.each do |file|
|
98
|
+
puts "Checking #{file}..." if verbose == true
|
99
|
+
# spell check each line separately so we can report error locations properly
|
100
|
+
lines = File.read(file).split("\n")
|
101
|
+
|
102
|
+
lines.each_with_index do |text, index|
|
103
|
+
misspelled = speller.list_misspelled([text]) - custom_words
|
104
|
+
|
105
|
+
if !misspelled.empty?
|
106
|
+
success = false
|
107
|
+
puts "#{file}:#{index + 1}: #{text.inspect}"
|
108
|
+
misspelled.each do |word|
|
109
|
+
puts " #{word.inspect} => #{speller.suggest(word)}"
|
110
|
+
end
|
111
|
+
puts
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
if success
|
117
|
+
puts "Spelling OK."
|
118
|
+
else
|
119
|
+
$stderr.puts "Spellcheck failed! (Fix it or add the words to " \
|
120
|
+
"'#{CUSTOM_DICTIONARY_FILE}' file if it is OK.)"
|
121
|
+
exit 1
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/lib/yast/rake.rb
CHANGED
@@ -46,7 +46,8 @@ Yast::Tasks.configuration do |conf|
|
|
46
46
|
conf.obs_project = "YaST:Head"
|
47
47
|
conf.obs_sr_project = "openSUSE:Factory"
|
48
48
|
conf.package_name = File.read("RPMNAME").strip if File.exists?("RPMNAME")
|
49
|
-
conf.version = Yast::Tasks.spec_version
|
49
|
+
conf.version = Yast::Tasks.spec_version if !Dir.glob("package/*.spec").empty?
|
50
|
+
conf.skip_license_check << /spell.dict$/ # skip license check for spelling dictionaries
|
50
51
|
end
|
51
52
|
|
52
53
|
# load own tasks
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yast-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Reidinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '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
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: packaging_rake_tasks
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.0.0
|
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
40
|
version: 1.0.0
|
41
41
|
description: |
|
@@ -47,14 +47,15 @@ executables: []
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
-
-
|
50
|
+
- COPYING
|
51
|
+
- VERSION
|
51
52
|
- lib/tasks/install.rake
|
52
53
|
- lib/tasks/pot.rake
|
54
|
+
- lib/tasks/run.rake
|
55
|
+
- lib/tasks/spellcheck.rake
|
53
56
|
- lib/tasks/test_unit.rake
|
54
57
|
- lib/tasks/version.rake
|
55
|
-
- lib/
|
56
|
-
- COPYING
|
57
|
-
- VERSION
|
58
|
+
- lib/yast/rake.rb
|
58
59
|
homepage: http://github.org/openSUSE/yast-rake
|
59
60
|
licenses:
|
60
61
|
- LGPL v2.1
|
@@ -65,17 +66,17 @@ require_paths:
|
|
65
66
|
- lib
|
66
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
68
|
requirements:
|
68
|
-
- -
|
69
|
+
- - ">="
|
69
70
|
- !ruby/object:Gem::Version
|
70
71
|
version: '0'
|
71
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
|
-
- -
|
74
|
+
- - ">="
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: '0'
|
76
77
|
requirements: []
|
77
78
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
79
|
+
rubygems_version: 2.2.2
|
79
80
|
signing_key:
|
80
81
|
specification_version: 4
|
81
82
|
summary: Rake tasks providing basic work-flow for Yast development
|