gemma 4.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Gemma
2
3
  class RakeTasks
3
4
  #
@@ -13,7 +14,7 @@ module Gemma
13
14
  # @param [Gem::Specification] gemspec
14
15
  # @param [String, nil] gemspec_file_name
15
16
  #
16
- def initialize gemspec, gemspec_file_name
17
+ def initialize(gemspec, gemspec_file_name)
17
18
  super(gemspec)
18
19
  @gemspec_file_name = gemspec_file_name
19
20
  end
@@ -28,11 +29,10 @@ module Gemma
28
29
  def create_rake_tasks
29
30
  require 'bundler/gem_helper'
30
31
  dir = File.dirname(@gemspec_file_name) if @gemspec_file_name
31
- Bundler::GemHelper.install_tasks(:dir => dir,
32
- :name => gemspec.name)
32
+ Bundler::GemHelper.install_tasks(dir: dir,
33
+ name: gemspec.name)
33
34
  nil
34
35
  end
35
36
  end
36
37
  end
37
38
  end
38
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Gemma
2
3
  class RakeTasks
3
4
  #
@@ -5,18 +6,18 @@ module Gemma
5
6
  # the gemspec and the gem's +test+ directory are placed on the load path,
6
7
  # and the +test_files+ given in the gemspec are executed as tests.
7
8
  #
8
- # Minitest works on both 1.8 and 1.9, and it's mostly compatible with
9
+ # Minitest works on both 1.8 and 1.9, and it's mostly compatible with
9
10
  # <tt>Test::Unit</tt> tests.
10
11
  #
11
12
  # This plugin is based on the `Rake::TestTask` that comes bundled with rake.
12
13
  # If you need an option that isn't exposed by the plugin, you can modify the
13
- # `TestTask` object directly in a block passed to {#with_test_task}.
14
+ # `TestTask` object directly in a block passed to {#with_test_task}.
14
15
  #
15
16
  class MinitestTasks < Plugin
16
17
  #
17
18
  # @param [Gem::Specification] gemspec
18
19
  #
19
- def initialize gemspec
20
+ def initialize(gemspec)
20
21
  super(gemspec)
21
22
 
22
23
  # Defaults.
@@ -28,15 +29,15 @@ module Gemma
28
29
  #
29
30
  # Name of rake task used to run the test; defaults to test.
30
31
  #
31
- # @return [Symbol]
32
- #
32
+ # @return [Symbol]
33
+ #
33
34
  attr_accessor :task_name
34
35
 
35
36
  #
36
37
  # The files to test; defaults to the +test_files+ from the gemspec.
37
38
  #
38
- # @return [Array<String>]
39
- #
39
+ # @return [Array<String>]
40
+ #
40
41
  attr_accessor :files
41
42
 
42
43
  #
@@ -49,7 +50,7 @@ module Gemma
49
50
  #
50
51
  # @return [nil]
51
52
  #
52
- def with_test_task &block
53
+ def with_test_task(&block)
53
54
  @with_test_task = block
54
55
  nil
55
56
  end
@@ -62,13 +63,13 @@ module Gemma
62
63
  # @private
63
64
  #
64
65
  def create_rake_tasks
65
- unless self.files.empty?
66
+ unless files.empty?
66
67
  require 'rake/testtask'
67
- Rake::TestTask.new(self.task_name) do |tt|
68
- tt.libs = gemspec.require_paths.dup
69
- tt.libs << 'test'
70
- tt.test_files = self.files
71
- tt.ruby_opts << '-rubygems' << '-rbundler/setup'
68
+ Rake::TestTask.new(task_name) do |tt|
69
+ tt.libs = gemspec.require_paths.dup
70
+ tt.libs << 'test'
71
+ tt.test_files = files
72
+ tt.ruby_opts << '-rubygems' << '-rbundler/setup'
72
73
  @with_test_task.call(tt) if @with_test_task
73
74
  end
74
75
  end
@@ -77,4 +78,3 @@ module Gemma
77
78
  end
78
79
  end
79
80
  end
80
-
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  module Gemma
2
3
  class RakeTasks
3
- #
4
+ #
4
5
  # Plugins generate rake tasks based on the content of the gemspec.
5
6
  #
6
7
  # The intention is that the plugin processes the gemspec and sets
@@ -13,7 +14,7 @@ module Gemma
13
14
  class Plugin
14
15
  include Rake::DSL
15
16
 
16
- def initialize gemspec
17
+ def initialize(gemspec)
17
18
  @gemspec = gemspec
18
19
  end
19
20
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rdoc/task'
2
3
 
3
4
  module Gemma
@@ -7,18 +8,18 @@ module Gemma
7
8
  # the gemspec.
8
9
  #
9
10
  # The default settings are based on the +require_paths+, +rdoc_options+ and
10
- # +extra_rdoc_files+ data in the gemspec.
11
+ # +extra_rdoc_files+ data in the gemspec.
11
12
  #
12
13
  # This plugin is based on the <tt>Rake::RDocTask</tt> that comes bundled
13
14
  # with rdoc. If you need an option that isn't exposed by the plugin, you
14
15
  # can modify the +RDocTask+ object directly in a block passed to
15
- # {#with_rdoc_task}.
16
+ # {#with_rdoc_task}.
16
17
  #
17
18
  class RDocTasks < Plugin
18
19
  #
19
20
  # @param [Gem::Specification] gemspec
20
21
  #
21
- def initialize gemspec
22
+ def initialize(gemspec)
22
23
  super(gemspec)
23
24
 
24
25
  # Defaults.
@@ -42,15 +43,15 @@ module Gemma
42
43
  #
43
44
  # Name of rake task used to generate these docs; defaults to rdoc.
44
45
  #
45
- # @return [Symbol]
46
- #
46
+ # @return [Symbol]
47
+ #
47
48
  attr_accessor :task_name
48
49
 
49
50
  #
50
51
  # Name of output directory (the rdoc option --output); extracted from
51
52
  # gemspec; defaults to rdoc.
52
53
  #
53
- # @return [String]
54
+ # @return [String]
54
55
  #
55
56
  attr_accessor :output
56
57
 
@@ -58,7 +59,7 @@ module Gemma
58
59
  # Name of file to display in index.html (the rdoc option --main);
59
60
  # extracted from gemspec; defaults to nil (none).
60
61
  #
61
- # @return [String, nil]
62
+ # @return [String, nil]
62
63
  #
63
64
  attr_accessor :main
64
65
 
@@ -66,7 +67,7 @@ module Gemma
66
67
  # Title for HTML output (the rdoc option --title); extracted from gemspec;
67
68
  # defaults to nil (unspecified).
68
69
  #
69
- # @return [String, nil]
70
+ # @return [String, nil]
70
71
  #
71
72
  attr_accessor :title
72
73
 
@@ -74,7 +75,7 @@ module Gemma
74
75
  # Name of template used to generate html output (the rdoc option
75
76
  # --template); extracted from gemspec; defaults to nil (unspecified).
76
77
  #
77
- # @return [String, nil]
78
+ # @return [String, nil]
78
79
  #
79
80
  attr_accessor :template
80
81
 
@@ -82,7 +83,7 @@ module Gemma
82
83
  # Files and directories to be processed by rdoc; extracted from gemspec;
83
84
  # by default, these are the gem's +require_paths+ and +extra_rdoc_files+.
84
85
  #
85
- # @return [Array<String>]
86
+ # @return [Array<String>]
86
87
  #
87
88
  attr_accessor :files
88
89
 
@@ -91,7 +92,7 @@ module Gemma
91
92
  # the {#output}, {#main}, {#title} and {#template} options and the
92
93
  # {#files} list are handled separately.
93
94
  #
94
- # @return [Array<String>]
95
+ # @return [Array<String>]
95
96
  #
96
97
  attr_accessor :options
97
98
 
@@ -105,7 +106,7 @@ module Gemma
105
106
  #
106
107
  # @return [nil]
107
108
  #
108
- def with_rdoc_task &block
109
+ def with_rdoc_task(&block)
109
110
  @with_rdoc_task = block
110
111
  nil
111
112
  end
@@ -118,16 +119,16 @@ module Gemma
118
119
  # @private
119
120
  #
120
121
  def create_rake_tasks
121
- Rake::RDocTask.new(self.task_name) do |rd|
122
- rd.rdoc_dir = self.output
123
- rd.rdoc_files = self.files
124
- rd.title = self.title
125
- rd.main = self.main
126
- rd.template = self.template
127
- rd.options = self.options
122
+ Rake::RDocTask.new(task_name) do |rd|
123
+ rd.rdoc_dir = output
124
+ rd.rdoc_files = files
125
+ rd.title = title
126
+ rd.main = main
127
+ rd.template = template
128
+ rd.options = options
128
129
  @with_rdoc_task.call(rd) if @with_rdoc_task
129
130
  end
130
- CLOBBER.include(self.output)
131
+ CLOBBER.include(output)
131
132
 
132
133
  nil
133
134
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'yard'
2
3
 
3
4
  module Gemma
@@ -24,13 +25,13 @@ module Gemma
24
25
  # This plugin is based on the <tt>YARD::Rake::YardocTask</tt> that comes
25
26
  # bundled with yard. If you need an option that isn't exposed by the
26
27
  # plugin, you can modify the +YardocTask+ object directly in a block passed
27
- # to {#with_yardoc_task}.
28
+ # to {#with_yardoc_task}.
28
29
  #
29
30
  class YardTasks < Plugin
30
31
  #
31
32
  # @param [Gem::Specification] gemspec
32
33
  #
33
- def initialize gemspec
34
+ def initialize(gemspec)
34
35
  super(gemspec)
35
36
 
36
37
  # Defaults.
@@ -55,14 +56,14 @@ module Gemma
55
56
  #
56
57
  # Name of rake task used to generate these docs; defaults to yard.
57
58
  #
58
- # @return [Symbol]
59
+ # @return [Symbol]
59
60
  #
60
61
  attr_accessor :task_name
61
62
 
62
63
  #
63
64
  # Name of output directory (the yard option --output); defaults to yard.
64
65
  #
65
- # @return [String]
66
+ # @return [String]
66
67
  #
67
68
  attr_accessor :output
68
69
 
@@ -70,7 +71,7 @@ module Gemma
70
71
  # Name of file to display in index.html (the yard option --main);
71
72
  # extracted from gemspec; defaults to nil (none).
72
73
  #
73
- # @return [String, nil]
74
+ # @return [String, nil]
74
75
  #
75
76
  attr_accessor :main
76
77
 
@@ -78,7 +79,7 @@ module Gemma
78
79
  # Title for HTML output (the yard option --title); extracted from gemspec;
79
80
  # defaults to nil (unspecified).
80
81
  #
81
- # @return [String, nil]
82
+ # @return [String, nil]
82
83
  #
83
84
  attr_accessor :title
84
85
 
@@ -86,7 +87,7 @@ module Gemma
86
87
  # Ruby files to be processed by yard; these are extracted from the
87
88
  # gemspec; by default these are the +require_paths+.
88
89
  #
89
- # @return [Array<String>]
90
+ # @return [Array<String>]
90
91
  #
91
92
  attr_accessor :files
92
93
 
@@ -94,7 +95,7 @@ module Gemma
94
95
  # Extra files (e.g. FAQ, LICENSE) to be processed by yard; these are
95
96
  # extracted from the gemspec.
96
97
  #
97
- # @return [Array<String>]
98
+ # @return [Array<String>]
98
99
  #
99
100
  attr_accessor :extra_files
100
101
 
@@ -117,7 +118,7 @@ module Gemma
117
118
  #
118
119
  # @return [nil]
119
120
  #
120
- def with_yardoc_task &block
121
+ def with_yardoc_task(&block)
121
122
  @with_yardoc_task = block
122
123
  nil
123
124
  end
@@ -131,32 +132,32 @@ module Gemma
131
132
  #
132
133
  def create_rake_tasks
133
134
  YARD::Rake::YardocTask.new do |yd|
134
- yd.name = self.task_name
135
+ yd.name = task_name
135
136
  yd.options = complete_options
136
- yd.files = self.files
137
- yd.files.push('-', *self.extra_files) unless self.extra_files.empty?
137
+ yd.files = files
138
+ yd.files.push('-', *extra_files) unless extra_files.empty?
138
139
  @with_yardoc_task.call(yd) if @with_yardoc_task
139
140
  end
140
- CLOBBER.include(self.output)
141
+ CLOBBER.include(output)
141
142
  CLOBBER.include('.yardoc')
142
143
  nil
143
144
  rescue LoadError
144
- # Assume yard is not installed.
145
+ nil # Assume yard is not installed.
145
146
  end
146
147
 
147
- private
148
+ private
148
149
 
149
- #
150
+ #
150
151
  # Options to be passed to yardoc; this includes {#options} and the
151
152
  # {#main}, {#title} and {#output} options.
152
153
  #
153
154
  # @return [Array<String>]
154
- #
155
+ #
155
156
  def complete_options
156
- opts = self.options.dup
157
- opts.push('--main', self.main) if self.main
158
- opts.push('--title', self.title) if self.title
159
- opts.push('--output', self.output)
157
+ opts = options.dup
158
+ opts.push('--main', main) if main
159
+ opts.push('--title', title) if title
160
+ opts.push('--output', output)
160
161
  opts
161
162
  end
162
163
  end
@@ -1,17 +1,23 @@
1
+ # frozen_string_literal: true
1
2
  module Gemma
3
+ #
4
+ # Utility functions.
5
+ #
2
6
  module Utility
3
- #
7
+ #
4
8
  # If the usage information for a script is documented in a comment block at
5
9
  # the top of the file, this method prints it out. If there is a shebang
6
10
  # (#!) on the first line, it is not printed.
7
11
  #
8
- def self.print_usage_from_file_comment file, comment_char='#', io=$stdout
12
+ def self.print_usage_from_file_comment(
13
+ file, comment_char = '#', io = $stdout
14
+ )
9
15
  lines = File.readlines(file)
10
16
  lines.shift if lines.first =~ /^#!/ # ignore shebang
11
- for line in lines
17
+ lines.each do |line|
12
18
  line.strip!
13
19
  break unless line =~ /^#{comment_char}(.*)/
14
- io.puts $1
20
+ io.puts Regexp.last_match(1)
15
21
  end
16
22
  end
17
23
 
@@ -26,9 +32,10 @@ module Gemma
26
32
  #
27
33
  # @return [nil]
28
34
  #
29
- def self.rgrep tag, path, io=$stdout
35
+ def self.rgrep(tag, path, io = $stdout)
30
36
  Dir.chdir path do
31
- (Dir["**/*"] + Dir["**/.*"]).select {|f| File.file? f}.sort.each do |f|
37
+ globs = Dir['**/*'] + Dir['**/.*']
38
+ globs.select { |f| File.file?(f) }.sort.each do |f|
32
39
  File.readlines(f).each_with_index do |line, i|
33
40
  io.puts "#{f}:#{i}: #{line}" if line =~ tag
34
41
  end
@@ -38,4 +45,3 @@ module Gemma
38
45
  end
39
46
  end
40
47
  end
41
-
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  module Gemma
2
- VERSION_MAJOR = 4
3
- VERSION_MINOR = 1
3
+ VERSION_MAJOR = 5
4
+ VERSION_MINOR = 0
4
5
  VERSION_PATCH = 0
5
6
  VERSION = [VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH].join('.')
6
7
  end
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: <%= RbConfig::CONFIG['MAJOR'] %>.<%= RbConfig::CONFIG['MINOR'] %>
3
+
4
+ Style/Documentation:
5
+ Exclude:
6
+ - 'test/**/*'
@@ -1,3 +1,4 @@
1
- source "http://rubygems.org"
2
- gemspec
1
+ # frozen_string_literal: true
3
2
 
3
+ source 'https://rubygems.org'
4
+ gemspec
@@ -1,28 +1,32 @@
1
- = <%= gem_name %>
1
+ # <%= gem_name %>
2
2
 
3
3
  * TODO url
4
4
 
5
- == SYNOPSIS
5
+ ## Synopsis
6
6
 
7
7
  TODO description
8
8
 
9
- === Usage
9
+ ### Usage
10
10
 
11
- TODO (code sample of usage)
11
+ ```ruby
12
+ TODO (code sample of usage)
13
+ ```
12
14
 
13
- == REQUIREMENTS
15
+ ## Requirements
14
16
 
15
17
  * TODO (list of requirements)
16
18
 
17
- == INSTALLATION
19
+ ## Installation
18
20
 
19
- sudo gem install <%= gem_name %>
21
+ ```
22
+ gem install <%= gem_name %>
23
+ ```
20
24
 
21
- == DEVELOPMENT
25
+ ## Development
22
26
 
23
27
  TODO developer advice
24
28
 
25
- == LICENSE
29
+ ## License
26
30
 
27
31
  (The MIT License)
28
32
 
@@ -46,4 +50,3 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
50
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
51
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
52
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49
-