Skip to content

Commit

Permalink
modify
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangHanDong committed Oct 26, 2010
0 parents commit 48f9baa
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
pkg/*
*.gem
.bundle
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source :gemcutter

# Specify your gem's dependencies in ruby_extend.gemspec
gemspec
2 changes: 2 additions & 0 deletions Rakefile
@@ -0,0 +1,2 @@
require 'bundler'
Bundler::GemHelper.install_tasks
2 changes: 2 additions & 0 deletions lib/ruby_extend.rb
@@ -0,0 +1,2 @@
require 'ruby_extend/hash_extendsions'

21 changes: 21 additions & 0 deletions lib/ruby_extend/hash_extendsions.rb
@@ -0,0 +1,21 @@
module RubyExtend
module HashExtendsions
def self.included(base)
base.send :include, InstanceMethods
end

module InstanceMethods
def hash_reverse
hash_new = {}
self.each {|key,value|
if not hash_new.has_key?(key) then hash_new[value] = key end
}
return hash_new
end
end
end
end

class Hash
include RubyExtend::HashExtendsions
end
3 changes: 3 additions & 0 deletions lib/ruby_extend/version.rb
@@ -0,0 +1,3 @@
module RubyExtend
VERSION = "0.0.1"
end
22 changes: 22 additions & 0 deletions ruby_extend.gemspec
@@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-
require File.expand_path("../lib/ruby_extend/version", __FILE__)

Gem::Specification.new do |s|
s.name = "ruby_extend"
s.version = RubyExtend::VERSION
s.platform = Gem::Platform::RUBY
s.authors = []
s.email = []
s.homepage = "http://rubygems.org/gems/ruby_extend"
s.summary = "TODO: Write a gem summary"
s.description = "TODO: Write a gem description"

s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "ruby_extend"

s.add_development_dependency "bundler", ">= 1.0.0"

s.files = `git ls-files`.split("\n")
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
s.require_path = 'lib'
end

0 comments on commit 48f9baa

Please sign in to comment.