github_releases 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -1
- data/app/controllers/github_releases/releases_controller.rb +6 -2
- data/app/helpers/github_releases/application_helper.rb +0 -3
- data/config/routes.rb +1 -0
- data/lib/github_releases/version.rb +1 -1
- data/lib/github_releases.rb +11 -7
- data/lib/tasks/{refresh_cache.rake → refresh.rake} +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df93686d5c35a861acdb0fd62da461a9f8690d8
|
4
|
+
data.tar.gz: 9c5e71e95a7cf628918e55c591b73e68ffbb2113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2792271d180d4b92309766c26379623f8f75952ca6d3dbcc5a123924c16fbb23f67d08f65552d78535e2a1c0249e4c10a367da02630edb33cd703421850dc7f
|
7
|
+
data.tar.gz: 16b740d878071b602019adb1aeac68b1ab9a4387ae0f75c5a6005bb10e5fb741b42cfba728074b52caaee7da170914e13168f6a78b905ded97de3b812829140e
|
data/README.md
CHANGED
@@ -36,14 +36,24 @@ An app that utilizes Github's release feature
|
|
36
36
|
end
|
37
37
|
|
38
38
|
```
|
39
|
+
|
40
|
+
4. Set your GitHub API token in a GITHUB_API_TOKEN environment variable.
|
39
41
|
|
40
|
-
|
42
|
+
5. Install
|
41
43
|
|
42
44
|
```ruby
|
43
45
|
rails g github_releases:install
|
44
46
|
```
|
45
47
|
|
46
48
|
This mounts the engine at `/releases`.
|
49
|
+
|
50
|
+
If you're using a pure Rails app, and want to use the current_version view helper, add GithubReleases::ApplicationHelper to your ApplicationController.
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
class ApplicationController < ActionController::Base
|
54
|
+
helper GithubReleases::ApplicationHelper
|
55
|
+
end
|
56
|
+
```
|
47
57
|
|
48
58
|
## Usage
|
49
59
|
|
@@ -52,6 +62,32 @@ releases in json. '/releases/latest' will expose the latest release to use in
|
|
52
62
|
displaying your apps current version. You may also access any single release
|
53
63
|
by id '/releases/:id'.
|
54
64
|
|
65
|
+
For pure Rails apps, you may access the current_version of your app with a view helper...
|
66
|
+
|
67
|
+
```Ruby
|
68
|
+
<%= current_version %>
|
69
|
+
```
|
70
|
+
|
71
|
+
Or if you don't want to add the helper module to your controller, you can call the class directly...
|
72
|
+
|
73
|
+
```Ruby
|
74
|
+
<%= GithubReleases.release('latest')['tag_name'] %>
|
75
|
+
```
|
76
|
+
|
77
|
+
**IMPORTANT** All calls to the GitHub API are cached. It's up to you to refresh the cache when releases should be updated. There are two ways to do this. Via the rake task...
|
78
|
+
|
79
|
+
```
|
80
|
+
rake github_releases:refresh_cache
|
81
|
+
```
|
82
|
+
|
83
|
+
Or via a Ruby class method...
|
84
|
+
|
85
|
+
```Ruby
|
86
|
+
GithubReleases.refresh_cache
|
87
|
+
```
|
88
|
+
|
89
|
+
One strategy is to run the rake task in a post deploy hook.
|
90
|
+
|
55
91
|
## Authors
|
56
92
|
|
57
93
|
* Brian Bauer / [@bbauer](https://github.com/bbauer)
|
@@ -1,9 +1,13 @@
|
|
1
1
|
class GithubReleases::ReleasesController < GithubReleases::ApplicationController
|
2
2
|
def index
|
3
|
-
render json: GithubReleases.
|
3
|
+
render json: GithubReleases.all, status: 200
|
4
4
|
end
|
5
5
|
|
6
6
|
def show
|
7
|
-
render json: GithubReleases.
|
7
|
+
render json: GithubReleases.find(params[:id]), status: 200
|
8
|
+
end
|
9
|
+
|
10
|
+
def current_version
|
11
|
+
render json: { version: GithubReleases.current_version }, status: 200
|
8
12
|
end
|
9
13
|
end
|
data/config/routes.rb
CHANGED
data/lib/github_releases.rb
CHANGED
@@ -6,19 +6,23 @@ module GithubReleases
|
|
6
6
|
LATEST_ID = 'latest'
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def
|
10
|
-
cache.write(RELEASES_KEY, get(endpoint))
|
11
|
-
cache.write("#{RELEASE_KEY}-#{LATEST_ID}", get("#{endpoint}/#{LATEST_ID}"))
|
12
|
-
end
|
13
|
-
|
14
|
-
def releases
|
9
|
+
def all
|
15
10
|
fetch(RELEASES_KEY, endpoint)
|
16
11
|
end
|
17
12
|
|
18
|
-
def
|
13
|
+
def find(id)
|
19
14
|
fetch("#{RELEASE_KEY}-#{id}", "#{endpoint}/#{id}")
|
20
15
|
end
|
21
16
|
|
17
|
+
def current_version
|
18
|
+
ENV['CURRENT_VERSION'] || find(LATEST_ID)['tag_name']
|
19
|
+
end
|
20
|
+
|
21
|
+
def refresh
|
22
|
+
cache.write(RELEASES_KEY, get(endpoint))
|
23
|
+
cache.write("#{RELEASE_KEY}-#{LATEST_ID}", get("#{endpoint}/#{LATEST_ID}"))
|
24
|
+
end
|
25
|
+
|
22
26
|
private
|
23
27
|
|
24
28
|
def fetch(key, resource)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_releases
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bbauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
- lib/github_releases/engine.rb
|
105
105
|
- lib/github_releases/version.rb
|
106
106
|
- lib/tasks/github_releases_tasks.rake
|
107
|
-
- lib/tasks/
|
107
|
+
- lib/tasks/refresh.rake
|
108
108
|
homepage: ''
|
109
109
|
licenses:
|
110
110
|
- MIT
|