sgem 1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d94c1b88cbfe5e9821939a0dba115b1a2ca44717
4
+ data.tar.gz: 928ea94f846d066de421a2501b94c1aef6c3e93c
5
+ SHA512:
6
+ metadata.gz: e1b55168c56a4398ff1169ccac2f7075570409ad8f4deb158b93c995a565aca3c1985f6a73dd4c548015d33193290eb3962beea0b77b3cd74e4310d0b2be64f5
7
+ data.tar.gz: 2aab3fd8d6f9fda0a811f6e378cdbb6a464038843e289749f621ccedc8fc275cb2c72b2a436c11ff55b9bfea7e7a16c8303a1ea717908eba27d9e6b4b37435b0
@@ -0,0 +1,55 @@
1
+ # sgem
2
+
3
+ `sgem` is a simple, minimalistic way to build and publish
4
+ [gems](http://rubygems.org) using [rake](http://rake.rubyforge.org).
5
+
6
+ `sgem` is based on the excellent [mg](https://github.com/sr/mg) (written by
7
+ [Ryan Tomayko](http://tomayko.com), extracted by
8
+ [Simon Rozet](http://atonie.org)).
9
+
10
+ ## Usage
11
+
12
+ In your Rakefile:
13
+
14
+ ```ruby
15
+ require 'sgem/auto'
16
+ ```
17
+
18
+ The following tasks are now available:
19
+
20
+ ```sh
21
+ rake archive # build archive into pkg/
22
+ rake gem # build gem into pkg/
23
+ rake gem:install # build and install as local gem
24
+ rake gem:publish # push the gem to rubygems.org
25
+ rake package # build gem and archive into pkg/
26
+ ```
27
+
28
+ If you do not trust `sgem` to automatically determine your gemspec, you may
29
+ provide it manually:
30
+
31
+ ```ruby
32
+ require 'sgem'
33
+
34
+ sgem 'project.gemspec'
35
+ ```
36
+
37
+ You may customize the output directory and archive format (as supported by
38
+ `git-archive`) through either Ruby:
39
+
40
+ ```ruby
41
+ require 'sgem/auto'
42
+
43
+ SGem.package_dir = 'dist'
44
+ SGem.archive_format = '.zip'
45
+ ```
46
+
47
+ ...or environment variables:
48
+
49
+ ```sh
50
+ $ DEST=dist ARCHIVE=.zip rake package
51
+ ```
52
+
53
+ ## License
54
+
55
+ `sgem` is free and unencumbered software released into the public domain.
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake'
4
+ require 'rake/clean'
5
+ require 'rake/tasklib'
6
+ require 'rubygems/specification'
7
+
8
+ # {SGem} is a simple, minimalistic way to build and publish gems using `rake`.
9
+ #
10
+ # {SGem} is based on the excellent [mg](https://github.com/sr/mg) (written by
11
+ # [Ryan Tomayko](http://tomayko.com), extracted by
12
+ # [Simon Rozet](http://atonie.org)).
13
+ class SGem < Rake::TaskLib
14
+ class << self
15
+ # @return [String] the default relative directory where {SGem} will place
16
+ # generated gems and archives unless otherwise specified
17
+ # @see SGem#package_dir
18
+ attr_accessor :package_dir
19
+
20
+ # @note This format must be supported by `git-archive`.
21
+ # @return [String] the default archive format for {SGem} to use unless
22
+ # otherwise specified
23
+ # @see SGem#archive_format
24
+ attr_accessor :archive_format
25
+ end
26
+
27
+ # @param spec [String] the gemspec for this instance of {SGem}
28
+ def initialize(spec)
29
+ @spec = Gem::Specification.load(spec)
30
+ define_tasks
31
+ end
32
+
33
+ # @return [String] the name of the gem for this instance of {SGem}
34
+ def name
35
+ @name ||= @spec.name
36
+ end
37
+
38
+ # @return [Gem::Version] the version of the gemspec for this instance of
39
+ # {SGem}
40
+ def version
41
+ @version ||= @spec.version
42
+ end
43
+
44
+ # @return [String] the relative directory where {SGem} will place generated
45
+ # gems and archives
46
+ def package_dir
47
+ return @dir if @dir
48
+ dir = ENV['DEST'] || self.class.package_dir || 'pkg/'
49
+ @dir = dir.end_with?('/') ? dir : "#{dir}/"
50
+ end
51
+
52
+ # @note This format must be supported by `git-archive`.
53
+ # @return [String] the archive format for {SGem} to use
54
+ def archive_format
55
+ @format ||= ENV['ARCHIVE'] || self.class.archive_format || '.tar.gz'
56
+ end
57
+
58
+ # @param ext [String] the extension to apply
59
+ # @return [String] the package name with the given extension
60
+ private def package(ext)
61
+ "#{package_dir}#{name}-#{version}#{ext}"
62
+ end
63
+
64
+ # Defines the {SGem} `rake` tasks.
65
+ # @return [void]
66
+ private def define_tasks
67
+ directory package_dir
68
+ CLOBBER.include(package_dir)
69
+
70
+ desc 'build and install as local gem'
71
+ task 'gem:install' => package('.gem') do
72
+ sh "gem install #{package(".gem")}"
73
+ end
74
+
75
+ desc "build gem into #{package_dir}"
76
+ task :gem => package('.gem')
77
+
78
+ desc "build archive into #{package_dir}"
79
+ task :archive => package(archive_format)
80
+
81
+ desc "build gem and archive into #{package_dir}"
82
+ task :package => ['.gem', archive_format].map { |ext| package(ext) }
83
+
84
+ file package(archive_format) => package_dir do |f|
85
+ sh "git archive --prefix=#{name}-#{version}/ -o #{f.name} HEAD"
86
+ end
87
+
88
+ file package('.gem') => package_dir do |f|
89
+ sh "gem build #{name}.gemspec"
90
+ mv File.basename(f.name), f.name
91
+ end
92
+
93
+ desc 'push the gem to rubygems.org'
94
+ task 'gem:publish' => package('.gem') do
95
+ %i(test spec).each { |t| t.invoke if Rake::Task.task_defined?(t) }
96
+ sh "gem push #{package('.gem')}"
97
+ end
98
+ end
99
+ end
100
+
101
+ module Kernel
102
+ # Creates a new instance of {SGem} with the given `gemspec`.
103
+ # @param spec [String] the gemspec for this instance of {SGem}
104
+ # @return [SGem] a new instance of {SGem}
105
+ def sgem(spec)
106
+ SGem.new(spec)
107
+ end unless method_defined?(:sgem)
108
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../sgem'
4
+
5
+ if spec = Dir.glob("#{Dir.pwd}/*.gemspec").first
6
+ sgem spec
7
+ else
8
+ warn 'sgem/auto: no gemspec found'
9
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SGem
4
+ # The semantic version of SGem.
5
+ VERSION = '1.0.0'
6
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/sgem/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'sgem'
7
+ spec.version = SGem::VERSION
8
+ spec.summary = 'a simple, minimalistic way to build and publish gems'
9
+ spec.description = spec.summary
10
+
11
+ spec.authors = ['Ryan Tomayko', 'Simon Rozet', 'Nicolas Sanguinetti',
12
+ 'Chris Wanstrath', 'Robin Owen']
13
+ spec.email = 'vthrenody@gmail.com'
14
+ spec.homepage = 'https://github.com/vthrenody/sgem'
15
+
16
+ spec.files = %w(sgem.gemspec) + Dir['*.md', 'lib/**/*.rb']
17
+ spec.require_path = 'lib'
18
+ spec.license = 'Unlicense'
19
+
20
+ spec.add_dependency 'rake'
21
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sgem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Tomayko
8
+ - Simon Rozet
9
+ - Nicolas Sanguinetti
10
+ - Chris Wanstrath
11
+ - Robin Owen
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2017-02-20 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rake
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ description: a simple, minimalistic way to build and publish gems
32
+ email: vthrenody@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - README.md
38
+ - UNLICENSE.md
39
+ - lib/sgem.rb
40
+ - lib/sgem/auto.rb
41
+ - lib/sgem/version.rb
42
+ - sgem.gemspec
43
+ homepage: https://github.com/vthrenody/sgem
44
+ licenses:
45
+ - Unlicense
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.6.8
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: a simple, minimalistic way to build and publish gems
67
+ test_files: []