targit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +13 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +26 -0
- data/Rakefile +14 -0
- data/bin/targit +7 -0
- data/lib/targit.rb +15 -0
- data/lib/targit/asset.rb +71 -0
- data/lib/targit/release.rb +27 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/targit_spec.rb +1 -0
- data/targit.gemspec +25 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bc7c75ab2e849e39e06887d5df8044695f033ced
|
4
|
+
data.tar.gz: f0c5e9dafa2fbf31125b6efb6c36cb38e7c54512
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 261daa72303a3406eecb7fafd53f379d70a8d37ca37cf20e02e310ea21aa8ed68fc3ee36de0748ba1ff7e52a4a415eaa57317cedbfbe0532f01847f2034f4a15
|
7
|
+
data.tar.gz: 927117fbf0e831f9c8720465b8040dd50474c0c45777a3c7b21e2119901b3fddaf3c8feec241a6e7fa471962a680fe4e9bbdf83141d621a131f2bc0508cf93f6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
rvm:
|
4
|
+
- 2.1.0
|
5
|
+
- 2.0.0
|
6
|
+
- 1.9.3
|
7
|
+
notifications:
|
8
|
+
email: false
|
9
|
+
irc:
|
10
|
+
template:
|
11
|
+
- "%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}"
|
12
|
+
channels:
|
13
|
+
secure: m35LgyTcdJpvmx7u+3HVVysfjBCH64dIsFjq4z9zAMOyyTeCoLDIVJ0U5UeYBf/IrCPNv7iyEpnRzgEpVEOn4NLzrmw0CCarI1W1GbghmbXRyoNL83qBm5ABqSKVFkhQWjXWR0H/o1qWERDJCk8MhTbYpWje/g4bzefNsD3wPQ4=
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Les Aker
|
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.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
targit
|
2
|
+
=========
|
3
|
+
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/targit.svg)](https://rubygems.org/gems/targit)
|
5
|
+
[![Dependency Status](https://img.shields.io/gemnasium/akerl/targit.svg)](https://gemnasium.com/akerl/targit)
|
6
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/akerl/targit.svg)](https://codeclimate.com/github/akerl/targit)
|
7
|
+
[![Coverage Status](https://img.shields.io/coveralls/akerl/targit.svg)](https://coveralls.io/r/akerl/targit)
|
8
|
+
[![Build Status](https://img.shields.io/travis/akerl/targit.svg)](https://travis-ci.org/akerl/targit)
|
9
|
+
[![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
|
10
|
+
|
11
|
+
Manages GitHub release assets for pushing binaries and other large files
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
gem install targit
|
18
|
+
|
19
|
+
## Contributors
|
20
|
+
|
21
|
+
* [Jon Chen](https://github.com/fly) for suggesting release assets for storing large files, and for coming up with the workflow that this gem is built to streamline.
|
22
|
+
|
23
|
+
## License
|
24
|
+
|
25
|
+
targit is released under the MIT License. See the bundled LICENSE file for details.
|
26
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
desc 'Run tests'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
desc 'Run Rubocop on the gem'
|
9
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
10
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
11
|
+
task.fail_on_error = true
|
12
|
+
end
|
13
|
+
|
14
|
+
task default: [:spec, :rubocop, :build, :install]
|
data/bin/targit
ADDED
data/lib/targit.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
##
|
2
|
+
# This module provides a simple interface to GitHub's release assets
|
3
|
+
module Targit
|
4
|
+
class << self
|
5
|
+
##
|
6
|
+
# Insert a helper .new() method for creating a new Cache object
|
7
|
+
|
8
|
+
def new(*args)
|
9
|
+
self::Asset.new(*args)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'targit/asset'
|
15
|
+
require 'targit/release'
|
data/lib/targit/asset.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
require 'octoauth'
|
3
|
+
|
4
|
+
module Targit
|
5
|
+
##
|
6
|
+
# Define asset object for a release
|
7
|
+
class Asset
|
8
|
+
attr_reader :release, :asset, :name, :github_data
|
9
|
+
|
10
|
+
def initialize(asset, params = {})
|
11
|
+
@options = params
|
12
|
+
@config = _config
|
13
|
+
@client = _client
|
14
|
+
@release = _release
|
15
|
+
@upload_options = _options
|
16
|
+
@asset = asset
|
17
|
+
@name = @upload_options[:name] || File.basename(@asset)
|
18
|
+
end
|
19
|
+
|
20
|
+
def upload!
|
21
|
+
delete! if @options[:force]
|
22
|
+
fail('Release asset already exists') if already_exists?
|
23
|
+
@client.upload_asset @release[:url], @asset, @options
|
24
|
+
end
|
25
|
+
|
26
|
+
def already_exists?
|
27
|
+
github_data != nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete!
|
31
|
+
asset = github_data
|
32
|
+
return unless asset
|
33
|
+
@client.delete_release_asset asset[:url]
|
34
|
+
end
|
35
|
+
|
36
|
+
def github_data
|
37
|
+
@client.release_assets(@release[:url]).find { |x| x[:name] == @name }
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def _config
|
43
|
+
@options[:authfile] ||= Octoauth::DEFAULT_FILE
|
44
|
+
@options[:autosave] ||= true
|
45
|
+
Octoauth.new(
|
46
|
+
note: 'targit',
|
47
|
+
file: @options[:authfile],
|
48
|
+
autosave: @options[:autosave]
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def _client
|
53
|
+
Octokit::Client.new(
|
54
|
+
access_token: @config.token,
|
55
|
+
api_endpoint: @options[:api_endpoint],
|
56
|
+
web_endpoint: @options[:api_endpoint],
|
57
|
+
auto_paginate: true
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
def _release
|
62
|
+
Targit::Release.new(@client, @options).data
|
63
|
+
end
|
64
|
+
|
65
|
+
def _options
|
66
|
+
[:name, :content_type].each_with_object({}) do |option, hash|
|
67
|
+
hash[option] = @options[option] if @options[option]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Targit
|
2
|
+
##
|
3
|
+
# GitHub Release object
|
4
|
+
class Release
|
5
|
+
attr_reader :data
|
6
|
+
|
7
|
+
def initialize(client, params = {})
|
8
|
+
@client = client
|
9
|
+
@data = find params
|
10
|
+
create(params) if @data.nil? && params[:create]
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def find(params)
|
16
|
+
@client.releases(params[:repo]).find do |x|
|
17
|
+
x[:tag_name] == params[:tag]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def create(params)
|
22
|
+
@client.create_release(params[:repo], params[:tag])
|
23
|
+
params[:create] = false
|
24
|
+
find params
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/targit_spec.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'spec_helper'
|
data/targit.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'targit'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
5
|
+
|
6
|
+
s.summary = 'Tool for adding GitHub release assets'
|
7
|
+
s.description = "Manages GitHub release assets for pushing binaries and other large files"
|
8
|
+
s.authors = ['Les Aker']
|
9
|
+
s.email = 'me@lesaker.org'
|
10
|
+
s.homepage = 'https://github.com/akerl/targit'
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split
|
14
|
+
s.test_files = `git ls-files spec/*`.split
|
15
|
+
s.executables = ['targit']
|
16
|
+
|
17
|
+
s.add_dependency 'octokit', '~> 3.2.0'
|
18
|
+
s.add_dependency 'octoauth', '~> 0.0.6'
|
19
|
+
|
20
|
+
s.add_development_dependency 'rubocop', '~> 0.24.0'
|
21
|
+
s.add_development_dependency 'rake', '~> 10.3.2'
|
22
|
+
s.add_development_dependency 'coveralls', '~> 0.7.0'
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.0.0'
|
24
|
+
s.add_development_dependency 'fuubar', '~> 2.0.0.rc1'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: targit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Les Aker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-29 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: 3.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octoauth
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.24.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.24.0
|
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.3.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 10.3.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.7.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.7.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: fuubar
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.0.0.rc1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.0.0.rc1
|
111
|
+
description: Manages GitHub release assets for pushing binaries and other large files
|
112
|
+
email: me@lesaker.org
|
113
|
+
executables:
|
114
|
+
- targit
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".rubocop.yml"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/targit
|
127
|
+
- lib/targit.rb
|
128
|
+
- lib/targit/asset.rb
|
129
|
+
- lib/targit/release.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
- spec/targit_spec.rb
|
132
|
+
- targit.gemspec
|
133
|
+
homepage: https://github.com/akerl/targit
|
134
|
+
licenses:
|
135
|
+
- MIT
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.0.14
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Tool for adding GitHub release assets
|
157
|
+
test_files:
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- spec/targit_spec.rb
|
160
|
+
has_rdoc:
|