githubrepo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f765f04f23701ed356df4635ba73237edc0c719
4
+ data.tar.gz: 2120faf3b9f6e20993595730948268d38af2ae4f
5
+ SHA512:
6
+ metadata.gz: c43c23a5f605e696df5f7986c363ab230db70e00a9968b30789f18609d007df491d8f77ec7ced966a45a3a16fecde668534daa7d9781f0d2cf944c0222393c91
7
+ data.tar.gz: d4a2d0da59de57626ce16cc7a70feb2b9b17631b6d61f2515047dc1232882f65eeb3aa8c9f10d74681d1e7dcd9aa8e465659fe167e7303665969d0b424108877
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectCodeStyleSettingsManager">
4
+ <option name="PER_PROJECT_SETTINGS">
5
+ <value>
6
+ <XML>
7
+ <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
8
+ </XML>
9
+ </value>
10
+ </option>
11
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
12
+ </component>
13
+ </project>
14
+
@@ -0,0 +1,24 @@
1
+ <component name="ProjectRunConfigurationManager">
2
+ <configuration default="false" name="githubrepo" type="RubyRunConfigurationType" factoryName="Ruby">
3
+ <module name="Create Repo" />
4
+ <RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
5
+ <RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/bin" />
6
+ <RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="true" />
7
+ <RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
8
+ <RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
9
+ <envs />
10
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
11
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
12
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
13
+ <COVERAGE_PATTERN ENABLED="true">
14
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
15
+ </COVERAGE_PATTERN>
16
+ </EXTENSION>
17
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
18
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/bin/githubrepo.rb" />
19
+ <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
20
+ <RunnerSettings RunnerId="RubyRunner" />
21
+ <ConfigurationWrapper RunnerId="RubyRunner" />
22
+ <method />
23
+ </configuration>
24
+ </component>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in githubrepo.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ githubrepo (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.1.1)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.3)
16
+ githubrepo!
17
+ rake
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Elikem Adadevoh
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Pryfile ADDED
@@ -0,0 +1 @@
1
+ load 'bin/githubrepo.rb'
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Githubrepo
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'githubrepo'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install githubrepo
18
+
19
+ ## Usage
20
+
21
+ $ githubrepo create REPOSITORY_NAME
22
+
23
+
24
+ For more details use help flag:
25
+
26
+ $ githubrepo --help
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/githubrepo ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander/import'
5
+ require 'pry'
6
+
7
+ require './lib/create'
8
+
9
+ program :name, 'githubrepo'
10
+ program :version, '0.0.1'
11
+ program :description, 'Create GitHub repositories from the command line'
12
+ program :help, 'Author', 'Elikem Adadevoh <elikem@gmail.com>'
13
+
14
+ command :create do |c|
15
+ c.syntax = 'githubrepo create [options]'
16
+
17
+ c.description = 'githubrepo create REPO_NAME'
18
+
19
+ c.example 'usage 1', 'githubrepo create REPO_NAME'
20
+ c.example 'usage 2 -- create is the default action for this gem', 'githubrepo REPO_NAME'
21
+
22
+ #the ability to add a description will come later
23
+ #c.example 'description', 'githubrepo create REPO_NAME -d "short description"'
24
+ #c.option '--description STRING', String, 'A short description of the repository'
25
+
26
+ c.action do |args, options|
27
+ repository = args.shift
28
+ if repository.nil?
29
+ puts 'invalid option -- githubrepo create REPO_NAME'
30
+ exit
31
+ end
32
+
33
+ username = ask "'Username for 'https://github.com': "
34
+ if username.length == 0
35
+ puts 'invalid option -- please enter a username'
36
+ exit
37
+ end
38
+
39
+ password = ask('Password: ') { |char| char.echo = false }
40
+
41
+ cli({ :repository => repository, :username => username, :password => password })
42
+ end
43
+ end
44
+
45
+ default_command :create
46
+
47
+ def cli(attributes)
48
+ puts attributes
49
+ Githubrepo.create(attributes)
50
+ # GitHubRepo.create({ :username => 'elikem', :password => 'testpassword2014', :repository => 'the_goonies' })
51
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'githubrepo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'githubrepo'
8
+ spec.version = Githubrepo::VERSION
9
+ spec.authors = ['Elikem Adadevoh']
10
+ spec.email = ['elikem@gmail.com']
11
+ spec.description = %q{Create GitHub repositories from the command line}
12
+ spec.summary = %q{CLI to create repositories}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 2.0'
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
24
+ end
data/lib/create.rb ADDED
@@ -0,0 +1,65 @@
1
+ require 'json'
2
+ require 'httparty'
3
+ require 'pry'
4
+
5
+ module Githubrepo
6
+
7
+ # no need for classes (will never create instance of self)... refactor and use just modules and methods
8
+ # http://matt.aimonetti.net/posts/2012/07/30/ruby-class-module-mixins/
9
+ include HTTParty
10
+
11
+ def self.create(attributes)
12
+
13
+ post = HTTParty.post(
14
+ 'https://api.github.com/user/repos',
15
+
16
+ :headers => {
17
+ # When API Keys are supported we will want to pass them via the headers
18
+ #'Authorization' => "token #{token}",
19
+
20
+ 'User-Agent' => 'Githubrepo',
21
+ 'Content-Type' => 'application/json',
22
+ 'Accept' => 'application/json'
23
+ },
24
+
25
+ :basic_auth => {
26
+ :username => attributes[:username],
27
+ :password => attributes[:password]
28
+ },
29
+
30
+ :body => {
31
+ 'name' => attributes[:repository]
32
+
33
+ # feature coming at a future date
34
+ #'description' => description
35
+ }.to_json
36
+ )
37
+
38
+ Githubrepo.parse_response_from(post)
39
+ end
40
+
41
+ # DRY this by moving to a Parse.response_from(post)
42
+ def self.parse_response_from(post)
43
+ attributes = post
44
+
45
+ git_url =
46
+ if attributes['git_url'] != nil
47
+ attributes['git_url']
48
+ end
49
+
50
+ message =
51
+ if attributes['message'] != nil
52
+ attributes['message']
53
+ end
54
+
55
+ error_message =
56
+ if attributes['errors'] != nil
57
+ attributes['errors'].first['message']
58
+ end
59
+
60
+ # messages to console
61
+ puts git_url if git_url
62
+ puts message.capitalize if message
63
+ puts error_message.capitalize if error_message
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module Githubrepo
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: githubrepo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Elikem Adadevoh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Create GitHub repositories from the command line
42
+ email:
43
+ - elikem@gmail.com
44
+ executables:
45
+ - githubrepo
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".idea/codeStyleSettings.xml"
51
+ - ".idea/runConfigurations/githubrepo.xml"
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - Pryfile
56
+ - README.md
57
+ - Rakefile
58
+ - bin/githubrepo
59
+ - githubrepo.gemspec
60
+ - lib/create.rb
61
+ - lib/githubrepo/version.rb
62
+ homepage: ''
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '2.0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.1.11
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: CLI to create repositories
86
+ test_files: []
87
+ has_rdoc: