gem-dandy 0.1.0 → 0.2.0
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.
- data/.gitignore +22 -0
- data/LICENSE +1 -1
- data/README.rdoc +36 -2
- data/VERSION +1 -1
- data/gem-dandy.gemspec +20 -14
- data/lib/gem_dandy.rb +31 -9
- data/lib/gem_dandy/command.rb +9 -0
- data/lib/gem_dandy/config_file.rb +21 -0
- data/lib/gem_dandy/configuration.rb +55 -0
- data/lib/gem_dandy/output.rb +11 -0
- data/lib/gem_dandy/rubyforge_profile.rb +28 -22
- metadata +10 -5
data/.gitignore
ADDED
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,9 +1,43 @@
|
|
1
1
|
= gem-dandy
|
2
2
|
|
3
|
-
|
3
|
+
Utilities to use to manage your gems.
|
4
|
+
|
5
|
+
|
6
|
+
== Usage
|
7
|
+
|
8
|
+
=== Push To Multiple Profiles On rubygems.org
|
9
|
+
|
10
|
+
GemDandy provides facilities to make pushing gems to multiple profiles on rubygems.org easier. The jeweler
|
11
|
+
gem utilizes a config file at ~/.gem/credentials that can only contain a single API key. GemDandy can manage
|
12
|
+
the active API key contained in this configuration.
|
13
|
+
|
14
|
+
Configure one or more profiles:
|
15
|
+
|
16
|
+
gemdandy config --profile ninja-loss -key 12345
|
17
|
+
|
18
|
+
gemdandy config --profile midas -key 23456
|
19
|
+
|
20
|
+
Use any value for the profile parameter as it is just a name for you to identify the profile.
|
21
|
+
|
22
|
+
Confirm the API key(s) are set up correctly:
|
23
|
+
|
24
|
+
gemdandy profile --list # => ninja-loss: 12345\nmidas: 23456
|
25
|
+
|
26
|
+
gemdandy profile --show ninja-loss #=> ninja-loss: 12345
|
27
|
+
|
28
|
+
gemdandy profile --show ninja-loss #=> midas: 23456
|
29
|
+
|
30
|
+
Switch to a specific profile:
|
31
|
+
|
32
|
+
gemdandy profile --switch ninja-loss
|
33
|
+
|
34
|
+
Check the active profile:
|
35
|
+
|
36
|
+
gemdandy profile --active
|
37
|
+
|
4
38
|
|
5
39
|
== Note on Patches/Pull Requests
|
6
|
-
|
40
|
+
|
7
41
|
* Fork the project.
|
8
42
|
* Make your feature addition or bug fix.
|
9
43
|
* Add tests for it. This is important so I don't break it in a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/gem-dandy.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gem-dandy}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ninja-loss"]
|
@@ -16,29 +16,35 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = ["gemdandy"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
|
19
|
+
"README.rdoc"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/gemdandy",
|
29
|
+
"gem-dandy.gemspec",
|
30
|
+
"lib/gem_dandy.rb",
|
31
|
+
"lib/gem_dandy/command.rb",
|
32
|
+
"lib/gem_dandy/config_file.rb",
|
33
|
+
"lib/gem_dandy/configuration.rb",
|
34
|
+
"lib/gem_dandy/output.rb",
|
35
|
+
"lib/gem_dandy/rubyforge_profile.rb",
|
36
|
+
"spec/gem-dandy_spec.rb",
|
37
|
+
"spec/spec.opts",
|
38
|
+
"spec/spec_helper.rb"
|
34
39
|
]
|
35
40
|
s.homepage = %q{http://github.com/midas/gem-dandy}
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
42
|
s.require_paths = ["lib"]
|
37
43
|
s.rubygems_version = %q{1.3.7}
|
38
44
|
s.summary = %q{Utilities to use to manage your gems.}
|
39
45
|
s.test_files = [
|
40
46
|
"spec/gem-dandy_spec.rb",
|
41
|
-
|
47
|
+
"spec/spec_helper.rb"
|
42
48
|
]
|
43
49
|
|
44
50
|
if s.respond_to? :specification_version then
|
data/lib/gem_dandy.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
require 'trollop'
|
2
2
|
require 'yaml'
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
3
|
+
# Dir.glob "#{File.dirname __FILE__}/gem_dandy/*.rb" do |f|
|
4
|
+
# require File.expand_path( "#{File.dirname __FILE__}/gem_dandy/" +
|
5
|
+
# File.basename( f, '.rb' ) )
|
6
|
+
# end
|
8
7
|
|
9
8
|
module GemDandy
|
9
|
+
autoload :Command, 'gem_dandy/command'
|
10
|
+
autoload :ConfigFile, 'gem_dandy/config_file'
|
11
|
+
autoload :Configuration, 'gem_dandy/configuration'
|
12
|
+
autoload :Output, 'gem_dandy/output'
|
13
|
+
autoload :RubyforgeProfile, 'gem_dandy/rubyforge_profile'
|
14
|
+
|
10
15
|
VERSION = File.read( "#{File.dirname __FILE__}/../VERSION" ).chomp
|
11
16
|
end
|
12
17
|
|
13
|
-
SUB_COMMANDS = %w(profile)
|
18
|
+
SUB_COMMANDS = %w(config profile)
|
14
19
|
global_opts = Trollop::options do
|
15
20
|
version "v0.1.0 (c) 2010 ninja-loss"
|
16
21
|
banner <<-EOS
|
@@ -20,26 +25,43 @@ Usage:
|
|
20
25
|
gemdandy [sub-command] [options]
|
21
26
|
|
22
27
|
sub-commands:
|
28
|
+
config
|
23
29
|
profile
|
24
30
|
|
31
|
+
(For help with a sub-command: gemdandy [sub-command] -h)
|
32
|
+
|
25
33
|
options:
|
26
34
|
EOS
|
27
35
|
# opt :dry_run, "Perform a dry run", :short => "-n"
|
28
36
|
stop_on SUB_COMMANDS
|
29
37
|
end
|
30
38
|
|
31
|
-
|
39
|
+
# Get the sub-command and its options
|
40
|
+
#
|
41
|
+
cmd = ARGV.shift || ''
|
32
42
|
cmd_opts = case( cmd )
|
33
|
-
when "
|
43
|
+
when "config"
|
44
|
+
Trollop::options do
|
45
|
+
opt :clear, "Clear the ~/.gemdandyrc file"
|
46
|
+
opt :profile, "The name of the profile", :type => String
|
47
|
+
opt :key, "The RubyForge API key", :type => String
|
48
|
+
end
|
49
|
+
when "profile"
|
34
50
|
Trollop::options do
|
35
51
|
opt :active, "Show the currently active Rubyforge profile"
|
36
|
-
opt :
|
52
|
+
opt :list, "List all of the configured Rubyforge profiles / API keys"
|
53
|
+
opt :show, "Show the configured Rubyforge API key for profile <s>", :type => String, :short => "-z"
|
54
|
+
opt :switch, "Switch the currently active Rubyforge profile to <s>", :type => String
|
37
55
|
end
|
38
56
|
else
|
39
57
|
Trollop::die "unknown command #{cmd.inspect}"
|
40
58
|
end
|
41
59
|
|
60
|
+
# Execute the command
|
61
|
+
#
|
42
62
|
case( cmd )
|
63
|
+
when "config"
|
64
|
+
GemDandy::Configuration.new( cmd_opts ).perform_action
|
43
65
|
when "profile"
|
44
66
|
GemDandy::RubyforgeProfile.new( cmd_opts ).perform_action
|
45
67
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module GemDandy
|
2
|
+
module ConfigFile
|
3
|
+
def api_keys
|
4
|
+
return File.exists?( gemdandy_rc_file ) ?
|
5
|
+
YAML::load( File.open( gemdandy_rc_file ) ) :
|
6
|
+
{}
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_api_key( identifier )
|
10
|
+
api_keys[identifier]
|
11
|
+
end
|
12
|
+
|
13
|
+
def gemdandy_rc_file
|
14
|
+
"#{File.expand_path( '~' )}/#{config_file_name}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def config_file_name
|
18
|
+
'.gemdandyrc'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module GemDandy
|
2
|
+
class Configuration < Command
|
3
|
+
include ConfigFile
|
4
|
+
include Output
|
5
|
+
|
6
|
+
def perform_action
|
7
|
+
if options[:clear_given]
|
8
|
+
clear_config
|
9
|
+
else
|
10
|
+
confirm_add_to_config_options
|
11
|
+
add_to_config( options[:profile], options[:key] )
|
12
|
+
confirm_add_to_config_success
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def add_to_config( profile, key )
|
19
|
+
keys = api_keys.merge( profile => key )
|
20
|
+
remove_config_file
|
21
|
+
write_config_file( keys )
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear_config
|
25
|
+
remove_config_file
|
26
|
+
write_config_file( {} )
|
27
|
+
report "Successfully cleared the ~/#{config_file_name} file"
|
28
|
+
end
|
29
|
+
|
30
|
+
def confirm_add_to_config_success
|
31
|
+
new_key = find_api_key( options[:profile] )
|
32
|
+
msg = new_key == options[:key] ?
|
33
|
+
"Successfully added #{options[:key]} key to #{options[:profile]} profile" :
|
34
|
+
"Failed to add new Ruby forge API key: #{options[:key]}"
|
35
|
+
report msg
|
36
|
+
end
|
37
|
+
|
38
|
+
def remove_config_file
|
39
|
+
if File.exists?( gemdandy_rc_file )
|
40
|
+
`rm #{gemdandy_rc_file}`
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def write_config_file( key_hash )
|
45
|
+
File.open( gemdandy_rc_file, 'w' ) do |f|
|
46
|
+
f.write YAML::dump( key_hash )
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def confirm_add_to_config_options
|
51
|
+
die( :profile, "is required" ) unless options[:profile]
|
52
|
+
die( :key, "is required" ) unless options[:key]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,10 +1,7 @@
|
|
1
1
|
module GemDandy
|
2
|
-
class RubyforgeProfile
|
3
|
-
|
4
|
-
|
5
|
-
def initialize( options )
|
6
|
-
@options = options
|
7
|
-
end
|
2
|
+
class RubyforgeProfile < Command
|
3
|
+
include ConfigFile
|
4
|
+
include Output
|
8
5
|
|
9
6
|
def perform_action
|
10
7
|
perform_checks
|
@@ -12,6 +9,11 @@ module GemDandy
|
|
12
9
|
if options[:switch_given]
|
13
10
|
switch_profile_to( options[:switch] )
|
14
11
|
display_active_profile
|
12
|
+
elsif options[:list_given]
|
13
|
+
list_configured_profiles
|
14
|
+
elsif options[:show_given]
|
15
|
+
confirm_show_configured_profile_options
|
16
|
+
show_configured_profile( options[:show] )
|
15
17
|
else
|
16
18
|
display_active_profile
|
17
19
|
end
|
@@ -21,19 +23,35 @@ module GemDandy
|
|
21
23
|
|
22
24
|
def perform_checks
|
23
25
|
unless File.exists?( gemdandy_rc_file )
|
24
|
-
|
26
|
+
die "The ~/.gemdandyrc file does not exist. Please run 'gemdandy config -p <profile-name> -k <key>"
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
def display_active_profile
|
29
|
-
|
31
|
+
report "Active RubyForge Profile: #{current_profile}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def list_configured_profiles
|
35
|
+
report api_keys.sort.map { |k,v| "#{k}: #{v}" }.join( "\n" )
|
36
|
+
end
|
37
|
+
|
38
|
+
def show_configured_profile( identifier )
|
39
|
+
key = find_api_key( identifier )
|
40
|
+
msg = (key.nil? || key.empty?) ?
|
41
|
+
"There is no RubyForge API key configured for the #{identifier} profile" :
|
42
|
+
"#{identifier}: #{key}"
|
43
|
+
report msg
|
44
|
+
end
|
45
|
+
|
46
|
+
def confirm_show_configured_profile_options
|
47
|
+
die( :show, "is required" ) unless options[:show]
|
30
48
|
end
|
31
49
|
|
32
50
|
def switch_profile_to( identifier )
|
33
|
-
|
51
|
+
report "Switching active RubyForge profile to #{options[:switch]}..."
|
34
52
|
credentials_hash = deployed_key_hash || {}
|
35
53
|
unless key = find_api_key( identifier )
|
36
|
-
|
54
|
+
die "#{identifier} is not a configured RubyForge API profile."
|
37
55
|
end
|
38
56
|
credentials_hash.merge!( credentials_key => key )
|
39
57
|
remove_credentials_file
|
@@ -52,10 +70,6 @@ module GemDandy
|
|
52
70
|
end
|
53
71
|
end
|
54
72
|
|
55
|
-
def api_keys
|
56
|
-
YAML::load( File.open( gemdandy_rc_file ) )
|
57
|
-
end
|
58
|
-
|
59
73
|
def deployed_key_hash
|
60
74
|
return File.exists?( gem_credentials_file ) ?
|
61
75
|
YAML::load( File.open( gem_credentials_file ) ) :
|
@@ -70,18 +84,10 @@ module GemDandy
|
|
70
84
|
:rubygems_api_key
|
71
85
|
end
|
72
86
|
|
73
|
-
def find_api_key( identifier )
|
74
|
-
api_keys[identifier]
|
75
|
-
end
|
76
|
-
|
77
87
|
def current_profile
|
78
88
|
api_keys.invert[deployed_key]
|
79
89
|
end
|
80
90
|
|
81
|
-
def gemdandy_rc_file
|
82
|
-
"#{File.expand_path( '~' )}/.gemdandyrc"
|
83
|
-
end
|
84
|
-
|
85
91
|
def gem_credentials_file
|
86
92
|
"#{File.expand_path( '~' )}/.gem/credentials"
|
87
93
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-dandy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- ninja-loss
|
@@ -61,6 +61,7 @@ extra_rdoc_files:
|
|
61
61
|
- README.rdoc
|
62
62
|
files:
|
63
63
|
- .document
|
64
|
+
- .gitignore
|
64
65
|
- LICENSE
|
65
66
|
- README.rdoc
|
66
67
|
- Rakefile
|
@@ -68,6 +69,10 @@ files:
|
|
68
69
|
- bin/gemdandy
|
69
70
|
- gem-dandy.gemspec
|
70
71
|
- lib/gem_dandy.rb
|
72
|
+
- lib/gem_dandy/command.rb
|
73
|
+
- lib/gem_dandy/config_file.rb
|
74
|
+
- lib/gem_dandy/configuration.rb
|
75
|
+
- lib/gem_dandy/output.rb
|
71
76
|
- lib/gem_dandy/rubyforge_profile.rb
|
72
77
|
- spec/gem-dandy_spec.rb
|
73
78
|
- spec/spec.opts
|
@@ -77,8 +82,8 @@ homepage: http://github.com/midas/gem-dandy
|
|
77
82
|
licenses: []
|
78
83
|
|
79
84
|
post_install_message:
|
80
|
-
rdoc_options:
|
81
|
-
|
85
|
+
rdoc_options:
|
86
|
+
- --charset=UTF-8
|
82
87
|
require_paths:
|
83
88
|
- lib
|
84
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|