push_gem 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c0428af9cde7137790b134f5c1bb74dbfb31255acae921a6d456dcc0cf6324b7
4
+ data.tar.gz: f3ae380d5d565358d2727a563b477f451b6389c3d7afb891219bfabd79e2b263
5
+ SHA512:
6
+ metadata.gz: d20d693ffe5f15758c50a18387319d432b8644a48ad855d64ec7ec5765ce9f2d6ac48c7b146cb77a754f8712c84c1227b92bde0e4272d339df6ea54354c2e4be
7
+ data.tar.gz: 97bbf3db2bf58ae0064601c68f7c98a9f0b8ca1b07c4c9285b89217780610fa1aaa00abffdf65414e3b96ca576c7c95560c2134c6fea82f8ea764c92ad902eb3
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2025-11-24
4
+
5
+ - gem作成
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 milkeclair
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # PushGem
2
+
3
+ Rakefile > `require "push_gem"`
4
+ Console > `rake gem:push[author_name,gem_name]` to push a gem to RubyGems.org
5
+ Console > `rake gem:check[author_name,gem_name]` to run tests for a gem
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/push_gem"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PushGem
4
+ VERSION = "1.0.0"
5
+ end
data/lib/push_gem.rb ADDED
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dotenv"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+ require "bundler/gem_tasks"
7
+ require_relative "push_gem/version"
8
+
9
+ class PushGem
10
+ attr_accessor :author, :gem
11
+
12
+ def initialize(author:, gem:)
13
+ @author = author
14
+ @gem = gem
15
+ end
16
+
17
+ def push
18
+ validate_author!
19
+ validate_gem!
20
+
21
+ system("bundle install")
22
+
23
+ puts "Pushing #{gem} gem..."
24
+
25
+ build_gem
26
+ push_to_github
27
+ push_to_rubygems
28
+
29
+ puts "Successfully pushed #{gem} gem to both GitHub Packages and RubyGems.org"
30
+ end
31
+
32
+ def check
33
+ validate_author!
34
+ validate_gem!
35
+
36
+ RSpec::Core::RakeTask.new(:spec) do |t|
37
+ t.verbose = false
38
+ end
39
+
40
+ RuboCop::RakeTask.new
41
+
42
+ puts "Running tests for #{gem} gem..."
43
+
44
+ Rake::Task["spec"].invoke
45
+ Rake::Task["rubocop"].invoke
46
+ end
47
+
48
+ private
49
+
50
+ def validate_author!
51
+ abort("Gem author is required") if @author.nil? || @author.strip.empty?
52
+ end
53
+
54
+ def validate_gem!
55
+ abort("Gem name is required") if @gem.nil? || @gem.strip.empty?
56
+ end
57
+
58
+ def build_gem
59
+ puts "--- build ---"
60
+ abort("Failed to build gem") unless system(build_gem_command)
61
+ end
62
+
63
+ def push_to_github
64
+ puts "--- push to github packages ---"
65
+ abort("Failed to push gem to GitHub Packages") unless system(github_push_command)
66
+ end
67
+
68
+ def push_to_rubygems
69
+ puts "--- push to rubygems.org ---"
70
+ abort("Failed to push gem to RubyGems.org") unless system(rubygems_push_command)
71
+ end
72
+
73
+ def build_gem_command
74
+ "rake build"
75
+ end
76
+
77
+ def github_push_command
78
+ "gem push --key github --host https://rubygems.pkg.github.com/#{author} " \
79
+ "pkg/#{gem}-#{Object.const_get(camelized_gem_name)::VERSION}.gem"
80
+ end
81
+
82
+ def rubygems_push_command
83
+ "gem push --host https://rubygems.org " \
84
+ "pkg/#{gem}-#{Object.const_get(camelized_gem_name)::VERSION}.gem"
85
+ end
86
+
87
+ def camelized_gem_name
88
+ gem.split("_").map(&:capitalize).join
89
+ end
90
+ end
91
+
92
+ task :"gem:push", [:author, :gem] do |_t, args|
93
+ Dotenv.load
94
+
95
+ author = args[:author] || ENV.fetch("GEM_AUTHOR", nil)
96
+ gem = args[:gem] || ENV.fetch("GEM_NAME", nil)
97
+
98
+ pusher = PushGem.new(author:, gem:)
99
+ pusher.push
100
+ end
101
+
102
+ task :"gem:check", [:author, :gem] do |_t, args|
103
+ Dotenv.load
104
+
105
+ author = args[:author] || ENV.fetch("GEM_AUTHOR", nil)
106
+ gem = args[:gem] || ENV.fetch("GEM_NAME", nil)
107
+
108
+ pusher = PushGem.new(author:, gem:)
109
+ pusher.check
110
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: push_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - milkeclair
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: dotenv
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rubocop
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ description: A Ruby gem to push gems to rubygems.org and github
69
+ email:
70
+ - milkeclair.black@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - CHANGELOG.md
76
+ - LICENSE.txt
77
+ - README.md
78
+ - Rakefile
79
+ - lib/push_gem.rb
80
+ - lib/push_gem/version.rb
81
+ homepage: https://github.com/milkeclair/push_gem
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ homepage_uri: https://github.com/milkeclair/push_gem
86
+ rubygems_mfa_required: 'true'
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 3.4.0
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.6.9
102
+ specification_version: 4
103
+ summary: gem push
104
+ test_files: []