gemify 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/gemify +6 -1
  2. data/lib/gemify.rb +20 -10
  3. metadata +2 -2
data/bin/gemify CHANGED
@@ -1,5 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
- require 'gemify'
2
+ begin
3
+ require 'gemify'
4
+ rescue LoadError
5
+ require 'lib/gemify'
6
+ end
7
+
3
8
  begin
4
9
  Gemify.new.main
5
10
  rescue Gemify::Exit
@@ -1,17 +1,19 @@
1
1
  require 'rubygems'
2
+ require 'rubygems/builder'
2
3
  require 'yaml'
3
4
 
4
5
  class Gemify
5
6
  class Exit < StandardError;end
7
+ MANIFEST = ["MANIFEST", "Manifest.txt", ".manifest"]
6
8
  REQUIRED = [:name, :summary, :version]
7
9
  OPTIONAL = [:author, :email, :homepage, :rubyforge_project, :dependencies]
8
10
  ALL = REQUIRED+OPTIONAL
9
11
  REPLACE = {:rubyforge_project => "RubyForge project"}
10
12
  def initialize
11
13
  @settings = {}
12
- @all = (@bin = Dir["bin/**/*"]) + Dir["lib/**/*"]
14
+ @bin = Dir["bin/**/*"]
13
15
 
14
- if @all.empty?
16
+ if files.empty?
15
17
  puts "Can't find anything to make a gem out of..."
16
18
  raise Exit
17
19
  end
@@ -23,6 +25,14 @@ class Gemify
23
25
  @result = "Can't read .gemified"
24
26
  end
25
27
 
28
+ def files
29
+ @files ||= if m=MANIFEST.detect{|x|File.exist?(x)}
30
+ File.read(m).split(/\r?\n/)
31
+ else
32
+ @bin + Dir["lib/**/*"]
33
+ end
34
+ end
35
+
26
36
  def main
27
37
  loop do
28
38
  menu
@@ -49,15 +59,15 @@ class Gemify
49
59
  when 1
50
60
  puts "Write all your dependencies here, split by ENTER and"
51
61
  puts "press ENTER twice when you're done:"
52
- @dependencies = $stdin.gets($/*2).strip.split($/)
53
- @dependencies = nil if @dependencies.empty?
62
+ @settings[:dependencies] = $stdin.gets($/*2).strip.split($/)
63
+ @settings.delete(:dependencies) if @settings[:dependencies].empty?
54
64
  @result = "Updated 'dependencies'"
55
65
  next
56
66
  when 2
57
67
  save
58
68
  next
59
69
  when 3
60
- @result = "Included files:#{$/}" + @all.join($/)
70
+ @result = "Included files:#{$/}" + files.join($/)
61
71
  next
62
72
  end
63
73
 
@@ -85,19 +95,19 @@ class Gemify
85
95
 
86
96
  def build
87
97
  Gem::Builder.new(Gem::Specification.new do |s|
98
+ (@settings.delete(:dependencies)||[]).each do |dep|
99
+ s.add_dependency dep
100
+ end
101
+
88
102
  @settings.each { |key, value| s.send("#{key}=",value) }
89
103
  s.platform = Gem::Platform::RUBY
90
- s.files = @all
104
+ s.files = files
91
105
  s.bindir = "bin"
92
106
  s.require_path = "lib"
93
107
 
94
108
  unless @bin.empty?
95
109
  s.executables = @bin.map{|x|x[4..-1]}
96
110
  end
97
-
98
- (@dependencies||[]).each do |dep|
99
- s.add_dependency dep
100
- end
101
111
  end).build
102
112
  raise Exit
103
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Holm
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-15 00:00:00 +01:00
12
+ date: 2008-03-23 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15