gemify 0.2.4 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ --title Gemify
2
+ --exclude trollop
3
+ --no-highlight
4
+ README.md
@@ -0,0 +1,38 @@
1
+ == 0.3
2
+ * Gemify is now a gemspec editor!
3
+
4
+ == 0.2.4 - 2008-04-06
5
+ * Added Sake-task
6
+ * Added has_rdoc to the options (Ben Wyrosdick)
7
+ * Windows-support?
8
+ * Little re-write of lib/gemify.rb
9
+ * Added bin/gemify-manifest (David A. Cuadrad)
10
+ * Added option to disable interactivity (David A. Cuadrad)
11
+ * Binaries will now read from the manifest
12
+ * Added an option parser (David A. Cuadrad)
13
+ * Added option to build the gem using the VCS tree (David A. Cuadrad)
14
+ * The settings from .gemified will now read as correct type (David A. Cuadrad)
15
+ * Rubinius-support (no test/spec = can't verify, but I think so)
16
+
17
+ == 0.2.3 - 2008-03-23
18
+ * Require rubygems/builder (defunkt)
19
+ * Made it simpler to test in developement
20
+ * Dependencies should work properly
21
+ * Custom manifest
22
+
23
+ == 0.2.2 - 2008-02-15
24
+ * Quick-release to fix an error in 0.2.1
25
+
26
+ == 0.2.1 - 2008-02-15
27
+ * Added error-handing of .gemfied
28
+ * Fixed some dependecies-bugs
29
+
30
+ == 0.2.0 - 2008-02-09
31
+ * Added support for dependencies
32
+ * Raises Exit in stead of exiting
33
+ * Read/write changes in .gemified
34
+ * Skinny bin, fat lib
35
+ * Added a very fancy CLI
36
+
37
+ == 0.1.0 - 2008-02-07
38
+ * The first release. More like a POC-code
@@ -0,0 +1,91 @@
1
+ Gemify, the lightweight gemspec editor
2
+ ======================================
3
+
4
+ Overview
5
+ --------
6
+
7
+ Gemify is a simple tool which helps you create and manage your gemspecs.
8
+ Instead of messing with Rakefiles and adding yet another development
9
+ dependency (like Hoe, Echoe and Jeweler), Gemify takes a much less obtrusive
10
+ approach.
11
+
12
+ Gemify works directly on the .gemspec file. In fact, when you're using Gemify,
13
+ you're only using it as an editor. If you want, you could just edit the file
14
+ manually.
15
+
16
+ Getting started
17
+ ---------------
18
+
19
+ $ gem install gemify
20
+ $ cd myproject (might already have a gemspec)
21
+ $ gemify
22
+ Currently editing gemify.gemspec
23
+
24
+ Which task would you like to invoke?
25
+ 1) Change name (required) = gemify
26
+ 2) Change summary (required) = The lightweight gemspec editor
27
+ 3) Change version (required) = 0.3
28
+ 4) Change author = Magnus Holm
29
+ 5) Change email = judofyr@gmail.com
30
+ 6) Change homepage = http://dojo.rubyforge.org/
31
+ 7) Set dependencies
32
+
33
+ s) Save
34
+ r) Reload (discard unsaved changes)
35
+ m) Rename
36
+ l) List files
37
+
38
+ x) Exit
39
+
40
+ >
41
+
42
+ ### Manifest
43
+
44
+ Gemify helps you manage the manifest (files which will be included in the gem). It follows these rules:
45
+
46
+ * If there's a file called **MANIFEST**, **Manifest.txt** or **.manifest**, it
47
+ assumes this files contains a line-separated list of the manifest.
48
+
49
+ * If not, it checks if you're using Git, Mercurial, Darcs, Bazaar, Subversion
50
+ or CVS and uses the commited files.
51
+
52
+ * If not, it just includes all the files.
53
+
54
+ You can always run `gemify -m` to see the manifest, and if you don't like what
55
+ you see you should maintain a manifest file yourself. Every time you open
56
+ Gemify and save, it will update the manifest. You can also call `gemify -u`.
57
+
58
+ ### Dependencies
59
+
60
+ When you set dependencies, you can separate the version requirement by a
61
+ comma:
62
+
63
+ $ gemify
64
+ ...
65
+ > 7
66
+ Split by ENTER and press ENTER twice when you're done
67
+ > nokogiri
68
+ > rack, >= 1.0
69
+
70
+ ### Build and share a gem
71
+
72
+ Let's not reinvent the wheel, shall we?
73
+
74
+ $ gem build foo.gemspec
75
+ $ gem push foo.gem
76
+
77
+
78
+ Acknowledgements
79
+ ----------------
80
+
81
+ Thanks to [Pat Nakajima](http://patnakajima.com/) for reminding me that Gemify
82
+ still has its uses.
83
+
84
+
85
+ Contributors
86
+ ------------
87
+
88
+ * David A. Cuadrado
89
+ * Ben Wyrosdick
90
+ * Chris Wanstrath
91
+ * Pat Nakajima
data/bin/gemify CHANGED
@@ -1,45 +1,57 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.dirname(__FILE__)+"/../lib"
4
-
3
+ $:.unshift File.dirname(__FILE__) + '/../lib'
5
4
  require 'gemify'
6
- require 'optparse'
5
+ require 'trollop'
7
6
 
8
- options = {}
9
- options[:interactive] = true # Interactive by default
7
+ gemspec = nil
8
+ actions = [:new, :update, :manifest]
10
9
 
11
- parser = OptionParser.new do |opts|
12
- opts.banner = "Usage: #{opts.program_name} [options]"
13
- opts.separator ""
14
- opts.separator "Options:"
15
- opts.on("-h", "--help", "Shows this message") do |val|
16
- $stdout.puts opts
17
- exit(0)
18
- end
19
- opts.on("-I", "--no-interactive", "Automaticically builds the gem") do |val|
20
- options[:interactive] = false
21
- end
22
- opts.on("-c", "--from-vcs", "Use files from version control system" ) do |val|
23
- options[:vcs] = true
24
- end
10
+ opts = Trollop.options do
11
+ version "gemify 0.3"
12
+ banner <<-EOS
13
+ Usage: #{$0} [OPTION]... [FILE]
14
+ A simple gemspec editor
15
+
16
+ EOS
17
+
18
+ opt :new, "Create a new gemspec"
19
+ opt :update, "Update the manifest"
20
+ opt :manifest, "Dump the manifest"
25
21
  end
26
22
 
27
- begin
28
- parser.parse!(ARGV)
29
- rescue => e
30
- $stderr.puts "Error: #{e.message}"
31
- $stdout.puts parser
32
- exit -1
33
- end
23
+ action = opts.detect { |opt, val| actions.include?(opt) && val }
24
+ action = action[0] unless action.nil?
34
25
 
35
- begin
36
- gemify = Gemify.new
37
- gemify.from_vcs = !!options[:vcs]
38
- if not options[:interactive] and File.exist?(Gemify::SETTINGS)
39
- gemify.build!
26
+ if action == :new
27
+ # do nothing
28
+ elsif (arg = ARGV.shift).nil?
29
+ gemspecs = Dir['*.gemspec']
30
+ gemspec = case gemspecs.length
31
+ when 0
32
+ nil
33
+ when 1
34
+ gemspecs.first
40
35
  else
41
- gemify.main
36
+ gemspecs
42
37
  end
43
- rescue Gemify::Exit
44
- exit
38
+ elsif File.exists?(arg)
39
+ gemspec = arg
40
+ else
41
+ Trollop.die "No such file: #{arg}"
42
+ end
43
+
44
+ Trollop.die "Extra operand: #{ARGV[0]}" unless ARGV.empty?
45
+
46
+ cli = Gemify::CLI.load(gemspec)
47
+
48
+ case action
49
+ when :update
50
+ cli.update_manifest
51
+ cli.save
52
+ puts "Updated manifest (to #{cli.base.files.length} files)"
53
+ when :manifest
54
+ puts cli.base.inspect_files
55
+ else
56
+ cli.main
45
57
  end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{gemify}
5
+ s.version = "0.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Magnus Holm"]
9
+ s.date = %q{2010-01-23}
10
+ s.email = %q{judofyr@gmail.com}
11
+ s.files = [".yardopts", "CHANGELOG", "README.md", "bin/gemify", "gemify.gemspec", "lib/gemify.rb", "lib/gemify/base.rb", "lib/gemify/cli.rb", "lib/gemify/manifest.rb", "lib/trollop.rb", "spec/spec_helper.rb"]
12
+ s.homepage = %q{http://dojo.rubyforge.org/}
13
+ s.require_paths = ["lib"]
14
+ s.rubygems_version = %q{1.3.6}
15
+ s.summary = %q{The lightweight gemspec editor}
16
+ s.post_install_message = %q{** Gemify has changed since 0.2, please see http://dojo.rubyforge.org/}
17
+
18
+ if s.respond_to? :specification_version then
19
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
20
+ s.specification_version = 3
21
+
22
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
23
+ else
24
+ end
25
+ else
26
+ end
27
+ end
@@ -1,224 +1,27 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
1
3
  require 'rubygems'
2
4
  require 'rubygems/builder'
3
5
  require 'yaml'
6
+ require 'open3'
4
7
 
5
- require 'gemify/vcs'
8
+ require 'gemify/base'
9
+ require 'gemify/manifest'
10
+ require 'gemify/cli'
6
11
 
7
- class Gemify
8
- attr_accessor :from_vcs
9
-
10
- class Exit < StandardError;end
11
- SETTINGS = ".gemified"
12
- MANIFEST = ["MANIFEST", "Manifest.txt", ".manifest"]
13
- REQUIRED = [:name, :summary, :version]
14
- OPTIONAL = [:author, :email, :homepage, :rubyforge_project, :has_rdoc, :dependencies]
15
- ALL = REQUIRED+OPTIONAL
16
- REPLACE = {
17
- :rubyforge_project => "RubyForge project",
18
- :has_rdoc => "documentation",
19
- }
20
- TYPE = {
21
- :has_rdoc => :boolean,
22
- :dependencies => :array,
23
- }
24
-
25
- def initialize
26
- @settings = {}
27
- @from_vcs = false
12
+ module Gemify
13
+ class << self; attr_accessor :last_specification; end
14
+ end
28
15
 
29
- if File.exists? SETTINGS
30
- load!
31
- end
32
- end
33
-
34
- def files
35
- @files ||= if @from_vcs
36
- VCS.files
37
- elsif m=MANIFEST.detect{|x|File.exist?(x)}
38
- File.read(m).split(/\r?\n/)
16
+ # Force Gem::Specification to use Gemify::Base instead.
17
+ Gem::Specification.extend Module.new {
18
+ def new(*args, &blk)
19
+ if self == Gem::Specification
20
+ Gemify::Base.new(*args, &blk)
39
21
  else
40
- VCS.files(:unknown)
41
- end
42
- end
43
-
44
- def bin
45
- files.select { |file| file =~ /^bin\// }
46
- end
47
-
48
- def extensions
49
- files.select { |file| file =~ /extconf\.rb$/ }
50
- end
51
-
52
- def main
53
- loop do
54
- menu
55
- puts @result if @result
56
- @result = nil
57
- l=(o=gets).downcase[0]
58
- i=o.to_i
59
-
60
- case l
61
- when ?x
62
- raise Exit
63
- when ?b
64
- build!
65
- when ?s
66
- save!
67
- next
68
- when ?i
69
- @result = "Included files:#{$/}" + files.join($/)
70
- next
71
- end
72
-
73
- if (1..ALL.length).include? i
74
- set(ALL[i-1])
75
- next
76
- end
77
-
78
- @result = "Can't find the task named '#{o}'"
22
+ Gemify.last_specification = super
79
23
  end
80
24
  end
81
-
82
- def menu
83
- require_files!
84
- clear
85
- puts "Welcome to Gemify!"
86
- puts
87
- puts "Which task would you like to invoke?"
88
- ALL.each do |m|
89
- puts build_task(m)
90
- end
91
- puts
92
- puts "s) Save"
93
- puts "i) Show included files"
94
- puts
95
- puts "b) Build gem"
96
- puts "x) Exit"
97
- puts
98
- end
99
-
100
- ## Special tasks
101
-
102
- def build!
103
- require_files!
104
- Gem::Builder.new(Gem::Specification.new do |s|
105
- (@settings.delete(:dependencies)||[]).each do |dep|
106
- s.add_dependency dep
107
- end
108
-
109
- @settings.each { |key, value| s.send("#{key}=",value) }
110
- s.platform = Gem::Platform::RUBY
111
- s.files = files
112
- s.bindir = "bin"
113
- s.require_path = "lib"
25
+ }
114
26
 
115
- unless bin.empty?
116
- s.executables = bin.map{|x|x[4..-1]}
117
- end
118
-
119
- unless extensions.empty?
120
- s.extensions = extensions
121
- end
122
-
123
- end).build
124
- raise Exit
125
- end
126
-
127
- def load!
128
- @settings = YAML.load(File.read(SETTINGS))
129
- @settings.keys.each do |key|
130
- @settings[key] = value(key)
131
- end
132
- rescue Errno::EACCES
133
- @result = "Can't read #{SETTINGS}"
134
- end
135
-
136
- def save!
137
- File.open(SETTINGS,"w"){|f|f << YAML.dump(@settings)}
138
- @result = "Saved!"
139
- rescue Errno::EACCES
140
- @result = "Can't write to #{SETTINGS}"
141
- end
142
-
143
- def build_task(m)
144
- index = (ALL.index(m)||0)+1
145
- unless type(m) == :boolean
146
- verb,now = if @settings.keys.include?(m)
147
- ["Change"," = " + inspect_setting(m)]
148
- else
149
- ["Set",""]
150
- end
151
- else
152
- verb, now = ["Toogle"," = " + inspect_setting(m)]
153
- end
154
- req = REQUIRED.include?(m) ? " (required)" : ""
155
- "#{index}) #{verb} #{show(m)}#{req}#{now}"
156
- end
157
-
158
- def clear
159
- system("cls") || print("\e[H\e[2J")
160
- end
161
-
162
- def set(m)
163
- menu
164
- case type(m)
165
- when :array
166
- puts "Split by ENTER and press ENTER twice when you're done"
167
- puts "> #{show(m).capitalize}: "
168
- @settings[m] = $stdin.gets($/*2).strip.split($/)
169
- @settings.delete(m) if @settings[m].empty?
170
- when :boolean
171
- @settings[m] = !@settings[m]
172
- when :string
173
- print "> #{show(m).capitalize}: "
174
- @settings[m] = $stdin.gets.strip
175
- @settings.delete(m) if @settings[m].empty?
176
- end
177
- @result = "Updated '#{m}'"
178
- end
179
-
180
- def gets
181
- print("> ")
182
- $stdin.gets.strip
183
- end
184
-
185
- def show(m)
186
- REPLACE[m]||m.to_s
187
- end
188
-
189
- def type(m)
190
- TYPE[m]||:string
191
- end
192
-
193
- def value(m)
194
- i=@settings[m]
195
- case type(m)
196
- when :array
197
- i.to_a
198
- when :boolean
199
- !!i
200
- when :string
201
- i.to_s
202
- end
203
- end
204
-
205
- def inspect_setting(m)
206
- i=@settings[m]
207
- case type(m)
208
- when :array
209
- i.join(", ")
210
- when :boolean
211
- (i||false).to_s
212
- when :string
213
- i.to_s
214
- end
215
- end
216
-
217
- protected
218
- def require_files!
219
- if files.empty?
220
- puts "Can't find anything to make a gem out of..."
221
- raise Exit
222
- end
223
- end
224
- end
27
+ Gem::DefaultUserInteraction.ui = Gem::SilentUI.new