gem-dandy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 ninja-loss
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = gem-dandy
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 ninja-loss. See LICENSE for details.
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "gem-dandy"
8
+ gem.summary = %Q{Utilities to use to manage your gems.}
9
+ gem.description = %Q{Enjoy Gem management.}
10
+ gem.email = "ninja-loss@gmail.com"
11
+ gem.homepage = "http://github.com/midas/gem-dandy"
12
+ gem.authors = ["ninja-loss"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency "trollop", "1.16.2"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+ task :spec => :check_dependencies
35
+
36
+ task :default => :spec
37
+
38
+ require 'rake/rdoctask'
39
+ Rake::RDocTask.new do |rdoc|
40
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "gem-dandy #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("#{File.dirname __FILE__}/../lib/gem_dandy")
@@ -0,0 +1,60 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{gem-dandy}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["ninja-loss"]
12
+ s.date = %q{2010-11-09}
13
+ s.default_executable = %q{gemdandy}
14
+ s.description = %q{Enjoy Gem management.}
15
+ s.email = %q{ninja-loss@gmail.com}
16
+ s.executables = ["gemdandy"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bin/gemdandy",
28
+ "gem-dandy.gemspec",
29
+ "lib/gem_dandy.rb",
30
+ "lib/gem_dandy/rubyforge_profile.rb",
31
+ "spec/gem-dandy_spec.rb",
32
+ "spec/spec.opts",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/midas/gem-dandy}
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.7}
38
+ s.summary = %q{Utilities to use to manage your gems.}
39
+ s.test_files = [
40
+ "spec/gem-dandy_spec.rb",
41
+ "spec/spec_helper.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
50
+ s.add_runtime_dependency(%q<trollop>, ["= 1.16.2"])
51
+ else
52
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
53
+ s.add_dependency(%q<trollop>, ["= 1.16.2"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
57
+ s.add_dependency(%q<trollop>, ["= 1.16.2"])
58
+ end
59
+ end
60
+
@@ -0,0 +1,45 @@
1
+ require 'trollop'
2
+ require 'yaml'
3
+ # require File.expand_path( "#{File.dirname __FILE__}/gem_dandy/rubyforge_profile" )
4
+ Dir.glob "#{File.dirname __FILE__}/gem_dandy/*.rb" do |f|
5
+ require File.expand_path( "#{File.dirname __FILE__}/gem_dandy/" +
6
+ File.basename( f, '.rb' ) )
7
+ end
8
+
9
+ module GemDandy
10
+ VERSION = File.read( "#{File.dirname __FILE__}/../VERSION" ).chomp
11
+ end
12
+
13
+ SUB_COMMANDS = %w(profile)
14
+ global_opts = Trollop::options do
15
+ version "v0.1.0 (c) 2010 ninja-loss"
16
+ banner <<-EOS
17
+ Managing Gems does not have to be scary.
18
+
19
+ Usage:
20
+ gemdandy [sub-command] [options]
21
+
22
+ sub-commands:
23
+ profile
24
+
25
+ options:
26
+ EOS
27
+ # opt :dry_run, "Perform a dry run", :short => "-n"
28
+ stop_on SUB_COMMANDS
29
+ end
30
+
31
+ cmd = ARGV.shift || '' # get the subcommand
32
+ cmd_opts = case( cmd )
33
+ when "profile" # parse delete options
34
+ Trollop::options do
35
+ opt :active, "Show the currently active Rubyforge profile"
36
+ opt :switch, "Switch the currently active Rubyforge profile to <s>", :type => String
37
+ end
38
+ else
39
+ Trollop::die "unknown command #{cmd.inspect}"
40
+ end
41
+
42
+ case( cmd )
43
+ when "profile"
44
+ GemDandy::RubyforgeProfile.new( cmd_opts ).perform_action
45
+ end
@@ -0,0 +1,89 @@
1
+ module GemDandy
2
+ class RubyforgeProfile
3
+ attr_reader :options
4
+
5
+ def initialize( options )
6
+ @options = options
7
+ end
8
+
9
+ def perform_action
10
+ perform_checks
11
+
12
+ if options[:switch_given]
13
+ switch_profile_to( options[:switch] )
14
+ display_active_profile
15
+ else
16
+ display_active_profile
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def perform_checks
23
+ unless File.exists?( gemdandy_rc_file )
24
+ Trollop::die "The ~/.gemdandyrc file does not exist. Please run 'gemdandy config -p <profile-name> -k <key>"
25
+ end
26
+ end
27
+
28
+ def display_active_profile
29
+ puts "Active RubyForge Profile: #{current_profile}"
30
+ end
31
+
32
+ def switch_profile_to( identifier )
33
+ puts "Switching active RubyForge profile to #{options[:switch]}..."
34
+ credentials_hash = deployed_key_hash || {}
35
+ unless key = find_api_key( identifier )
36
+ Trollop::die "#{identifier} is not a configured RubyForge API profile."
37
+ end
38
+ credentials_hash.merge!( credentials_key => key )
39
+ remove_credentials_file
40
+ write_credentials_file( credentials_hash )
41
+ end
42
+
43
+ def remove_credentials_file
44
+ if File.exists?( gem_credentials_file )
45
+ `rm #{gem_credentials_file}`
46
+ end
47
+ end
48
+
49
+ def write_credentials_file( credentials_hash )
50
+ File.open( gem_credentials_file, 'w' ) do |f|
51
+ f.write YAML::dump( credentials_hash )
52
+ end
53
+ end
54
+
55
+ def api_keys
56
+ YAML::load( File.open( gemdandy_rc_file ) )
57
+ end
58
+
59
+ def deployed_key_hash
60
+ return File.exists?( gem_credentials_file ) ?
61
+ YAML::load( File.open( gem_credentials_file ) ) :
62
+ {}
63
+ end
64
+
65
+ def deployed_key
66
+ deployed_key_hash[credentials_key]
67
+ end
68
+
69
+ def credentials_key
70
+ :rubygems_api_key
71
+ end
72
+
73
+ def find_api_key( identifier )
74
+ api_keys[identifier]
75
+ end
76
+
77
+ def current_profile
78
+ api_keys.invert[deployed_key]
79
+ end
80
+
81
+ def gemdandy_rc_file
82
+ "#{File.expand_path( '~' )}/.gemdandyrc"
83
+ end
84
+
85
+ def gem_credentials_file
86
+ "#{File.expand_path( '~' )}/.gem/credentials"
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "GemDandy" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'gem-dandy'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-dandy
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - ninja-loss
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-09 00:00:00 -06:00
19
+ default_executable: gemdandy
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: trollop
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 83
46
+ segments:
47
+ - 1
48
+ - 16
49
+ - 2
50
+ version: 1.16.2
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Enjoy Gem management.
54
+ email: ninja-loss@gmail.com
55
+ executables:
56
+ - gemdandy
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - LICENSE
61
+ - README.rdoc
62
+ files:
63
+ - .document
64
+ - LICENSE
65
+ - README.rdoc
66
+ - Rakefile
67
+ - VERSION
68
+ - bin/gemdandy
69
+ - gem-dandy.gemspec
70
+ - lib/gem_dandy.rb
71
+ - lib/gem_dandy/rubyforge_profile.rb
72
+ - spec/gem-dandy_spec.rb
73
+ - spec/spec.opts
74
+ - spec/spec_helper.rb
75
+ has_rdoc: true
76
+ homepage: http://github.com/midas/gem-dandy
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options: []
81
+
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project:
105
+ rubygems_version: 1.3.7
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Utilities to use to manage your gems.
109
+ test_files:
110
+ - spec/gem-dandy_spec.rb
111
+ - spec/spec_helper.rb