Class: GGem::Gemspec
- Inherits:
-
Object
- Object
- GGem::Gemspec
- Defined in:
- lib/ggem/gemspec.rb
Constant Summary collapse
- PUSH_HOST_META_KEY =
'allowed_push_host'
- DEFAULT_PUSH_HOST =
'https://rubygems.org'.freeze
- BUILD_TO_DIRNAME =
'pkg'.freeze
Instance Attribute Summary collapse
-
#gem_file ⇒ Object
readonly
Returns the value of attribute gem_file.
-
#gem_file_name ⇒ Object
readonly
Returns the value of attribute gem_file_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#push_host ⇒ Object
readonly
Returns the value of attribute push_host.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#version_tag ⇒ Object
readonly
Returns the value of attribute version_tag.
Instance Method Summary collapse
-
#initialize(root_path) ⇒ Gemspec
constructor
A new instance of Gemspec.
- #run_build_cmd ⇒ Object
- #run_install_cmd ⇒ Object
- #run_push_cmd ⇒ Object
Constructor Details
#initialize(root_path) ⇒ Gemspec
Returns a new instance of Gemspec.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ggem/gemspec.rb', line 15 def initialize(root_path) @root = Pathname.new(File.(root_path)) raise NotFoundError unless @root.exist? @path = Pathname.new(Dir[File.join(@root, "{,*}.gemspec")].first.to_s) raise NotFoundError unless @path.exist? @spec = load_gemspec(@path) @name = @spec.name @version = @spec.version @version_tag = "v#{@version}" @gem_file_name = "#{@name}-#{@version}.gem" @gem_file = File.join(BUILD_TO_DIRNAME, @gem_file_name) @built_gem_path = @root.join(@gem_file) @push_host = get_push_host(@spec) end |
Instance Attribute Details
#gem_file ⇒ Object (readonly)
Returns the value of attribute gem_file.
13 14 15 |
# File 'lib/ggem/gemspec.rb', line 13 def gem_file @gem_file end |
#gem_file_name ⇒ Object (readonly)
Returns the value of attribute gem_file_name.
13 14 15 |
# File 'lib/ggem/gemspec.rb', line 13 def gem_file_name @gem_file_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/ggem/gemspec.rb', line 12 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/ggem/gemspec.rb', line 12 def path @path end |
#push_host ⇒ Object (readonly)
Returns the value of attribute push_host.
13 14 15 |
# File 'lib/ggem/gemspec.rb', line 13 def push_host @push_host end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/ggem/gemspec.rb', line 12 def version @version end |
#version_tag ⇒ Object (readonly)
Returns the value of attribute version_tag.
12 13 14 |
# File 'lib/ggem/gemspec.rb', line 12 def version_tag @version_tag end |
Instance Method Details
#run_build_cmd ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ggem/gemspec.rb', line 33 def run_build_cmd run_cmd("gem build --verbose #{@path}").tap do gem_path = @root.join(@gem_file_name) run_cmd("mkdir -p #{@built_gem_path.dirname}") run_cmd("mv #{gem_path} #{@built_gem_path}") end end |
#run_install_cmd ⇒ Object
41 42 43 |
# File 'lib/ggem/gemspec.rb', line 41 def run_install_cmd run_cmd("gem install #{@built_gem_path}") end |
#run_push_cmd ⇒ Object
45 46 47 |
# File 'lib/ggem/gemspec.rb', line 45 def run_push_cmd run_cmd("gem push #{@built_gem_path} --host #{@push_host}") end |