labelito 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6ae6bb25f57e11dcb243a322fd051d6d35640d2a
4
+ data.tar.gz: 812fa611a610e47b397205dab9ed8bed65c72b2e
5
+ SHA512:
6
+ metadata.gz: 0e77dff9e3b96c1d09c1e7829abafc0b4d7111138621abb07e3bf0e86d92998ac3c2c82176f01483802ce1179e12de89c2bd7fe554d2b151886c775932adf564
7
+ data.tar.gz: 374324e66b131c34cd46dd9ac8b30e54bd4581ad68a2f2d89501184afa51ac1d53be449028efebea2514069561782cef2fd596c3fe170ccbd18ecc1a864e3de9
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea
@@ -0,0 +1 @@
1
+ -global
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ 2.3.0
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at pepibumur@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in Labelito.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Pedro Piñera Buendía
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.
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'Labelito/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "labelito"
8
+ spec.version = Labelito::VERSION
9
+ spec.authors = ["Pedro Piñera Buendía"]
10
+ spec.email = ["pepi@caramba.io"]
11
+ spec.summary = %q{Command line tool for automating GitHub labels creation.}
12
+ spec.homepage = "https://caramba.io"
13
+ spec.license = "MIT"
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
+ spec.bindir = "exe"
16
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "octokit", "~> 4.3"
20
+ spec.add_dependency "colorize", "~> 0.8"
21
+ spec.add_dependency "thor", "~> 0.19"
22
+ spec.add_development_dependency "byebug"
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ end
@@ -0,0 +1,78 @@
1
+ # Labelito
2
+
3
+ [![Build Status](https://travis-ci.org/carambalabs/Labelito.svg?branch=master)](https://travis-ci.org/carambalabs/Labelito)
4
+ [![Dependency Status](https://gemnasium.com/badges/github.com/carambalabs/Labelito.svg)](https://gemnasium.com/github.com/carambalabs/Labelito)
5
+
6
+ Labelito is a command line tool written in Ruby that automates the label creation on GitHub. It currently supports two ways of creating the labels:
7
+
8
+ - Cloning them from an existing repository.
9
+ - Reading them from a template.
10
+
11
+ **Example cloning [CocoaPods](https://cocoapods.org) labels**
12
+
13
+ ![example](assets/example.gif)
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'Labelito'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install Labelito
30
+
31
+ ## Usage
32
+
33
+ ```bash
34
+ Commands:
35
+ labelito clone FROM_OWNER/FROM_REPO TO_OWNER/TO_REPO # clone the labels from an existing repository
36
+ labelito create TEMPLATE_PATH REPO_OWNER/REPO # create labels on a repository based on a template
37
+ labelito help [COMMAND] # Describe available commands or one specific command
38
+ ```
39
+
40
+ You can specify the GitHub token by:
41
+
42
+ - Passing a parameter `github_token`
43
+ - Defining an environment variable `LABELITO_GITHUB_TOKEN`
44
+
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ 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).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/carambalabs/Labelito. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
+
56
+ ## References
57
+
58
+ - Octokit. Ruby client: [Link](https://github.com/octokit/octokit.rb)
59
+ - rspec-mocks: [Link](http://rspec.info/documentation/3.5/rspec-mocks/)
60
+ - rspecs-expectations: [Link](http://rspec.info/documentation/3.5/rspec-expectations/)
61
+
62
+ ## About
63
+
64
+ <img src="https://github.com/carambalabs/Foundation/blob/master/ASSETS/avatar_rounded.png?raw=true" width="70" />
65
+
66
+ This project is funded and maintained by [Caramba](http://caramba.io). We 💛 open source software!
67
+
68
+ Check out our other [open source projects](https://github.com/carambalabs/), read our [blog](http://blog.caramba.io) or say :wave: on twitter [@carambalabs](http://twitter.com/carambalabs).
69
+
70
+ ## Contribute
71
+
72
+ Contributions are welcome :metal: We encourage developers like you to help us improve the projects we've shared with the community. Please see the [Contributing Guide](https://github.com/carambalabs/Foundation/blob/master/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/carambalabs/Foundation/blob/master/CONDUCT.md).
73
+
74
+ ## License
75
+
76
+ CarambaKit is available under the MIT license. See the LICENSE file for more info.
77
+
78
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
Binary file
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "Labelito"
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
@@ -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
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "Labelito"
@@ -0,0 +1,42 @@
1
+ require_relative "Labelito/version"
2
+ require_relative "Labelito/template_reader"
3
+ require_relative "Labelito/errors"
4
+ require_relative "Labelito/tool"
5
+ require "thor"
6
+
7
+ module Labelito
8
+
9
+ # http://whatisthor.com/
10
+ class CommandTool < Thor
11
+
12
+ option :github_token, :required => false, :type => :string
13
+ desc "clone FROM_OWNER/FROM_REPO TO_OWNER/TO_REPO", "clone the labels from an existing repository"
14
+ def clone(from_repo, to_repo)
15
+ token = options[:github_token]
16
+ token ||= ENV["LABELITO_GITHUB_TOKEN"]
17
+ if token == nil
18
+ puts("You should pass a token or define it as a environment variable, LABELITO_GITHUB_TOKEN")
19
+ exit -1
20
+ end
21
+ tool = Labelito::Tool.with_token(token)
22
+ tool.clone(from_repo, to_repo)
23
+ end
24
+
25
+ option :github_token, :required => false, :type => :string
26
+ desc "create TEMPLATE_PATH REPO_OWNER/REPO", "create labels on a repository based on a template"
27
+ def create(template_path, repo)
28
+ token = options[:github_token]
29
+ token ||= ENV["LABELITO_GITHUB_TOKEN"]
30
+ if token == nil
31
+ puts("You should pass a token or define it as a environment variable, LABELITO_GITHUB_TOKEN")
32
+ exit -1
33
+ end
34
+ tool = Labelito::Tool.with_token(token)
35
+ tool.create(template_path, repo)
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ Labelito::CommandTool.start(ARGV)
@@ -0,0 +1,6 @@
1
+ module Labelito
2
+ module Errors
3
+ class TemplateNotFound < StandardError; end
4
+ class InvalidFormat < StandardError; end
5
+ end
6
+ end
@@ -0,0 +1,36 @@
1
+ require 'octokit'
2
+ require_relative "label"
3
+
4
+ module Labelito
5
+ class GithubClient
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def self.with_token(token)
12
+ GithubClient.new Octokit::Client.new(:access_token => token)
13
+ end
14
+
15
+ def labels(repository)
16
+ puts "=> Fetching labels"
17
+ @client.labels(repository).map do |label|
18
+ Label.from_github_label(label)
19
+ end
20
+ end
21
+
22
+ def update(labels, repository)
23
+ old_labels = @client.labels(repository)
24
+ puts "=> Deleting existing labels"
25
+ old_labels.each { |label|
26
+ puts "==> Deleting label #{label[:name]}"
27
+ @client.delete_label!(repository, label[:name])
28
+ }
29
+ labels.each do |label|
30
+ puts "==> Creating label #{label.name}"
31
+ @client.add_label(repository, label.name, label.color)
32
+ end
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ module Labelito
2
+ class Label
3
+
4
+ attr_reader :name, :color
5
+
6
+ def initialize(name, color)
7
+ @name = name
8
+ @color = color
9
+ end
10
+
11
+ def self.from_github_label(label)
12
+ return Label.new label[:name], label[:color] if label[:name] && label[:color]
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'yaml'
2
+ require_relative 'label'
3
+ require_relative 'errors'
4
+
5
+ module Labelito
6
+ class TemplateReader
7
+
8
+ def read(path)
9
+ raise Errors::TemplateNotFound unless File.exists?(path)
10
+ puts "=> Fetching labels"
11
+ YAML::load_file(path).map do |element|
12
+ raise Errors::InvalidFormat unless element["name"] && element["color"]
13
+ Label.new element["name"], element["color"]
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ require_relative "github_client"
2
+ require_relative "template_reader"
3
+ require "thor"
4
+
5
+ module Labelito
6
+ class Tool
7
+
8
+ def initialize(client, template_reader)
9
+ @client = client
10
+ @template_reader = template_reader
11
+ end
12
+
13
+ def self.with_token(token)
14
+ Tool.new GithubClient.with_token(token), TemplateReader.new
15
+ end
16
+
17
+ def clone(from_repo, to_repo)
18
+ labels = @client.labels(from_repo)
19
+ @client.update(labels, to_repo)
20
+ end
21
+
22
+ def create(template_path, repo)
23
+ labels = @template_reader.read(template_path)
24
+ @client.update(labels, repo)
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Labelito
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: labelito
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Pedro Piñera Buendía
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-09-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.19'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.19'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.12'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ description:
112
+ email:
113
+ - pepi@caramba.io
114
+ executables:
115
+ - labelito
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rbenv-gemsets"
121
+ - ".rspec"
122
+ - ".ruby-version"
123
+ - ".travis.yml"
124
+ - CODE_OF_CONDUCT.md
125
+ - Gemfile
126
+ - LICENSE.txt
127
+ - Labelito.gemspec
128
+ - README.md
129
+ - Rakefile
130
+ - assets/example.gif
131
+ - bin/console
132
+ - bin/setup
133
+ - exe/labelito
134
+ - lib/Labelito.rb
135
+ - lib/Labelito/errors.rb
136
+ - lib/Labelito/github_client.rb
137
+ - lib/Labelito/label.rb
138
+ - lib/Labelito/template_reader.rb
139
+ - lib/Labelito/tool.rb
140
+ - lib/Labelito/version.rb
141
+ homepage: https://caramba.io
142
+ licenses:
143
+ - MIT
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.6.7
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Command line tool for automating GitHub labels creation.
165
+ test_files: []
166
+ has_rdoc: