gitius 0.0.1pre

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: f4581991a5af0fd8736f746251b90bbe8506fbb9
4
+ data.tar.gz: 1a7278a4d29026418364039a5a4acb74de866e76
5
+ SHA512:
6
+ metadata.gz: 2c69037a4849b36ae28f10a878bdb74ffacebd4fd124d2e0187e1de6f8b59a9c99a2782f60a8737846cc639eb57397d33c21c2e106856d9c0c61d0dead4178c6
7
+ data.tar.gz: b5b102f1e39d4034df66778f4cb31f8e9db8f5d73d3331dfcaa9fa01e910bcb87c38de31275f2db9a4985f3058bb2f24e30609a0dd056eac94fa7b1dad16835d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ ## [v0.0.1](https://github.com/ashanaakh/gitius/tree/v0.0.1) (2017-10-03)
4
+ **Merged pull requests:**
5
+
6
+ - cleanup gitius.gemspec [\#2](https://github.com/ashanaakh/gitius/pull/2) ([ashanaakh](https://github.com/ashanaakh))
7
+ - Created github base commands [\#1](https://github.com/ashanaakh/gitius/pull/1) ([ashanaakh](https://github.com/ashanaakh))
8
+
9
+
10
+
11
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gitius.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gitius (0.0.1pre)
5
+ octokit (~> 4.7.0)
6
+ thor (~> 0.20.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.5.2)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ diff-lcs (1.3)
14
+ faraday (0.13.1)
15
+ multipart-post (>= 1.2, < 3)
16
+ multipart-post (2.0.0)
17
+ octokit (4.7.0)
18
+ sawyer (~> 0.8.0, >= 0.5.3)
19
+ public_suffix (3.0.0)
20
+ rake (10.5.0)
21
+ rspec (3.6.0)
22
+ rspec-core (~> 3.6.0)
23
+ rspec-expectations (~> 3.6.0)
24
+ rspec-mocks (~> 3.6.0)
25
+ rspec-core (3.6.0)
26
+ rspec-support (~> 3.6.0)
27
+ rspec-expectations (3.6.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.6.0)
30
+ rspec-mocks (3.6.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.6.0)
33
+ rspec-support (3.6.0)
34
+ sawyer (0.8.1)
35
+ addressable (>= 2.3.5, < 2.6)
36
+ faraday (~> 0.8, < 1.0)
37
+ thor (0.20.0)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ bundler (~> 1.15.4)
44
+ gitius!
45
+ rake (~> 10.0)
46
+ rspec (~> 3.0)
47
+
48
+ BUNDLED WITH
49
+ 1.16.0.pre.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Ali Shanaakh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Gitius
2
+
3
+ Command line interface based on GitHub official [Octokit](https://github.com/octokit/octokit.rb)
4
+ gem and [Thor](https://github.com/erikhuda/thor) library for creating CLI on ruby
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'gitius'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install gitius
21
+
22
+ ## Usage
23
+
24
+ ```shell
25
+ gitius config token <token>
26
+ gitius config tocken # shows your token
27
+ gitius whoami # prints user's nickname
28
+ ```
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ashanaakh/gitius.
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gitius"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/gitius ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thor'
3
+
4
+ $: << File.join(File.dirname(__FILE__), '../lib')
5
+
6
+ require 'gitius'
7
+
8
+ Gitius::Core.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/gitius.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'gitius/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'gitius'
7
+ spec.version = Gitius::VERSION
8
+ spec.authors = ['Ali Shanaakh']
9
+ spec.email = ['ashanaakh@gmail.com']
10
+
11
+ spec.summary = %q{ Command line interface for githib }
12
+ spec.homepage = 'https://github.com/ashanaakh/gitius'
13
+
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'thor', '~> 0.20.0'
22
+ spec.add_dependency 'octokit', '~> 4.7.0'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.15.4'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ end
@@ -0,0 +1,5 @@
1
+ module Gitius
2
+ class Base < Thor
3
+ include Thor::Actions
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Gitius
2
+ PATH = "#{Dir.home}/.gitius".freeze
3
+ end
@@ -0,0 +1,28 @@
1
+ module Gitius
2
+ class Core < Base
3
+ include Gitius::Helpers
4
+
5
+ desc 'repo <command>', ''
6
+ subtask 'repo', Repository
7
+
8
+ desc 'gist <command>', ''
9
+ subtask 'gist', Gist
10
+
11
+ desc 'whoami', "Return user's github nickname"
12
+ def whoami
13
+ puts user.name
14
+ rescue StandardError => e
15
+ puts e.message
16
+ end
17
+
18
+ desc 'config', 'Set configurations for using cli'
19
+ def config(key, value = nil)
20
+ value.nil? ? puts(get_config(key)) : change_config(key, value)
21
+ end
22
+
23
+ desc 'version', 'Return gitius version'
24
+ def version
25
+ puts "v#{VERSION}"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ class Gist < Thor
2
+ include Gitius::Helpers
3
+
4
+ desc 'create', 'Create gist'
5
+ option :description, aliases: :d, banner: '<text>'
6
+ option :public
7
+ def create(*paths)
8
+ paths.each do |f|
9
+ options['files'] = {
10
+ File.basename(f) => { 'content' => File.read(f).to_s }
11
+ }
12
+ end
13
+ response = client.create_gist(options)
14
+ puts response.html_url
15
+ rescue StandardError => e
16
+ puts e.message
17
+ end
18
+
19
+ desc 'delete', 'Delete gist'
20
+ def delete(id)
21
+ response = client.delete_repo(id)
22
+ puts response ? 'gist deleted' : 'error'
23
+ rescue StandardError => e
24
+ puts e.message
25
+ end
26
+ end
@@ -0,0 +1,42 @@
1
+ module Gitius
2
+ module Helpers
3
+ def token
4
+ get_config(:token)
5
+ end
6
+
7
+ def change_config(key, value)
8
+ File.new Gitius::PATH, 'w' unless File.exist? Gitius::PATH
9
+ configs = YAML.load_file(Gitius::PATH) || {}
10
+ configs[key.to_sym] = value
11
+ File.open(Gitius::PATH, 'w') { |file| file.write configs.to_yaml }
12
+ rescue StandardError => e
13
+ raise e
14
+ end
15
+
16
+ def get_config(key)
17
+ File.new Gitius::PATH, 'w' unless File.exist? Gitius::PATH
18
+ configs = YAML.load_file(Gitius::PATH) || {}
19
+ configs[key.to_sym]
20
+ rescue StandardError => e
21
+ raise e
22
+ end
23
+
24
+ def client
25
+ Octokit::Client.new(access_token: token)
26
+ rescue StandardError => e
27
+ raise e
28
+ end
29
+
30
+ def user
31
+ client.user
32
+ rescue StandardError => e
33
+ raise e
34
+ end
35
+
36
+ def repo(name)
37
+ client.nil? ? nil : client.repo(name)
38
+ rescue StandardError => e
39
+ raise e
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,41 @@
1
+ class Repository < Thor
2
+ include Gitius::Helpers
3
+
4
+ desc 'create', 'Create repository'
5
+ option :description, aliases: :d, banner: '<text>'
6
+ option :homepage, aliases: :url, banner: '<url>'
7
+ option :private, aliases: :p
8
+ option :auto_init, aliases: :i
9
+ def create(name)
10
+ response = client.create(name, options)
11
+ puts response.html_url, response.ssh_url
12
+ rescue StandardError => e
13
+ puts e.message
14
+ end
15
+
16
+ desc 'delete', 'Delete repository'
17
+ def delete(name)
18
+ succeed = client.delete_repo(name)
19
+ puts succeed ? 'Repository was succfully deleted' : 'Error'
20
+ rescue StandardError => e
21
+ puts e.message
22
+ end
23
+
24
+ desc 'info', 'Get information'
25
+ option :forks, aliases: :f
26
+ def info(name)
27
+ puts client.forks(name) if options[:forks]
28
+ puts "last update: #{repo(name).created_at}"
29
+ rescue StandardError => e
30
+ puts e.message
31
+ end
32
+
33
+ desc 'fork', 'Fork repository'
34
+ def fork(name)
35
+ response = client.fork(name)
36
+ puts "#{name} forked", "url: #{response.html_url}",
37
+ "url: #{response.ssh_url}"
38
+ rescue StandardError => e
39
+ puts e.message
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Gitius
2
+ VERSION = '0.0.1pre'.freeze
3
+ end
data/lib/gitius.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'thor'
2
+ require 'octokit'
3
+ require 'yaml'
4
+
5
+ require 'gitius/config'
6
+ require 'gitius/version'
7
+ require 'gitius/helpers'
8
+ require 'gitius/base'
9
+
10
+ require 'gitius/repository'
11
+ require 'gitius/gist'
12
+
13
+ require 'gitius/core'
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitius
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1pre
5
+ platform: ruby
6
+ authors:
7
+ - Ali Shanaakh
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.20.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.20.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: octokit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 4.7.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 4.7.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.15.4
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.15.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ - ashanaakh@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - CHANGELOG.md
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/gitius
99
+ - bin/setup
100
+ - gitius.gemspec
101
+ - lib/gitius.rb
102
+ - lib/gitius/base.rb
103
+ - lib/gitius/config.rb
104
+ - lib/gitius/core.rb
105
+ - lib/gitius/gist.rb
106
+ - lib/gitius/helpers.rb
107
+ - lib/gitius/repository.rb
108
+ - lib/gitius/version.rb
109
+ homepage: https://github.com/ashanaakh/gitius
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">"
125
+ - !ruby/object:Gem::Version
126
+ version: 1.3.1
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.6.13
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Command line interface for githib
133
+ test_files: []