Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2ddb401

Browse filesBrowse files
committed
added data binding for a file in gist
1 parent 3ec2568 commit 2ddb401
Copy full SHA for 2ddb401

File tree

Expand file treeCollapse file tree

2 files changed

+79
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+79
-0
lines changed

‎src/main/java/org/kohsuke/github/GHGist.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHGist.java
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44

55
import java.io.IOException;
6+
import java.util.Collections;
67
import java.util.Date;
8+
import java.util.HashMap;
9+
import java.util.Map;
10+
import java.util.Map.Entry;
711

812
/**
913
* Gist
@@ -28,6 +32,8 @@ public final class GHGist {
2832

2933
private String comments_url;
3034

35+
private Map<String,GHGistFile> files = new HashMap<String, GHGistFile>();
36+
3137
/**
3238
* User that owns this Gist.
3339
*/
@@ -99,9 +105,18 @@ public String getCommentsUrl() {
99105
return comments_url;
100106
}
101107

108+
public GHGistFile getFile(String name) {
109+
return files.get(name);
110+
}
111+
112+
public Map<String,GHGistFile> getFiles() {
113+
return Collections.unmodifiableMap(files);
114+
}
115+
102116
/*package*/ GHGist wrapUp(GHUser owner) {
103117
this.owner = owner;
104118
this.root = owner.root;
119+
wrapUp();
105120
return this;
106121
}
107122

@@ -112,9 +127,15 @@ public String getCommentsUrl() {
112127
/*package*/ GHGist wrapUp(GitHub root) throws IOException {
113128
this.owner = root.getUser(owner);
114129
this.root = root;
130+
wrapUp();
115131
return this;
116132
}
117133

134+
private void wrapUp() {
135+
for (Entry<String, GHGistFile> e : files.entrySet()) {
136+
e.getValue().fileName = e.getKey();
137+
}
138+
}
118139
String getApiTailUrl(String tail) {
119140
return "/gists/" + id + '/' + tail;
120141
}
+58Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.kohsuke.github;
2+
3+
/**
4+
* A file inside {@link GHGist}
5+
*
6+
* @author Kohsuke Kawaguchi
7+
*/
8+
public class GHGistFile {
9+
/*package almost final*/ String fileName;
10+
11+
private int size;
12+
private String raw_url, type, language, content;
13+
private boolean truncated;
14+
15+
16+
public String getFileName() {
17+
return fileName;
18+
}
19+
20+
/**
21+
* File size in bytes.
22+
*/
23+
public int getSize() {
24+
return size;
25+
}
26+
27+
/**
28+
* URL that serves this file as-is.
29+
*/
30+
public String getRawUrl() {
31+
return raw_url;
32+
}
33+
34+
/**
35+
* Content type of this Gist, such as "text/plain"
36+
*/
37+
public String getType() {
38+
return type;
39+
}
40+
41+
public String getLanguage() {
42+
return language;
43+
}
44+
45+
/**
46+
* Content of this file.
47+
*/
48+
public String getContent() {
49+
return content;
50+
}
51+
52+
/**
53+
* (?) indicates if {@link #getContent()} contains a truncated content.
54+
*/
55+
public boolean isTruncated() {
56+
return truncated;
57+
}
58+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.