github_releases 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/MIT-LICENSE +20 -0
- data/README.md +106 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/github_releases/application.js +13 -0
- data/app/assets/stylesheets/github_releases/application.css +15 -0
- data/app/controllers/github_releases/application_controller.rb +4 -0
- data/app/controllers/github_releases/releases_controller.rb +9 -0
- data/app/helpers/github_releases/application_helper.rb +4 -0
- data/app/views/layouts/github_releases/application.html.erb +14 -0
- data/config/routes.rb +4 -0
- data/lib/generators/github_releases/install/install_generator.rb +7 -0
- data/lib/generators/github_releases/install/templates/initializer.rb +4 -0
- data/lib/github_releases/client.rb +31 -0
- data/lib/github_releases/engine.rb +20 -0
- data/lib/github_releases/version.rb +3 -0
- data/lib/github_releases.rb +52 -0
- data/lib/tasks/github_releases_tasks.rake +4 -0
- data/lib/tasks/refresh_cache.rake +6 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6afb8ede22c5ea03705e89949447bc46430f1759
|
4
|
+
data.tar.gz: 254ec6f8cb916df9ea7388724bfc2b52d78f9149
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23d6fa5661505f7f287e2ff6fe1b36a7de79e78058771547bee41dbb8e99ea504ecf852343ea0f0b4beb9e03afbd1659e380c7c6818956933d7386f92809ef2a
|
7
|
+
data.tar.gz: 0876224a9ce456a52b90f0a68f456a3e78421037bbb0442ea46ceb3d72ad01487b5666bffa0c97039621af2b0ba412cf05e198258c295b0b7f83bbfa8753f928
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 bbauer
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# Github Releases
|
2
|
+
|
3
|
+
Github Releases creates an endpoint that exposes an app's releases for use in
|
4
|
+
displaying a current version.
|
5
|
+
|
6
|
+
## Current Version
|
7
|
+
|
8
|
+
0.0.1
|
9
|
+
|
10
|
+
## Requirements
|
11
|
+
|
12
|
+
An app that utilizes Github's release feature
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
1. Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'github_releases'
|
20
|
+
```
|
21
|
+
|
22
|
+
2. And then execute:
|
23
|
+
|
24
|
+
```console
|
25
|
+
bundle
|
26
|
+
```
|
27
|
+
|
28
|
+
|
29
|
+
3. Configure your app in a config/initializers/github_releases.rb initializer
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
GithubReleases.setup do |config|
|
33
|
+
# configure your app's Github username
|
34
|
+
config.username = 'g5search'
|
35
|
+
# configure your app's Github repo name
|
36
|
+
config.repo = 'g5-cxm'
|
37
|
+
end
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
4. Install
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
rails g github_releases:install
|
45
|
+
```
|
46
|
+
|
47
|
+
This mounts the engine at `/releases`.
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
The engine exposes an endpoint at '/releases' that will list all of the app's
|
52
|
+
releases in json. '/releases/latest' will expose the latest release to use in
|
53
|
+
displaying your apps current version. You may also access any single release
|
54
|
+
by id '/releases/:id'.
|
55
|
+
|
56
|
+
## Authors
|
57
|
+
|
58
|
+
* Brian Bauer / [@bbauer](https://github.com/bbauer)
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. [Fork it](https://github.com/g5search/github_releases/fork)
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Write your code and **specs**
|
65
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
6. Create a new Pull Request
|
68
|
+
|
69
|
+
If you find bugs, have feature requests or questions, please
|
70
|
+
[file an issue](https://github.com/g5search/github_releases/issues).
|
71
|
+
|
72
|
+
## Specs
|
73
|
+
|
74
|
+
### Running the specs
|
75
|
+
|
76
|
+
Run specs via `rspec` with:
|
77
|
+
|
78
|
+
```bash
|
79
|
+
$ rspec spec
|
80
|
+
```
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
Copyright (c) 2015 G5
|
85
|
+
|
86
|
+
MIT License
|
87
|
+
|
88
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
89
|
+
a copy of this software and associated documentation files (the
|
90
|
+
"Software"), to deal in the Software without restriction, including
|
91
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
92
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
93
|
+
permit persons to whom the Software is furnished to do so, subject to
|
94
|
+
the following conditions:
|
95
|
+
|
96
|
+
The above copyright notice and this permission notice shall be
|
97
|
+
included in all copies or substantial portions of the Software.
|
98
|
+
|
99
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
100
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
101
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
102
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
103
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
104
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
105
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
106
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'GithubReleases'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'spec'
|
32
|
+
t.pattern = 'spec/**/*_spec.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>GithubReleases</title>
|
5
|
+
<%= stylesheet_link_tag "github_releases/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "github_releases/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module GithubReleases::Client
|
2
|
+
def fetch(key, resource)
|
3
|
+
return cache.read(key) if cache.exist?(key)
|
4
|
+
cache.write(key, get(resource))
|
5
|
+
cache.read(key)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def get(resource)
|
11
|
+
JSON.parse(HTTParty.get(resource, headers: headers).body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def headers
|
15
|
+
{
|
16
|
+
'Content-Type' => 'application/json',
|
17
|
+
'Accept' => 'application/vnd.github.v3+json',
|
18
|
+
'User-Agent' => GithubReleases.username,
|
19
|
+
'Authorization' => "token #{ENV['GITHUB_API_TOKEN']}"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def endpoint
|
24
|
+
"#{GithubReleases.github_api}/repos/#{GithubReleases.username}/" \
|
25
|
+
"#{GithubReleases.repo}/releases"
|
26
|
+
end
|
27
|
+
|
28
|
+
def cache
|
29
|
+
Rails.cache
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module GithubReleases
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace GithubReleases
|
4
|
+
|
5
|
+
config.autoload_paths << GithubReleases::Engine.root.join('lib')
|
6
|
+
config.generators { |g| g.test_framework :rspec }
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
mattr_accessor :repo, :username, :github_api
|
11
|
+
|
12
|
+
self.repo = nil
|
13
|
+
self.username = nil
|
14
|
+
self.github_api = 'https://api.github.com'
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.setup(&block)
|
18
|
+
yield self
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'github_releases/engine'
|
2
|
+
|
3
|
+
module GithubReleases
|
4
|
+
RELEASES_KEY = 'releases'
|
5
|
+
RELEASE_KEY = 'release'
|
6
|
+
LATEST_ID = 'latest'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def refresh_cache
|
10
|
+
cache.write(RELEASES_KEY, get(endpoint))
|
11
|
+
cache.write("#{RELEASE_KEY}-#{LATEST_ID}", get("#{endpoint}/#{LATEST_ID}"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def releases
|
15
|
+
fetch(RELEASES_KEY, endpoint)
|
16
|
+
end
|
17
|
+
|
18
|
+
def release(id)
|
19
|
+
fetch("#{RELEASE_KEY}-#{id}", "#{endpoint}/#{id}")
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def fetch(key, resource)
|
25
|
+
return cache.read(key) if cache.exist?(key)
|
26
|
+
cache.write(key, get(resource))
|
27
|
+
cache.read(key)
|
28
|
+
end
|
29
|
+
|
30
|
+
def get(resource)
|
31
|
+
JSON.parse(HTTParty.get(resource, headers: headers).body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def headers
|
35
|
+
{
|
36
|
+
'Content-Type' => 'application/json',
|
37
|
+
'Accept' => 'application/vnd.github.v3+json',
|
38
|
+
'User-Agent' => GithubReleases.username,
|
39
|
+
'Authorization' => "token #{ENV['GITHUB_API_TOKEN']}"
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def endpoint
|
44
|
+
"#{GithubReleases.github_api}/repos/#{GithubReleases.username}/" \
|
45
|
+
"#{GithubReleases.repo}/releases"
|
46
|
+
end
|
47
|
+
|
48
|
+
def cache
|
49
|
+
Rails.cache
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_releases
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- bbauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
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: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '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'
|
83
|
+
description: Exposes an apps Github releases
|
84
|
+
email:
|
85
|
+
- brian.bauer@g5platform.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- MIT-LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- app/assets/javascripts/github_releases/application.js
|
94
|
+
- app/assets/stylesheets/github_releases/application.css
|
95
|
+
- app/controllers/github_releases/application_controller.rb
|
96
|
+
- app/controllers/github_releases/releases_controller.rb
|
97
|
+
- app/helpers/github_releases/application_helper.rb
|
98
|
+
- app/views/layouts/github_releases/application.html.erb
|
99
|
+
- config/routes.rb
|
100
|
+
- lib/generators/github_releases/install/install_generator.rb
|
101
|
+
- lib/generators/github_releases/install/templates/initializer.rb
|
102
|
+
- lib/github_releases.rb
|
103
|
+
- lib/github_releases/client.rb
|
104
|
+
- lib/github_releases/engine.rb
|
105
|
+
- lib/github_releases/version.rb
|
106
|
+
- lib/tasks/github_releases_tasks.rake
|
107
|
+
- lib/tasks/refresh_cache.rake
|
108
|
+
homepage: ''
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.4.5
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Exposes an apps Github releases
|
132
|
+
test_files: []
|