gemma 4.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YTE5M2Y0MmZjYTY1ODY2YTM5OGFkNjg1NmE0YWI0OGU0NTE4ZmViNA==
5
- data.tar.gz: !binary |-
6
- N2IxM2JiMzRkMzBhZWViMTU2MTJmODZmOWMwMWYwZGU0ZjBmMTFlOQ==
2
+ SHA1:
3
+ metadata.gz: 50de89c768f1926c49fcf8710eb45a0828d92815
4
+ data.tar.gz: 3213328600aca48ce8c54c5a984d5548a844d3a9
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- Y2Y1NTE0YWYzZmY2MWVlMDI4MmE2MzBjMTg5YzQxYmViOTA3NjVhMzliNTll
10
- MjNjZWY5MTA3NTYzZTQ4Y2U0MWFjNTE4ZmI0NzkxOGUyOTg4OTE2ODFiNzJm
11
- NWNmZTYxZGU0OWRkYTQ1YjVlNWUzMDM3ZTJkYWNkZGQ4ZjJiNjM=
12
- data.tar.gz: !binary |-
13
- NGYyNDZjODdjMTVkMzNiN2Y4MDMwOTIwMTg0OTBjYWQ5ZWFlYjJkYzI5MjAw
14
- Njg3Y2Y4MGQ2NTlhZTAxZTRmYzNmM2ZkOTQ5NDhjNGUyZTEwOGMwNjQ5YzIw
15
- NTQxOWE2YWY2YjBlZWVmYzc2N2FiNTZlZGVmYTA1ODUwMDkyNmY=
6
+ metadata.gz: bb86aa15921e9ffd00b0441a087a726e97f5cd0cd77cf5fffdf55b0127f003ba46f1ae3dfd0703488bc223c11b2ce3adacc43899d9260a1d3bf2da0436cd7e5c
7
+ data.tar.gz: f04872a8b10b1ead1132381dbdd88e0b203bfd253015371a7b5b92bb9688cd451081f7fa8a76b9b3ef39e8b8c362b82bbfaf4d1651360b4eda1255327644900c
@@ -38,13 +38,13 @@ This gives you a simple gem template like the following:
38
38
  |-- bin
39
39
  | `-- my_gem # executable (optional)
40
40
  |-- Gemfile # for bundler (see below)
41
- |-- lib
41
+ |-- lib
42
42
  | |-- my_gem # most of your code goes here
43
43
  | | `-- version.rb # the version constant
44
44
  | `-- my_gem.rb # the main code file
45
45
  |-- my_gem.gemspec # gem metadata
46
- |-- Rakefile.rb # development tasks
47
- |-- README.rdoc # documentation
46
+ |-- Rakefile # development tasks
47
+ |-- README.md # documentation
48
48
  `-- test # unit tests go here
49
49
  `-- my_gem
50
50
  `-- my_gem_test.rb
@@ -66,7 +66,7 @@ your gemspec; to enable them, add the following to the top of your +Rakefile+:
66
66
 
67
67
  Gemma::RakeTasks.with_gemspec_file 'my_gem.gemspec'
68
68
 
69
- task :default => :test
69
+ task default: :test
70
70
 
71
71
  This gives you some standard rake tasks, in addition to any that you define
72
72
  yourself.
@@ -97,17 +97,10 @@ See the gemma API docs for more information.
97
97
 
98
98
  == INSTALLATION
99
99
 
100
- On RVM:
101
100
  gem install gemma
102
101
 
103
- On a system ruby:
104
- sudo gem install bundler
105
- sudo gem install gemma
106
-
107
102
  == DEVELOPMENT
108
103
 
109
- gem install bundler
110
- gem install gemma
111
104
  git clone git://github.com/jdleesmiller/gemma.git
112
105
  cd gemma
113
106
  bundle
@@ -130,6 +123,15 @@ On a system ruby:
130
123
 
131
124
  == HISTORY
132
125
 
126
+ <em>5.0.0</em>
127
+ * updated dependencies
128
+ * added rubocop as a dependency and lint the code and the template
129
+ * converted the template readme to markdown
130
+ * dropped support for rubies < 2.3 (use 4.x for older rubies)
131
+
132
+ <em>4.1.0</em>
133
+ * updated dependencies
134
+
133
135
  <em>4.0.0</em>
134
136
  * updated dependencies
135
137
  * removed RunTasks -- bundler handles this now
@@ -152,7 +154,7 @@ On a system ruby:
152
154
 
153
155
  <em>1.0.0</em>
154
156
  * added templates
155
- * changed rdoc and yard tasks to use +require_paths+ instead of +files+
157
+ * changed rdoc and yard tasks to use +require_paths+ instead of +files+
156
158
  * more tests
157
159
  * more documentation
158
160
 
@@ -184,4 +186,3 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
184
186
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
185
187
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
186
188
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
187
-
data/bin/gemma CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  #
3
4
  # = gemma
4
5
  #
@@ -30,7 +31,7 @@
30
31
  #
31
32
  # --template=path::
32
33
  # path to template to use instead of default template(s); specify this
33
- # argument multiple times to copy from several templates (in order).
34
+ # argument multiple times to copy from several templates (in order).
34
35
  #
35
36
 
36
37
  require 'getoptlong'
@@ -42,8 +43,8 @@ require 'highline'
42
43
  #
43
44
 
44
45
  getopt = GetoptLong.new(
45
- ['--help', '-h', GetoptLong::NO_ARGUMENT ],
46
- ['--version', '-v', GetoptLong::NO_ARGUMENT ],
46
+ ['--help', '-h', GetoptLong::NO_ARGUMENT],
47
+ ['--version', '-v', GetoptLong::NO_ARGUMENT],
47
48
  ['--name', GetoptLong::REQUIRED_ARGUMENT],
48
49
  ['--dir', GetoptLong::REQUIRED_ARGUMENT],
49
50
  ['--module', GetoptLong::REQUIRED_ARGUMENT],
@@ -69,7 +70,7 @@ end
69
70
 
70
71
  # Remaining argument should be the command.
71
72
  command = ARGV.shift
72
- unless command && command == "new"
73
+ unless command && command == 'new'
73
74
  Gemma::Utility.print_usage_from_file_comment __FILE__
74
75
  exit
75
76
  end
@@ -83,29 +84,31 @@ gt = Gemma::GemFromTemplate.new
83
84
  interactive = !opts['--name'] || opts['--name'].empty?
84
85
 
85
86
  if interactive
86
- puts
87
- puts "creating a new gem with gemma..."
88
- puts
87
+ puts
88
+ puts 'creating a new gem with gemma...'
89
+ puts
89
90
  end
90
91
 
91
- unless interactive
92
- gt.gem_name = opts['--name']
92
+ if interactive
93
+ gt.gem_name = hl.ask('gem name: ') { |q| q.validate = /^.+$/ } # weak
93
94
  else
94
- gt.gem_name = hl.ask('gem name: ') {|q| q.validate = /^.+$/} # weak
95
+ gt.gem_name = opts['--name']
95
96
  end
96
97
 
97
98
  if opts['--dir']
98
- gt.dir_name = opts['--dir']
99
+ gt.dir_name = opts['--dir']
99
100
  elsif interactive
100
- gt.dir_name =
101
- hl.ask('create gem in directory: ') {|q| q.default = gt.dir_name}
101
+ gt.dir_name = hl.ask('create gem in directory: ') do |q|
102
+ q.default = gt.dir_name
103
+ end
102
104
  end
103
105
 
104
106
  if opts['--module']
105
107
  gt.module_name = opts['--module']
106
108
  elsif interactive
107
- gt.module_name =
108
- hl.ask('wrap contents in module called: ') {|q| q.default = gt.module_name}
109
+ gt.module_name = hl.ask('wrap contents in module called: ') do |q|
110
+ q.default = gt.module_name
111
+ end
109
112
  end
110
113
 
111
114
  templates = opts['--template']
@@ -113,7 +116,7 @@ if templates.empty?
113
116
  if interactive
114
117
  templates << 'base' << 'minitest'
115
118
  hl.choose do |menu|
116
- menu.prompt = "type of gem: "
119
+ menu.prompt = 'type of gem: '
117
120
  menu.shell = true
118
121
  menu.choice('library (library scripts only)') do
119
122
  # no extras
@@ -123,12 +126,14 @@ if templates.empty?
123
126
  end
124
127
  end
125
128
  else
126
- templates.push(*Gemma::GemFromTemplate::BUILTIN_TEMPLATES)
129
+ templates.concat(Gemma::GemFromTemplate::BUILTIN_TEMPLATES)
130
+ end
131
+ templates.map! do |name|
132
+ File.join(Gemma::GemFromTemplate::TEMPLATE_ROOT, name)
127
133
  end
128
- templates.map!{|name| File.join(Gemma::GemFromTemplate::TEMPLATE_ROOT,name)}
129
134
  end
130
135
 
131
136
  puts "creating gem in #{gt.destination_path}"
132
137
  gt.create_gem(templates)
133
- puts "gem created; to get started, see the following TODO tags:"
138
+ puts 'gem created; to get started, see the following TODO tags:'
134
139
  Gemma::Utility.rgrep(/TODO/, gt.destination_path)
@@ -1,17 +1,18 @@
1
+ # frozen_string_literal: true
2
+ require 'English'
1
3
  require 'shellwords'
2
4
 
3
- require 'gemma/version'
4
- require 'gemma/utility'
5
- require 'gemma/options'
6
- require 'gemma/rake_tasks'
5
+ require_relative 'gemma/version'
6
+ require_relative 'gemma/utility'
7
+ require_relative 'gemma/options'
8
+ require_relative 'gemma/rake_tasks'
7
9
 
8
10
  # Load default Rakefile plugins:
9
- require 'gemma/rake_tasks/plugin'
10
- require 'gemma/rake_tasks/rdoc_tasks'
11
- require 'gemma/rake_tasks/yard_tasks'
12
- require 'gemma/rake_tasks/minitest_tasks'
13
- require 'gemma/rake_tasks/gem_tasks'
14
-
15
- require 'gemma/conventions'
16
- require 'gemma/gem_from_template'
11
+ require_relative 'gemma/rake_tasks/plugin'
12
+ require_relative 'gemma/rake_tasks/rdoc_tasks'
13
+ require_relative 'gemma/rake_tasks/yard_tasks'
14
+ require_relative 'gemma/rake_tasks/minitest_tasks'
15
+ require_relative 'gemma/rake_tasks/gem_tasks'
17
16
 
17
+ require_relative 'gemma/conventions'
18
+ require_relative 'gemma/gem_from_template'
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Gemma
2
3
  #
3
4
  # Methods to check input against accepted conventions.
4
5
  #
5
6
  # For help on extensions:
6
7
  # * http://nokogiri.org/tutorials/installing_nokogiri.html explains how to
7
- # prepare several unices to build native extensions.
8
+ # prepare several unices to build native extensions.
8
9
  #
9
10
  # General objectives for gemma:
10
11
  # * follow and promote accepted conventions where obvious
@@ -29,7 +30,7 @@ module Gemma
29
30
  #
30
31
  # @return [Boolean]
31
32
  #
32
- def self.good_gem_name? gem_name
33
+ def self.good_gem_name?(gem_name)
33
34
  gem_name =~ /^[a-z0-9]+[a-z0-9_\-]*$/
34
35
  end
35
36
 
@@ -39,9 +40,8 @@ module Gemma
39
40
  #
40
41
  # @return [String]
41
42
  #
42
- def self.gem_name_to_module_name gem_name
43
- gem_name.gsub(/(?:^|_|-)([a-z0-9])/) { $1.upcase }
43
+ def self.gem_name_to_module_name(gem_name)
44
+ gem_name.gsub(/(?:^|_|-)([a-z0-9])/) { Regexp.last_match(1).upcase }
44
45
  end
45
46
  end
46
47
  end
47
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'erb'
2
3
  require 'fileutils'
3
4
  require 'yaml'
@@ -17,7 +18,7 @@ module Gemma
17
18
  # there are files that occur in multiple templates (files in earlier
18
19
  # templates are overwritten by those in later templates, at present).
19
20
  #
20
- BUILTIN_TEMPLATES = %w(base executable minitest)
21
+ BUILTIN_TEMPLATES = %w(base executable minitest).freeze
21
22
 
22
23
  def initialize
23
24
  @gem_name = nil
@@ -39,7 +40,7 @@ module Gemma
39
40
  # @return [Boolean]
40
41
  #
41
42
  def good_gem_name?
42
- Conventions.good_gem_name? self.gem_name
43
+ Conventions.good_gem_name? gem_name
43
44
  end
44
45
 
45
46
  #
@@ -49,7 +50,7 @@ module Gemma
49
50
  # @return [String]
50
51
  #
51
52
  def module_name
52
- @module_name || Conventions.gem_name_to_module_name(self.gem_name)
53
+ @module_name || Conventions.gem_name_to_module_name(gem_name)
53
54
  end
54
55
 
55
56
  #
@@ -72,10 +73,10 @@ module Gemma
72
73
  attr_writer :dir_name
73
74
 
74
75
  #
75
- # Full path of root of the gem to be created.
76
+ # Full path of root of the gem to be created.
76
77
  #
77
78
  def destination_path
78
- File.expand_path(File.join('.',self.dir_name))
79
+ File.expand_path(File.join('.', dir_name))
79
80
  end
80
81
 
81
82
  #
@@ -84,25 +85,26 @@ module Gemma
84
85
  # @param [Array<String>] template_paths absolute paths of the template
85
86
  # directories to copy
86
87
  #
87
- def create_gem template_paths, destination_path=self.destination_path
88
- raise "destination #{destination_path} exists" if File.exists?(
89
- destination_path)
88
+ def create_gem(template_paths, destination_path = self.destination_path)
89
+ if File.exist?(destination_path)
90
+ raise "destination #{destination_path} exists"
91
+ end
90
92
 
91
93
  # Copy templates in.
92
94
  FileUtils.mkdir_p destination_path
93
- for path in template_paths
94
- FileUtils.cp_r File.join(path,'.'), destination_path
95
+ template_paths.each do |path|
96
+ FileUtils.cp_r File.join(path, '.'), destination_path
95
97
  end
96
98
 
97
99
  Dir.chdir destination_path do
98
- dirs = Dir["**/*"].select { |f| File.directory? f }.sort
100
+ dirs = Dir['**/*'].select { |f| File.directory? f }.sort
99
101
  dirs.grep(/gem_name/).each do |file|
100
102
  FileUtils.mv file, file.gsub(/gem_name/, gem_name)
101
103
  end
102
104
 
103
- files = (Dir["**/*"] + Dir["**/.*"]).select { |f| File.file? f }.sort
104
- FileUtils.chmod 0644, files
105
- FileUtils.chmod 0755, files.select{|f| File.dirname(f) == 'bin'}
105
+ files = (Dir['**/*'] + Dir['**/.*']).select { |f| File.file? f }.sort
106
+ FileUtils.chmod 0o644, files
107
+ FileUtils.chmod 0o755, files.select { |f| File.dirname(f) == 'bin' }
106
108
  files.each do |file|
107
109
  # Rename files with names that depend on the gem name.
108
110
  if file =~ /gem_name/
@@ -112,15 +114,14 @@ module Gemma
112
114
  end
113
115
 
114
116
  # Run erb to customize each file.
115
- if File.extname(file) == ".erb"
116
- erb_file = File.read file
117
- File.open file, "w" do |f|
118
- erb = ERB.new(erb_file)
119
- erb.filename = file
120
- f.puts erb.result(binding)
121
- end
122
- FileUtils.mv file, file.sub(/\.erb$/, '')
117
+ next unless File.extname(file) == '.erb'
118
+ erb_file = File.read file
119
+ File.open file, 'w' do |f|
120
+ erb = ERB.new(erb_file)
121
+ erb.filename = file
122
+ f.puts erb.result(binding)
123
123
  end
124
+ FileUtils.mv file, file.sub(/\.erb$/, '')
124
125
  end
125
126
  end
126
127
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Gemma
2
3
  #
3
4
  # Helpers for processing command line arguments.
@@ -35,7 +36,7 @@ module Gemma
35
36
  #
36
37
  # The +options+ parameter takes an array of arguments; to split a string
37
38
  # into the appropriate form, you can use the +Shellwords+ module in the ruby
38
- # standard library.
39
+ # standard library.
39
40
  #
40
41
  # @example
41
42
  # Gemma::Options.extract(%w(-a), %w(-a foo bar.txt))
@@ -52,42 +53,45 @@ module Gemma
52
53
  # @return [ExtractResult] contains the argument for the given option and the
53
54
  # rest of the options
54
55
  #
55
- def self.extract names, options
56
+ def self.extract(names, options)
56
57
  options = options.dup
57
58
  result = nil
58
59
  done = []
59
60
 
60
61
  until options.empty?
61
62
  x = options.shift
62
- if x == '--' then
63
+ if x == '--'
63
64
  # Stop at the '--' terminator.
64
65
  done << x
65
66
  break
66
- elsif x =~ /^(--[^=]+)/ then
67
- if names.member?($1) then
67
+ elsif x =~ /^(--[^=]+)/
68
+ if names.member?(Regexp.last_match(1))
68
69
  # Found a long style option; look for its argument (if any).
69
- if x =~ /=(.*)$/ then
70
- result = $1
71
- elsif !options.empty? && options.first !~ /^-./
72
- result = options.shift
73
- else
74
- result = ''
75
- end
70
+ result = \
71
+ if x =~ /=(.*)$/
72
+ Regexp.last_match(1)
73
+ elsif !options.empty? && options.first !~ /^-./
74
+ options.shift
75
+ else
76
+ ''
77
+ end
76
78
  else
77
79
  done << x
78
80
  end
79
- elsif x =~ /^(-(.))(.*)/ then
81
+ elsif x =~ /^(-(.))(.*)/
80
82
  # Found a short style option; this may actually represent several
81
83
  # options; look for matching short options.
82
- name, letter, rest = $1, $2, $3
84
+ name = Regexp.last_match(1)
85
+ rest = Regexp.last_match(3)
83
86
  if names.member?(name)
84
- if rest.length > 0
85
- result = rest
86
- elsif !options.empty? && options.first !~ /^-./
87
- result = options.shift
88
- else
89
- result = ''
90
- end
87
+ result = \
88
+ if rest.length.positive?
89
+ rest
90
+ elsif !options.empty? && options.first !~ /^-./
91
+ options.shift
92
+ else
93
+ ''
94
+ end
91
95
  else
92
96
  done << x
93
97
  end
@@ -101,4 +105,3 @@ module Gemma
101
105
  end
102
106
  end
103
107
  end
104
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rake/clean'
2
3
 
3
4
  module Gemma
@@ -16,10 +17,9 @@ module Gemma
16
17
  # # ... other tasks ...
17
18
  #
18
19
  class RakeTasks
19
-
20
20
  # Alias for new.
21
21
  class <<self
22
- alias :with_gemspec_file :new
22
+ alias with_gemspec_file new
23
23
  end
24
24
 
25
25
  #
@@ -35,11 +35,11 @@ module Gemma
35
35
  #
36
36
  # @private
37
37
  #
38
- def initialize gemspec, &block
38
+ def initialize(gemspec)
39
39
  # Load gemspec.
40
40
  if gemspec.is_a?(String)
41
41
  @gemspec_file_name = gemspec
42
- @gemspec = Gem::Specification::load(gemspec_file_name)
42
+ @gemspec = Gem::Specification.load(gemspec_file_name)
43
43
  elsif gemspec.is_a?(Gem::Specification)
44
44
  @gemspec_file_name = nil
45
45
  @gemspec = gemspec
@@ -51,13 +51,13 @@ module Gemma
51
51
  create_default_plugins
52
52
 
53
53
  # Let the user add more plugins and alter settings.
54
- block.call(self) if block_given?
54
+ yield(self) if block_given?
55
55
 
56
56
  @plugins.values.each do |plugin|
57
57
  begin
58
58
  plugin.create_rake_tasks
59
59
  rescue
60
- warn "plugin #{plugin.class} failed: #{$!}"
60
+ warn "plugin #{plugin.class} failed: #{$ERROR_INFO}"
61
61
  end
62
62
  end
63
63
  end
@@ -86,22 +86,30 @@ module Gemma
86
86
  #
87
87
  # @return [RDocTasks]
88
88
  #
89
- def rdoc; @plugins[:rdoc] end
89
+ def rdoc
90
+ @plugins[:rdoc]
91
+ end
90
92
 
91
93
  #
92
94
  # @return [MinitestTasks]
93
95
  #
94
- def test; @plugins[:test] end
96
+ def test
97
+ @plugins[:test]
98
+ end
95
99
 
96
100
  #
97
101
  # @return [YardTasks]
98
102
  #
99
- def yard; @plugins[:yard] end
103
+ def yard
104
+ @plugins[:yard]
105
+ end
100
106
 
101
107
  #
102
108
  # @return [GemTasks]
103
109
  #
104
- def gem; @plugins[:gem] end
110
+ def gem
111
+ @plugins[:gem]
112
+ end
105
113
 
106
114
  protected
107
115
 
@@ -109,7 +117,8 @@ module Gemma
109
117
  @plugins[:rdoc] = Gemma::RakeTasks::RDocTasks.new(gemspec)
110
118
  @plugins[:test] = Gemma::RakeTasks::MinitestTasks.new(gemspec)
111
119
  @plugins[:yard] = Gemma::RakeTasks::YardTasks.new(gemspec)
112
- @plugins[:gem] = Gemma::RakeTasks::GemTasks.new(gemspec,gemspec_file_name)
120
+ @plugins[:gem] =
121
+ Gemma::RakeTasks::GemTasks.new(gemspec, gemspec_file_name)
113
122
  end
114
123
  end
115
124
  end