Module: SimpleGem
- Defined in:
- lib/tasks/simple_gem.rb,
lib/simple_gem/version.rb
Constant Summary collapse
- VERSION =
'1.1.0'
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.downcase.start_with? 'y' safe_create_dir(target_dir) spec = Gem::Specification.load(current_gemspec) spec.version = current_version gem_file = Gem::Package.build(spec) 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 puts %q{Aborting... update version file and run "rake build" again.} exit end end |
.build_production_gem ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tasks/simple_gem.rb', line 50 def build_production_gem if !`git status -s`.strip.empty? print 'There are uncommitted changes in the tree... are you sure you want to continue (y/n): ' response = STDIN.gets.strip if !response.downcase.start_with? 'y' puts 'Build aborted' exit end 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
63 64 65 66 |
# File 'lib/tasks/simple_gem.rb', line 63 def tag(version) version ||= current_version `git tag #{version}`.strip end |