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"
- BUILD_TO_DIRNAME =
"pkg"
- NotFoundError =
Class.new(ArgumentError)
- LoadError =
Class.new(ArgumentError)
- CmdError =
Class.new(RuntimeError)
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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ggem/gemspec.rb', line 20 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.
18 19 20 |
# File 'lib/ggem/gemspec.rb', line 18 def gem_file @gem_file end |
#gem_file_name ⇒ Object (readonly)
Returns the value of attribute gem_file_name.
18 19 20 |
# File 'lib/ggem/gemspec.rb', line 18 def gem_file_name @gem_file_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/ggem/gemspec.rb', line 17 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/ggem/gemspec.rb', line 17 def path @path end |
#push_host ⇒ Object (readonly)
Returns the value of attribute push_host.
18 19 20 |
# File 'lib/ggem/gemspec.rb', line 18 def push_host @push_host end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
17 18 19 |
# File 'lib/ggem/gemspec.rb', line 17 def version @version end |
#version_tag ⇒ Object (readonly)
Returns the value of attribute version_tag.
17 18 19 |
# File 'lib/ggem/gemspec.rb', line 17 def version_tag @version_tag end |
Instance Method Details
#run_build_cmd ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/ggem/gemspec.rb', line 38 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
46 47 48 |
# File 'lib/ggem/gemspec.rb', line 46 def run_install_cmd run_cmd("gem install #{@built_gem_path}") end |
#run_push_cmd ⇒ Object
50 51 52 |
# File 'lib/ggem/gemspec.rb', line 50 def run_push_cmd run_cmd("gem push #{@built_gem_path} --host #{@push_host}") end |