Create your own gem and upload it to github
Create your own gem and upload it to the github environment: centos7, git version 1.8.3.1
1. Create gem1 to install bundler
# Gem install bundler
2. Use bundler to create the framework required for gem
# Bundler gem file_manipulate
3. Modify the file_manipulate.gemspec file.
# Vim file_manipulate.gemspec
(The description and summary are modified, because RubyGem does not actually package the description in the spec with a "TODO" package into the gem)
The modified file_manipulate.gemspec file contains the following content:
# Coding: UTF-8
Lib = File. expand_path ('../lib', _ FILE __)
$ LOAD_PATH.unshift (lib) unless $ LOAD_PATH.include? (Lib)
Require 'file _ manipulate/version'
Gem: Specification. new do | spec |
Spec. name = "file_manipulate"
Spec. version = FileManipulate: VERSION
Spec. authors = ["liyongkuan"]
Spec. email = ["lykperson@163.com"]
Spec. summary = % q {This is a file manipulate library}
Spec. description = % q {This is a file manipulate library}
Spec. homepage = "http://blog.csdn.net/li_yong_kuan"
Spec. license = "MIT"
Spec. files = 'git ls-files-Z'. split ("\ x0 ")
Spec.exe cutables = spec. files. grep (% r {^ bin/}) {| f | File. basename (f )}
Spec. test_files = spec. files. grep (% r {^ (test | spec | features )/})
Spec. require_paths = ["lib"]
Spec. add_development_dependency "bundler", "~> 1.7"
Spec. add_development_dependency "rake", "~> 10.0"
End
4. Compile the lib/file_manipulate.rb file and process the file as a file that is only imported into the database.
# Vim lib/file_manipulate.rb
The content is as follows:
Require "file_manipulate/version"
Require "file_manipulate/file_manipulate"
5. Create a New file_manipulate.rb file under lib/file_manipulate and write the specific content in it.
# Touch file_manipulate.rb
6. Write the specific method in file_manipulate.rb and save and exit.
# Vim file_manipulate.rb
7. Submit to git
# Git add.
# Git commit-m "Create a document library operation"
8. Pack the gem
# Gem build file_manipulate.gemspec
Or
# Rake build
The: file_manipulate-0.0.1.gem is generated after execution is complete
9 install file_manipulate locally
# Gem install file_manipulate.gem-l after installation, You Can # gem list to check whether this gem exists in the gem list
OK, generate the gem. (after the test, delete file_manipulate.gem and upload the project to github later)
2. Upload the file to the github Server 1. Create the repository file_manipulate on github.
Link: https://help.github.com/articles/create-a-repo/
2. Create a key
Link: https://help.github.com/articles/generating-ssh-keys/
# Ssh-keygen-t rsa-C "lykperson@163.com"
After creation, the private key and public key are generated under. ssh in your home directory.
/Home/oss/. ssh (. ssh is a hidden file, # ls-a can be viewed)
3. Copy the public key to the ssh file created on github, and name it by yourself (name as needed)
4. Go to the file_manipulate file we created earlier.
# Cd file_manipulate
5. Create an alias for the url link
# Git remote add kuange git@github.com: liyongkuan/file_manipulate.git
(Git@github.com: liyongkuan/file_manipulate.git is the repository ssh address created in operation 1, which can be copied directly on github)
6. Upload the specified project to github.
# Git push kuange master
(Kuange is the link alias created in the previous step)
The project has been uploaded to the github server at: https://github.com/liyongkuan/file_manipulate