htauth 2.3.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +14 -0
  3. data/Manifest.txt +4 -28
  4. data/exe/htdigest-ruby +14 -0
  5. data/exe/htpasswd-ruby +14 -0
  6. data/htauth.gemspec +33 -0
  7. data/lib/htauth/algorithm.rb +30 -29
  8. data/lib/htauth/argon2.rb +45 -36
  9. data/lib/htauth/bcrypt.rb +12 -11
  10. data/lib/htauth/cli/digest.rb +42 -46
  11. data/lib/htauth/cli/passwd.rb +126 -115
  12. data/lib/htauth/cli.rb +5 -3
  13. data/lib/htauth/console.rb +9 -6
  14. data/lib/htauth/crypt.rb +11 -9
  15. data/lib/htauth/descendant_tracker.rb +11 -9
  16. data/lib/htauth/digest_entry.rb +22 -20
  17. data/lib/htauth/digest_file.rb +25 -18
  18. data/lib/htauth/entry.rb +3 -1
  19. data/lib/htauth/error.rb +6 -5
  20. data/lib/htauth/file.rb +35 -39
  21. data/lib/htauth/md5.rb +35 -34
  22. data/lib/htauth/passwd_entry.rb +26 -24
  23. data/lib/htauth/passwd_file.rb +26 -21
  24. data/lib/htauth/plaintext.rb +7 -5
  25. data/lib/htauth/sha1.rb +9 -7
  26. data/lib/htauth/version.rb +3 -1
  27. data/lib/htauth.rb +29 -28
  28. metadata +15 -133
  29. data/Rakefile +0 -29
  30. data/bin/htdigest-ruby +0 -12
  31. data/bin/htpasswd-ruby +0 -12
  32. data/spec/algorithm_spec.rb +0 -7
  33. data/spec/argon2_spec.rb +0 -28
  34. data/spec/bcrypt_spec.rb +0 -32
  35. data/spec/cli/digest_spec.rb +0 -149
  36. data/spec/cli/passwd_spec.rb +0 -346
  37. data/spec/crypt_spec.rb +0 -11
  38. data/spec/digest_entry_spec.rb +0 -59
  39. data/spec/digest_file_spec.rb +0 -64
  40. data/spec/md5_spec.rb +0 -11
  41. data/spec/passwd_entry_spec.rb +0 -172
  42. data/spec/passwd_file_spec.rb +0 -84
  43. data/spec/plaintext_spec.rb +0 -11
  44. data/spec/sha1_spec.rb +0 -10
  45. data/spec/spec_helper.rb +0 -25
  46. data/spec/test.add.digest +0 -3
  47. data/spec/test.add.passwd +0 -3
  48. data/spec/test.delete.digest +0 -1
  49. data/spec/test.delete.passwd +0 -1
  50. data/spec/test.original.digest +0 -2
  51. data/spec/test.original.passwd +0 -2
  52. data/spec/test.update.digest +0 -2
  53. data/spec/test.update.passwd +0 -2
  54. data/tasks/default.rake +0 -250
  55. data/tasks/this.rb +0 -208
  56. /data/{LICENSE → LICENSE.txt} +0 -0
@@ -1,84 +0,0 @@
1
- require 'spec_helper'
2
- require 'htauth/passwd_file'
3
- require 'tempfile'
4
-
5
- describe HTAuth::PasswdFile do
6
-
7
- before(:each) do
8
- @tf = Tempfile.new("rpasswrd-passwd")
9
- @tf.write(IO.read(PASSWD_ORIGINAL_TEST_FILE))
10
- @tf.close
11
- @passwd_file = HTAuth::PasswdFile.new(@tf.path)
12
-
13
- @tf2 = Tempfile.new("rpasswrd-passwd-empty")
14
- @tf2.close
15
- @empty_passwd_file = HTAuth::PasswdFile.new(@tf2.path)
16
- end
17
-
18
- after(:each) do
19
- @tf2.close(true)
20
- @tf.close(true)
21
- end
22
-
23
- it "can add a new entry to an already existing passwd file" do
24
- @passwd_file.add_or_update("charlie", "c secret", "sha1")
25
- _(@passwd_file.contents).must_equal IO.read(PASSWD_ADD_TEST_FILE)
26
- end
27
-
28
- it "can tell if an entry already exists in the passwd file" do
29
- _(@passwd_file.has_entry?("alice")).must_equal true
30
- _(@passwd_file.has_entry?("david")).must_equal false
31
- end
32
-
33
- it "can update an entry in an already existing passwd file, algorithm can change" do
34
- @passwd_file.add_or_update("alice", "a new secret", "sha1")
35
- _(@passwd_file.contents).must_equal IO.read(PASSWD_UPDATE_TEST_FILE)
36
- end
37
-
38
- it "can update an entry in an already existing passwd file, algorithm and arguments can change" do
39
- @passwd_file.add_or_update("brenda", "b secret", "bcrypt")
40
- entry = @passwd_file.fetch("brenda")
41
- _(entry.algorithm.cost).must_equal(::HTAuth::Bcrypt::DEFAULT_APACHE_COST)
42
- @passwd_file.add_or_update("brenda", "b secret", "bcrypt", :cost => 12)
43
- entry = @passwd_file.fetch("brenda")
44
- _(entry.algorithm.cost).must_equal(12)
45
- end
46
-
47
- it "fetches a copy of an entry" do
48
- _(@passwd_file.fetch("alice").to_s).must_equal "alice:$apr1$DghnA...$CsPcgerfsI/Ryy0AOAJtb0"
49
- end
50
-
51
- it "raises an error if an attempt is made to alter a non-existent file" do
52
- _ { HTAuth::PasswdFile.new("some-file") }.must_raise(HTAuth::FileAccessError)
53
- end
54
-
55
- # this test will only work on systems that have /etc/ssh_host_rsa_key
56
- it "raises an error if an attempt is made to open a file where no permissions are granted" do
57
- _ { HTAuth::PasswdFile.new("/etc/ssh_host_rsa_key") }.must_raise(HTAuth::FileAccessError)
58
- end
59
-
60
- it "deletes an entry" do
61
- @passwd_file.delete("bob")
62
- _(@passwd_file.contents).must_equal IO.read(PASSWD_DELETE_TEST_FILE)
63
- end
64
-
65
- it "checks authentication of an entry - true" do
66
- _(@passwd_file.authenticated?("alice", "a secret")).must_equal true
67
- end
68
-
69
- it "checks authentication of an entry - false" do
70
- _(@passwd_file.authenticated?("alice", "the wrong secret")).must_equal false
71
- end
72
-
73
-
74
- it "is usable in a ruby manner and yields itself when opened" do
75
- HTAuth::PasswdFile.open(@tf.path) do |pf|
76
- pf.add_or_update("alice", "a new secret", "md5")
77
- pf.delete('bob')
78
- end
79
- lines = IO.readlines(@tf.path)
80
- _(lines.size).must_equal 1
81
- _(lines.first.split(':').first).must_equal "alice"
82
- _(lines.first.split(':').last).must_match( /\$apr1\$/ )
83
- end
84
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
- require 'htauth/plaintext'
3
-
4
- describe HTAuth::Plaintext do
5
- it "encrypts the same way that apache does" do
6
- apache_result = "a secret"
7
- pt = HTAuth::Plaintext.new
8
- _(pt.encode("a secret")).must_equal apache_result
9
- end
10
- end
11
-
data/spec/sha1_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe HTAuth::Sha1 do
4
- it "encrypts the same way that apache does" do
5
- apache_result = "{SHA}ZrnlrvmM7ZCOV3FAvM7la89NKbk="
6
- sha1 = HTAuth::Sha1.new
7
- _(sha1.encode("a secret")).must_equal apache_result
8
- end
9
- end
10
-
data/spec/spec_helper.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'simplecov'
2
- SimpleCov.start if ENV['COVERAGE']
3
-
4
- require 'minitest/autorun'
5
- require 'minitest/pride'
6
-
7
- PASSWD_ORIGINAL_TEST_FILE = File.join(File.dirname(__FILE__), "test.original.passwd")
8
- PASSWD_ADD_TEST_FILE = File.join(File.dirname(__FILE__), "test.add.passwd")
9
- PASSWD_UPDATE_TEST_FILE = File.join(File.dirname(__FILE__), "test.update.passwd")
10
- PASSWD_DELETE_TEST_FILE = File.join(File.dirname(__FILE__), "test.delete.passwd")
11
- PASSWD_COMMENTED_TEST_FILE = File.join(File.dirname(__FILE__), "test.comments.passwd")
12
-
13
- DIGEST_ORIGINAL_TEST_FILE = File.join(File.dirname(__FILE__), "test.original.digest")
14
- DIGEST_ADD_TEST_FILE = File.join(File.dirname(__FILE__), "test.add.digest")
15
- DIGEST_UPDATE_TEST_FILE = File.join(File.dirname(__FILE__), "test.update.digest")
16
- DIGEST_DELETE_TEST_FILE = File.join(File.dirname(__FILE__), "test.delete.digest")
17
- DIGEST_COMMENTED_TEST_FILE = File.join(File.dirname(__FILE__), "test.comments.digest")
18
-
19
- require 'stringio'
20
- class ConsoleIO < StringIO
21
- def noecho(&block)
22
- yield self
23
- end
24
- end
25
- require 'htauth'
data/spec/test.add.digest DELETED
@@ -1,3 +0,0 @@
1
- bob:htauth:fcbeab6821d2ab3b00934c958db0fd1e
2
- alice:htauth:2f361db93147d84831eb34f19d05bfbb
3
- charlie:htauth-new:1ec9da72c45d9140949f338dc537c089
data/spec/test.add.passwd DELETED
@@ -1,3 +0,0 @@
1
- alice:$apr1$DghnA...$CsPcgerfsI/Ryy0AOAJtb0
2
- bob:SFUkhjaJc18KA
3
- charlie:{SHA}Cqrkk2no+ly0vYClUp49OJQahSE=
@@ -1 +0,0 @@
1
- bob:htauth:fcbeab6821d2ab3b00934c958db0fd1e
@@ -1 +0,0 @@
1
- alice:$apr1$DghnA...$CsPcgerfsI/Ryy0AOAJtb0
@@ -1,2 +0,0 @@
1
- bob:htauth:fcbeab6821d2ab3b00934c958db0fd1e
2
- alice:htauth:2f361db93147d84831eb34f19d05bfbb
@@ -1,2 +0,0 @@
1
- alice:$apr1$DghnA...$CsPcgerfsI/Ryy0AOAJtb0
2
- bob:SFUkhjaJc18KA
@@ -1,2 +0,0 @@
1
- bob:htauth:fcbeab6821d2ab3b00934c958db0fd1e
2
- alice:htauth:c32a4df25c6ecf75f3eaeb96771520de
@@ -1,2 +0,0 @@
1
- alice:{SHA}GnoUUjgrLF07/6L9lW2BcaDXxB0=
2
- bob:SFUkhjaJc18KA
data/tasks/default.rake DELETED
@@ -1,250 +0,0 @@
1
- # vim: syntax=ruby
2
- require 'rake/clean'
3
- require 'digest'
4
- #------------------------------------------------------------------------------
5
- # If you want to Develop on this project just run 'rake develop' and you'll
6
- # have all you need to get going. If you want to use bundler for development,
7
- # then run 'rake develop:using_bundler'
8
- #------------------------------------------------------------------------------
9
- namespace :develop do
10
-
11
- # Install all the development and runtime dependencies of this gem using the
12
- # gemspec.
13
- task :default => 'Gemfile' do
14
- require 'rubygems/dependency_installer'
15
- installer = ::Gem::DependencyInstaller.new
16
- puts "Installing bundler..."
17
- installer.install 'bundler'
18
- sh 'bundle install'
19
- puts "\n\nNow run 'rake test'"
20
- end
21
-
22
- # Create a Gemfile that just references the gemspec
23
- file 'Gemfile' => :gemspec do
24
- File.open( "Gemfile", "w+" ) do |f|
25
- f.puts "# DO NOT EDIT - This file is automatically generated"
26
- f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
27
- f.puts 'source "https://rubygems.org"'
28
- f.puts 'gemspec'
29
- end
30
- end
31
- end
32
- desc "Bootstrap development"
33
- task :develop => "develop:default"
34
-
35
- #------------------------------------------------------------------------------
36
- # Minitest - standard TestTask
37
- #------------------------------------------------------------------------------
38
- begin
39
- require 'minitest/test_task'
40
- Minitest::TestTask.create( :test) do |t|
41
- t.libs << "lib"
42
- t.libs << "spec"
43
- t.libs << "test"
44
- t.warning = true
45
- t.test_globs = "{test,spec}/**/{test_*,*_spec}.rb"
46
- end
47
-
48
- task :test_requirements
49
- task :test => :test_requirements
50
- task :default => :test
51
- rescue LoadError
52
- This.task_warning( 'test' )
53
- end
54
-
55
- #------------------------------------------------------------------------------
56
- # RDoc - standard rdoc rake task, although we must make sure to use a more
57
- # recent version of rdoc since it is the one that has 'tomdoc' markup
58
- #------------------------------------------------------------------------------
59
- begin
60
- gem 'rdoc' # otherwise we get the wrong task from stdlib
61
- require 'rdoc/task'
62
- RDoc::Task.new do |t|
63
- t.markup = 'tomdoc'
64
- t.rdoc_dir = 'doc'
65
- t.main = 'README.md'
66
- t.title = "#{This.name} #{This.version}"
67
- t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
68
- FileList['lib/**/*.rb'] )
69
- end
70
- rescue StandardError, LoadError
71
- This.task_warning( 'rdoc' )
72
- end
73
-
74
- #------------------------------------------------------------------------------
75
- # Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
76
- # for the moment only rcov is listed.
77
- #------------------------------------------------------------------------------
78
- begin
79
- require 'simplecov'
80
- desc 'Run tests with code coverage'
81
- task :coverage do
82
- ENV['COVERAGE'] = 'true'
83
- Rake::Task[:test].execute
84
- end
85
- CLOBBER << 'coverage' if File.directory?( 'coverage' )
86
- rescue LoadError
87
- This.task_warning( 'simplecov' )
88
- end
89
-
90
- #------------------------------------------------------------------------------
91
- # Manifest - We want an explicit list of thos files that are to be packaged in
92
- # the gem. Most of this is from Hoe.
93
- #------------------------------------------------------------------------------
94
- namespace 'manifest' do
95
- desc "Check the manifest"
96
- task :check => :clean do
97
- files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
98
- files = files.select{ |f| File.file?( f ) }
99
-
100
- tmp = "Manifest.tmp"
101
- File.open( tmp, 'w' ) do |f|
102
- f.puts files.join("\n")
103
- end
104
-
105
- begin
106
- sh "diff -du Manifest.txt #{tmp}"
107
- ensure
108
- rm tmp
109
- end
110
- puts "Manifest looks good"
111
- end
112
-
113
- desc "Generate the manifest"
114
- task :generate => :clean do
115
- files = %x[ git ls-files ].split("\n").sort
116
- files.reject! { |f| f =~ This.exclude_from_manifest }
117
- File.open( "Manifest.txt", "w" ) do |f|
118
- f.puts files.join("\n")
119
- end
120
- end
121
- end
122
-
123
- #------------------------------------------------------------------------------
124
- # Fixme - look for fixmes and report them
125
- #------------------------------------------------------------------------------
126
- namespace :fixme do
127
- task :default => 'manifest:check' do
128
- This.manifest.each do |file|
129
- next if file == __FILE__
130
- next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
131
- puts "FIXME: Rename #{file}" if file =~ /fixme/i
132
- IO.readlines( file ).each_with_index do |line, idx|
133
- prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
134
- puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
135
- end
136
- end
137
- end
138
-
139
- def fixme_project_root
140
- This.project_path( '../fixme' )
141
- end
142
-
143
- def fixme_project_path( subtree )
144
- fixme_project_root.join( subtree )
145
- end
146
-
147
- def local_fixme_files
148
- local_files = This.manifest.select { |p| p =~ %r|^tasks/| }
149
- local_files << ".semaphore/semaphore.yml"
150
- end
151
-
152
- def outdated_fixme_files
153
- local_fixme_files.select do |local|
154
- upstream = fixme_project_path( local )
155
- if upstream.exist? then
156
- if File.exist?( local ) then
157
- ( Digest::SHA256.file( local ) != Digest::SHA256.file( upstream ) )
158
- else
159
- true
160
- end
161
- end
162
- end
163
- end
164
-
165
- def fixme_up_to_date?
166
- outdated_fixme_files.empty?
167
- end
168
-
169
- desc "See if the fixme tools are outdated"
170
- task :outdated do
171
- if fixme_up_to_date? then
172
- puts "Fixme files are up to date."
173
- else
174
- outdated_fixme_files.each do |f|
175
- puts "#{f} is outdated"
176
- end
177
- end
178
- end
179
-
180
- desc "Update outdated fixme files"
181
- task :update do
182
- if fixme_up_to_date? then
183
- puts "Fixme files are already up to date."
184
- else
185
- puts "Updating fixme files:"
186
- outdated_fixme_files.each do |local|
187
- upstream = fixme_project_path( local )
188
- puts " * #{local}"
189
- FileUtils.cp( upstream, local )
190
- end
191
- puts "Use your git commands as appropriate."
192
- end
193
- end
194
- end
195
- desc "Look for fixmes and report them"
196
- task :fixme => "fixme:default"
197
-
198
- #------------------------------------------------------------------------------
199
- # Gem Specification
200
- #------------------------------------------------------------------------------
201
- # Really this is only here to support those who use bundler
202
- desc "Build the #{This.name}.gemspec file"
203
- task :gemspec do
204
- File.open( This.gemspec_file, "wb+" ) do |f|
205
- f.puts "# DO NOT EDIT - This file is automatically generated"
206
- f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
207
- f.write This.platform_gemspec.to_ruby
208
- end
209
- end
210
-
211
- # .rbc files from ruby 2.0
212
- CLOBBER << "**/*.rbc"
213
-
214
- # The standard gem packaging task, everyone has it.
215
- require 'rubygems/package_task'
216
- ::Gem::PackageTask.new( This.platform_gemspec ) do
217
- # nothing
218
- end
219
-
220
- #------------------------------------------------------------------------------
221
- # Release - the steps we go through to do a final release, this is pulled from
222
- # a compbination of mojombo's rakegem, hoe and hoe-git
223
- #
224
- # 1) make sure we are on the main branch
225
- # 2) make sure there are no uncommitted items
226
- # 3) check the manifest and make sure all looks good
227
- # 4) build the gem
228
- # 5) do an empty commit to have the commit message of the version
229
- # 6) tag that commit as the version
230
- # 7) push main
231
- # 8) push the tag
232
- # 7) pus the gem
233
- #------------------------------------------------------------------------------
234
- task :release_check do
235
- unless `git branch` =~ /^\* main/
236
- abort "You must be on the main branch to release!"
237
- end
238
- unless `git status` =~ /^nothing to commit/m
239
- abort "Nope, sorry, you have unfinished business"
240
- end
241
- end
242
-
243
- desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
244
- task :release => [ :release_check, 'manifest:check', :gem ] do
245
- sh "git commit --allow-empty -a -m 'Release #{This.version}'"
246
- sh "git tag -a -m 'v#{This.version}' v#{This.version}"
247
- sh "git push origin main"
248
- sh "git push origin v#{This.version}"
249
- sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
250
- end
data/tasks/this.rb DELETED
@@ -1,208 +0,0 @@
1
- require 'pathname'
2
-
3
- # Public: A Class containing all the metadata and utilities needed to manage a
4
- # ruby project.
5
- class ThisProject
6
- # The name of this project
7
- attr_accessor :name
8
-
9
- # The author's name
10
- attr_accessor :author
11
-
12
- # The email address of the author(s)
13
- attr_accessor :email
14
-
15
- # The homepage of this project
16
- attr_accessor :homepage
17
-
18
- # The regex of files to exclude from the manifest
19
- attr_accessor :exclude_from_manifest
20
-
21
- # The hash of Gem::Specifications keyed' by platform
22
- attr_accessor :gemspecs
23
-
24
- # Public: Initialize ThisProject
25
- #
26
- # Yields self
27
- def initialize(&block)
28
- @exclude_from_manifest = Regexp.union(/\.(git|DS_Store|semaphore)/,
29
- /^(doc|coverage|pkg|tmp|Gemfile(\.lock)?)/,
30
- /^[^\/]+\.gemspec/,
31
- /\.(swp|jar|bundle|so|rvmrc|travis.yml|byebug_history|fossa.yml|ruby-version)$/,
32
- /~$/)
33
- @gemspecs = Hash.new
34
- yield self if block_given?
35
- end
36
-
37
- # Public: return the version of ThisProject
38
- #
39
- # Search the ruby files in the project looking for the one that has the
40
- # version string in it. This does not eval any code in the project, it parses
41
- # the source code looking for the string.
42
- #
43
- # Returns a String version
44
- def version
45
- [ "lib/#{ name }.rb", "lib/#{ name }/version.rb" ].each do |v|
46
- path = project_path( v )
47
- line = path.read[/^\s*VERSION\s*=\s*.*/]
48
- if line then
49
- return line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
50
- end
51
- end
52
- end
53
-
54
- # Internal: Return a section of an RDoc file with the given section name
55
- #
56
- # path - the relative path in the project of the file to parse
57
- # section_name - the section out of the file from which to parse data
58
- #
59
- # Retuns the text of the section as an array of paragrphs.
60
- def section_of( file, section_name )
61
- re = /^[=#]+ (.*)$/
62
- sectional = project_path( file )
63
- parts = sectional.read.split( re )[1..-1]
64
- parts.map! { |p| p.strip }
65
-
66
- sections = Hash.new
67
- Hash[*parts].each do |k,v|
68
- sections[k] = v.split("\n\n")
69
- end
70
- return sections[section_name]
71
- end
72
-
73
- # Internal: print out a warning about the give task
74
- def task_warning( task )
75
- warn "WARNING: '#{task}' tasks are not defined. Please run 'rake develop'"
76
- end
77
-
78
- # Internal: Return the full path to the file that is relative to the project
79
- # root.
80
- #
81
- # path - the relative path of the file from the project root
82
- #
83
- # Returns the Pathname of the file
84
- def project_path( *relative_path )
85
- project_root.join( *relative_path )
86
- end
87
-
88
- # Internal: The absolute path of this file
89
- #
90
- # Returns the Pathname of this file.
91
- def this_file_path
92
- Pathname.new( __FILE__ ).expand_path
93
- end
94
-
95
- # Internal: The root directory of this project
96
- #
97
- # This is defined as being the directory that is in the path of this project
98
- # that has the first Rakefile
99
- #
100
- # Returns the Pathname of the directory
101
- def project_root
102
- this_file_path.ascend do |p|
103
- rakefile = p.join( 'Rakefile' )
104
- return p if rakefile.exist?
105
- end
106
- end
107
-
108
- # Internal: Returns the contents of the Manifest.txt file as an array
109
- #
110
- # Returns an Array of strings
111
- def manifest
112
- manifest_file = project_path( "Manifest.txt" )
113
- abort "You need a Manifest.txt" unless manifest_file.readable?
114
- manifest_file.readlines.map { |l| l.strip }
115
- end
116
-
117
- # Internal: Return the files that define the extensions
118
- #
119
- # Returns an Array
120
- def extension_conf_files
121
- manifest.grep( /extconf.rb\Z/ )
122
- end
123
-
124
- # Internal: Returns the gemspace associated with the current ruby platform
125
- def platform_gemspec
126
- gemspecs.fetch(platform) { This.ruby_gemspec }
127
- end
128
-
129
- def core_gemspec
130
- Gem::Specification.new do |spec|
131
- spec.name = name
132
- spec.version = version
133
- spec.author = author
134
- spec.email = email
135
- spec.homepage = homepage
136
-
137
- spec.summary = summary
138
- spec.description = description
139
- spec.license = license
140
-
141
- spec.files = manifest
142
- spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
143
- spec.test_files = spec.files.grep(/^spec/)
144
-
145
- spec.extra_rdoc_files += spec.files.grep(/(txt|rdoc|md)$/)
146
- spec.rdoc_options = [ "--main" , 'README.md',
147
- "--markup", "tomdoc" ]
148
-
149
- spec.required_ruby_version = '>= 2.3.0'
150
- end
151
- end
152
-
153
- # Internal: Return the gemspec for the ruby platform
154
- def ruby_gemspec( core = core_gemspec, &block )
155
- yielding_gemspec( 'ruby', core, &block )
156
- end
157
-
158
- # Internal: Return the gemspec for the jruby platform
159
- def java_gemspec( core = core_gemspec, &block )
160
- yielding_gemspec( 'java', core, &block )
161
- end
162
-
163
- # Internal: give an initial spec and a key, create a new gemspec based off of
164
- # it.
165
- #
166
- # This will force the new gemspecs 'platform' to be that of the key, since the
167
- # only reason you would have multiple gemspecs at this point is to deal with
168
- # different platforms.
169
- def yielding_gemspec( key, core )
170
- spec = gemspecs[key] ||= core.dup
171
- spec.platform = key
172
- yield spec if block_given?
173
- return spec
174
- end
175
-
176
- # Internal: Return the platform of ThisProject at the current moment in time.
177
- def platform
178
- (RUBY_PLATFORM == "java") ? 'java' : Gem::Platform::RUBY
179
- end
180
-
181
- # Internal: Return the DESCRIPTION section of the README.rdoc file
182
- def description_section
183
- section_of( 'README.md', 'DESCRIPTION')
184
- end
185
-
186
- # Internal: Return the summary text from the README
187
- def summary
188
- description_section.first
189
- end
190
-
191
- # Internal: Return the full description text from the README
192
- def description
193
- description_section.join(" ").tr("\n", ' ').gsub(/[{}]/,'').gsub(/\[[^\]]+\]/,'') # strip rdoc
194
- end
195
-
196
- def license
197
- license_file = project_path("LICENSE")
198
- line = license_file.readlines.first
199
- line.split(/\s+/).first
200
- end
201
-
202
- # Internal: The path to the gemspec file
203
- def gemspec_file
204
- project_path( "#{ name }.gemspec" )
205
- end
206
- end
207
-
208
- This = ThisProject.new
File without changes