FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
developer.github.com/lib/changes_helper.rb at commit-status-examples · LegendZhu/developer.github.com · GitHub
LegendZhu
/
developer.github.com
Public
forked from
github/developer.github.com
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
developer.github.com
/
lib
/
changes_helper.rb
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (78 loc) · 2 KB
Breadcrumbs
developer.github.com
/
lib
/
changes_helper.rb
Copy path
File metadata and controls
89 lines (78 loc) · 2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
module
ChangesHelper
MimeFormat
=
"application/vnd.github.%s+json"
.
freeze
# Public: Filters the change items out. If a version is given, show only the
# items related to that version.
#
# version - Optional String version key.
#
# Returns an Array of the first 30 Nanoc::Item objects, sorted in reverse
# chronological order.
def
api_changes
(
version
=
nil
)
changes
=
@items
.
select
{
|
item
|
item
[
:kind
]
==
'change'
}
if
version
version_s
=
version
.
to_s
changes
.
select
{
|
item
|
item
[
:api_version
]
==
version_s
}
else
changes
end
.
sort!
do
|
x
,
y
|
attribute_to_time
(
y
[
:created_at
]
)
<=>
attribute_to_time
(
x
[
:created_at
]
)
end
.
first
(
30
)
end
# Public
def
current_api
@current_api
||=
(
api_versions
[
-
2
]
||
api_versions
.
first
)
.
first
end
# Public
def
upcoming_api
@upcoming_api
||=
begin
version
,
date
=
api_versions
.
last
version
unless
date
end
end
# Public
def
current_api?
(
version
)
@api_current_checks
||=
{
}
if
@api_current_checks
.
key?
(
version
)
@api_current_checks
[
version
]
end
@api_current_checks
[
version
]
=
version
==
current_api
end
# Public
def
no_current_api_versions?
(
*
versions
)
versions
.
none?
{
|
v
|
current_api?
(
v
)
}
end
# Public
def
api_released_at
(
version
)
@api_releases
||=
{
}
if
@api_releases
.
key?
(
version
)
@api_releases
[
version
]
end
@api_releases
[
version
]
=
begin
pair
=
api_versions
.
detect
do
|
(
name
,
date
)
|
name
==
version
end
pair
?
pair
[
1
]
:
nil
end
end
# Public
def
api_mimetype_listing
(
version
)
version_s
=
version
.
to_s
mime
=
mimetype_for
version_s
if
time
=
api_released_at
(
version_s
)
mime
<<
" ("
mime
<<
"Current, "
if
current_api?
(
version_s
)
mime
<<
strftime
(
time
)
mime
<<
")"
else
mime
end
end
# Internal
def
mimetype_for
(
version
)
MimeFormat
%
version
.
to_s
end
# Internal
def
api_versions
@api_versions
||=
Array
(
@site
.
config
[
:api_versions
]
)
end
end
Back
|
FazBrowse Home
|
New Git URL