github_cli 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ coverage
2
+ rdoc
3
+ doc
4
+ .yardoc
5
+ .bundle
6
+ pkg
7
+ *.swp
8
+ log
9
+ *.sqlite3
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+
3
+ environment_id="ruby-1.9.3-p0@github_cli"
4
+
5
+ #
6
+ # First we attempt to load the desired environment directly from the environment
7
+ # file. This is very fast and efficient compared to running through the entire
8
+ # CLI and selector. If you want feedback on which environment was used then
9
+ # insert the word 'use' after --create as this triggers verbose mode.
10
+ #
11
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
12
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
13
+ then
14
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
15
+
16
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
17
+ then
18
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
19
+ fi
20
+ else
21
+ # If the environment file has not yet been created, use the RVM CLI to select.
22
+ if ! rvm --create "$environment_id"
23
+ then
24
+ echo "Failed to create RVM environment '${environment_id}'."
25
+ return 1
26
+ fi
27
+ fi
28
+
29
+ if [[ $- == *i* ]] # check for interactive shells
30
+ then
31
+ echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
32
+ else
33
+ echo "Using: $GEM_HOME" # don't use colors in interactive shells
34
+ fi
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ github_cli (0.0.1.pre)
5
+ github_api (~> 0.4.8)
6
+ thor
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.2.7)
12
+ aruba (0.4.11)
13
+ childprocess (>= 0.2.3)
14
+ cucumber (>= 1.1.1)
15
+ ffi (>= 1.0.11)
16
+ rspec (>= 2.7.0)
17
+ builder (3.0.0)
18
+ childprocess (0.3.1)
19
+ ffi (~> 1.0.6)
20
+ cucumber (1.1.9)
21
+ builder (>= 2.1.2)
22
+ diff-lcs (>= 1.1.2)
23
+ gherkin (~> 2.9.0)
24
+ json (>= 1.4.6)
25
+ term-ansicolor (>= 1.0.6)
26
+ diff-lcs (1.1.3)
27
+ faraday (0.7.6)
28
+ addressable (~> 2.2)
29
+ multipart-post (~> 1.1)
30
+ rack (~> 1.1)
31
+ ffi (1.0.11)
32
+ gherkin (2.9.0)
33
+ json (>= 1.4.6)
34
+ github_api (0.4.8)
35
+ faraday (~> 0.7.6)
36
+ hashie (~> 1.2.0)
37
+ multi_json (~> 1.1.0)
38
+ oauth2 (~> 0.5.2)
39
+ hashie (1.2.0)
40
+ json (1.6.5)
41
+ multi_json (1.1.0)
42
+ multipart-post (1.1.5)
43
+ oauth2 (0.5.2)
44
+ faraday (~> 0.7)
45
+ multi_json (~> 1.0)
46
+ rack (1.4.1)
47
+ rspec (2.8.0)
48
+ rspec-core (~> 2.8.0)
49
+ rspec-expectations (~> 2.8.0)
50
+ rspec-mocks (~> 2.8.0)
51
+ rspec-core (2.8.0)
52
+ rspec-expectations (2.8.0)
53
+ diff-lcs (~> 1.1.2)
54
+ rspec-mocks (2.8.0)
55
+ term-ansicolor (1.0.7)
56
+ thor (0.14.6)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ aruba
63
+ github_cli!
64
+ rspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Piotr Murach
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/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # GithubCli
2
+ [![Build Status](https://secure.travis-ci.org/peter-murach/github_cli.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/peter-murach/github_cli.png?travis)][gemnasium]
3
+
4
+ CLI-based access to GitHub API v3 that works hand-in-hand with 'github_api' gem.
5
+
6
+ This gem does not work yet at this stage, stay tuned.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'github_cli'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install github_cli
21
+
22
+ ## Usage
23
+
24
+ Run it:
25
+
26
+ ```shell
27
+ $ ghc
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
37
+
38
+ ## Copyright
39
+
40
+ Copyright (c) 2012 Piotr Murach. See LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+ require "cucumber/rake/task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ Cucumber::Rake::Task.new(:features)
11
+
12
+ task :default => [:spec, :features]
data/bin/ghc ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ lib_dir = File.expand_path("../../lib", __FILE__)
3
+ $LOAD_PATH.unshift lib_dir if File.directory?(lib_dir)
4
+
5
+ require "github_cli"
6
+ GithubCLI::CLI.start
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'aruba/cucumber'
3
+ require 'fileutils'
4
+ require 'rspec/expectations'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/github_cli/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Piotr Murach"]
6
+ gem.email = ["pmurach@gmail.com"]
7
+ gem.description = %q{CLI-based access to GitHub API v3}
8
+ gem.summary = %q{CLI-based access to GitHub API v3}
9
+ gem.homepage = "http://github.com/peter-murach/github_cli"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {spec,features}/*`.split("\n")
14
+ gem.name = "github_cli"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = GithubCLI::VERSION
17
+
18
+ gem.add_dependency 'github_api', '~> 0.4.8'
19
+ gem.add_dependency 'thor'
20
+
21
+ gem.add_development_dependency 'rspec'
22
+ gem.add_development_dependency 'aruba'
23
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class API
5
+
6
+ @@api = nil
7
+
8
+ def self.github_api
9
+ if @@api
10
+ @@api
11
+ else
12
+ @@api = Github.new
13
+ end
14
+ end
15
+
16
+ def self.configure_api
17
+ end
18
+
19
+ end # API
20
+ end # GithubCLI
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require "github_cli/command_template"
4
+ require "github_cli/repositories"
5
+ require "github_cli/issues"
6
+
7
+ module GithubCLI
8
+ class CLI < ::Thor
9
+
10
+ map "repo" => :repository,
11
+ "is" => :issue,
12
+ "-v" => :version
13
+
14
+ class_option :config, :type => :string,
15
+ :desc => "Configuration file.",
16
+ :default => "~/.githubrc"
17
+ class_option :oauth, :type => :string, :aliases => '-a',
18
+ :desc => 'Authentication token.'
19
+ class_option :verbose, :type => :boolean
20
+
21
+ def initialize(*args)
22
+ super
23
+ say <<-TEXT
24
+
25
+ Github CLI client
26
+
27
+ TEXT
28
+ end
29
+
30
+ desc 'init <config-name>', 'Initialize configuration file'
31
+ def init(config_name=nil)
32
+ say "#{options[:config]}"
33
+ end
34
+
35
+ desc 'ls <pattern>', 'List all available commands limited by pattern'
36
+ def ls(pattern=nil)
37
+ say Thor::Base.subclasses.find { |klass| puts klass }
38
+ end
39
+
40
+ desc "repository <command>", "manage repositories"
41
+ subcommand "repository", GithubCLI::Repositories
42
+
43
+ desc "issue <command>", "manage issues"
44
+ subcommand "issue", GithubCLI::Issues
45
+
46
+ desc 'version', 'Display Github CLI version.'
47
+ def version
48
+ require 'github_cli/version'
49
+ say "Github CLI #{GithubCLI::VERSION}"
50
+ end
51
+
52
+ end # CLI
53
+ end # GithubCLI
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ # TODO: add helpers here for unifying options setting such as user etc...
5
+ class Command < Thor
6
+
7
+ def self.banner(task, namespace=true, subcommand=true)
8
+ "#{basename} #{task.formatted_usage(self, true, subcommand)}"
9
+ end
10
+
11
+ end # Command
12
+ end # GithubCLI
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Config
5
+
6
+ def initialize(options={})
7
+ @options = options
8
+ end
9
+
10
+ def self.config
11
+ ::GithubCLI.const_set(:CONFIG, self.new)
12
+ end
13
+ end
14
+ end # GithubCLI
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'github_cli/command'
4
+
5
+ module GithubCLI
6
+ class Issues < Command
7
+
8
+ namespace :issue
9
+
10
+ option :params, :type => :hash
11
+ desc 'list', 'Listing all issues'
12
+ long_desc <<-TEXT
13
+ ghc issue list --params filter:'assigned', state:'open'
14
+
15
+ Parameters\n
16
+ filter\n
17
+ * assigned: Issues assigned to you (default) \n
18
+ * created: Issues assigned to you (default) \n
19
+ * mentioned: Issues assigned to you (default)\n
20
+ * subscribed: Issues assigned to you (default)\n
21
+ state - open, closed, default: open \n
22
+ labels - String list of comma separated Label names. Example: bug,ui,@high
23
+ sort - created, updated, comments, default: created \n
24
+ direction - asc, desc, default: desc \n
25
+ since - Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ \n
26
+ TEXT
27
+ def list
28
+ say "listing #{options[:params]}"
29
+ end
30
+
31
+ option :number, :type => :numeric, :required => true
32
+ desc 'get <user>,<repo>', 'Get a single issue'
33
+ def get(user, repo)
34
+ say "#{user}"
35
+ end
36
+
37
+ option :params, :type => :hash
38
+ desc 'create <user>,<repo>', 'Create an issue.'
39
+ def create(user, repo)
40
+ say 'creating...'
41
+ end
42
+
43
+ option :params, :type => :hash
44
+ desc 'edit <user>,<repo>', 'Edit an issue.'
45
+ def edit(user, repo)
46
+ say 'editing...'
47
+ end
48
+
49
+ end # Issues
50
+ end # GithubCLI
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ require 'github_cli/command'
4
+
5
+ module GithubCLI
6
+ class Repositories < Command
7
+
8
+ namespace :repo
9
+
10
+ option :orgs, :type => :boolean,
11
+ :desc => 'List repositories for <organization>'
12
+ desc 'list', 'Listing all repositories'
13
+ def list
14
+ say 'listing'
15
+ end
16
+
17
+ desc 'get', 'Get a repository'
18
+ def get
19
+ end
20
+
21
+ desc 'create', 'Create <repo> <user>'
22
+ def create
23
+ say 'creating...'
24
+ end
25
+
26
+ desc 'remove', 'Remove <repo> <user>'
27
+ def remove
28
+ say 'removing'
29
+ end
30
+
31
+ end # Repositories
32
+ end # GithubCLI
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module GithubCLI
4
+ class Repository
5
+
6
+ def initialize
7
+ end
8
+
9
+ def self.all
10
+ end
11
+
12
+ def self.get(id)
13
+
14
+ end
15
+
16
+ def self.create()
17
+ end
18
+
19
+ end # Repository
20
+ end # GithubCLI
@@ -0,0 +1,3 @@
1
+ module GithubCLI
2
+ VERSION = "0.0.1.pre"
3
+ end
data/lib/github_cli.rb ADDED
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'thor'
4
+ require 'thor/group'
5
+ require 'github_api'
6
+
7
+ module GithubCLI
8
+ require "github_cli/cli"
9
+
10
+ require "github_cli/version"
11
+ require "github_cli/api"
12
+ require "github_cli/config"
13
+ require "github_cli/repository"
14
+ require "github_cli/repositories"
15
+ require "github_cli/issues"
16
+ require "github_cli/command"
17
+
18
+ autoload :CLI, 'github_cli/cli'
19
+ autoload :Repositories, 'github_cli/repositories'
20
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe GithubCLI::API do
4
+ context '#github_api' do
5
+ before(:each) { described_class.class_variable_set :@@api, nil }
6
+
7
+ it 'sets up github api connection' do
8
+ github_instance = stub
9
+ Github.should_receive(:new).and_return github_instance
10
+ described_class.github_api.should == github_instance
11
+ end
12
+
13
+ it 'does not instantiate on subsequent calls' do
14
+ described_class.github_api
15
+ Github.should_receive(:new).exactly(0).times
16
+ described_class.github_api
17
+ end
18
+ end
19
+ end # GithubCLI::API
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe GithubCLI::CLI do
4
+
5
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe GithubCLI::Config do
4
+
5
+ context '#config' do
6
+ it 'sets global config' do
7
+ instance = stub
8
+ described_class.stub(:new) { instance }
9
+ GithubCLI.should_receive(:const_set).with(:CONFIG, instance)
10
+ described_class.config
11
+ end
12
+ it 'returns config type' do
13
+ described_class.config.should be_a GithubCLI::Config
14
+ end
15
+ end
16
+
17
+ end # GithubCLI::Config
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+
6
+ require 'rspec'
7
+ require 'github_cli'
8
+
9
+ RSpec.configure do |config|
10
+ config.order = :rand
11
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Piotr Murach
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: github_api
16
+ requirement: &2151935480 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2151935480
25
+ - !ruby/object:Gem::Dependency
26
+ name: thor
27
+ requirement: &2151933800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2151933800
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &2151932820 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2151932820
47
+ - !ruby/object:Gem::Dependency
48
+ name: aruba
49
+ requirement: &2151932020 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2151932020
58
+ description: CLI-based access to GitHub API v3
59
+ email:
60
+ - pmurach@gmail.com
61
+ executables:
62
+ - ghc
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - .gitignore
67
+ - .rspec
68
+ - .rvmrc
69
+ - Gemfile
70
+ - Gemfile.lock
71
+ - LICENSE
72
+ - README.md
73
+ - Rakefile
74
+ - bin/ghc
75
+ - features/support/env.rb
76
+ - github_cli.gemspec
77
+ - lib/github_cli.rb
78
+ - lib/github_cli/api.rb
79
+ - lib/github_cli/cli.rb
80
+ - lib/github_cli/command.rb
81
+ - lib/github_cli/config.rb
82
+ - lib/github_cli/issues.rb
83
+ - lib/github_cli/repositories.rb
84
+ - lib/github_cli/repository.rb
85
+ - lib/github_cli/version.rb
86
+ - spec/github_cli/api_spec.rb
87
+ - spec/github_cli/cli_spec.rb
88
+ - spec/github_cli/config_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: http://github.com/peter-murach/github_cli
91
+ licenses: []
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>'
106
+ - !ruby/object:Gem::Version
107
+ version: 1.3.1
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 1.8.10
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: CLI-based access to GitHub API v3
114
+ test_files:
115
+ - features/support/env.rb
116
+ - spec/github_cli/api_spec.rb
117
+ - spec/github_cli/cli_spec.rb
118
+ - spec/github_cli/config_spec.rb
119
+ - spec/spec_helper.rb