Module: SimpleGem
- Defined in:
- lib/tasks/simple_gem.rb,
lib/simple_gem/version.rb
Constant Summary collapse
- VERSION =
'0.0.2'
Class Attribute Summary collapse
Class Method Summary collapse
- .build_gem(target_dir) ⇒ Object
- .build_production_gem ⇒ Object
- .safe_create_dir(dir_name) ⇒ Object
- .tag(version) ⇒ Object
Class Attribute Details
.current_gemspec ⇒ Object
15 16 17 18 19 20 |
# File 'lib/tasks/simple_gem.rb', line 15 def current_gemspec if !@current_gemspec raise 'must define SimpleGem.current_gemspec' end @current_gemspec end |
.current_version ⇒ Object
8 9 10 11 12 13 |
# File 'lib/tasks/simple_gem.rb', line 8 def current_version if !@current_version raise 'must define SimpleGem.current_version' end @current_version end |
Class Method Details
.build_gem(target_dir) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tasks/simple_gem.rb', line 31 def build_gem(target_dir) print "Do you want to build version #{current_version} (Y/n): " input = STDIN.gets.strip if input.to_s[0,1] == 'Y' safe_create_dir(target_dir) spec = Gem::Specification.load(current_gemspec) spec.version = current_version builder = Gem::Builder.new(spec) gem_file = builder.build target_file = "#{target_dir}/#{gem_file}" File.rename gem_file, target_file puts "Successfully built #{gem_file} into #{target_dir}" [ current_version, target_file ] else raise %q{Aborting... update version file and run "rake build" again.} end end |
.build_production_gem ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/tasks/simple_gem.rb', line 50 def build_production_gem if !`git status -s`.strip.empty? raise 'There are uncommitted changes in the tree - commit before building' end build_gem 'gems' end |
.safe_create_dir(dir_name) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/tasks/simple_gem.rb', line 22 def safe_create_dir(dir_name) if File.exists?(dir_name) raise "#{dir_name} is not a directory" unless File.directory?(dir_name) else Dir.mkdir dir_name puts "* created directory #{dir_name}" end end |
.tag(version) ⇒ Object
58 59 60 61 |
# File 'lib/tasks/simple_gem.rb', line 58 def tag(version) version ||= current_version `git tag #{version}`.strip end |