Skip to content

Commit

Permalink
Merge pull request #37 from mixalturek/master
Browse files Browse the repository at this point in the history
[JENKINS-21922] REST API/Remote access API
  • Loading branch information
mixalturek committed Mar 14, 2014
2 parents 7ce2774 + 4b42fdc commit 2453b1e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/hudson/plugins/sloccount/SloccountResult.java
@@ -1,6 +1,7 @@
package hudson.plugins.sloccount;

import hudson.model.AbstractBuild;
import hudson.model.Api;
import hudson.model.ModelObject;
import hudson.plugins.sloccount.model.File;
import hudson.plugins.sloccount.model.FileFilter;
Expand Down Expand Up @@ -147,6 +148,15 @@ public SloccountResult getFolderResult(String jumbledFolder){
return new BreadCrumbResult(filtered, this.owner, folder);
}

/**
* Gets the remote API for the build result.
*
* @return the remote API
*/
public Api getApi() {
return new Api(getStatistics());
}

private static class LanguageFileFilter implements FileFilter, Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 0L;
Expand Down
Expand Up @@ -2,11 +2,15 @@

import java.io.Serializable;

import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

/**
* Statistic of one language. The class is thread safe.
*
* @author Michal Turek
*/
@ExportedBean
public class SloccountLanguageStatistics implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 0L;
Expand Down Expand Up @@ -42,6 +46,7 @@ public SloccountLanguageStatistics(String languageName, int lineCount,
*
* @return the name
*/
@Exported(name="name")
public String getName(){
return name;
}
Expand All @@ -51,6 +56,7 @@ public String getName(){
*
* @return the number of lines
*/
@Exported(name="lines")
public int getLineCount(){
return lineCount;
}
Expand All @@ -60,6 +66,7 @@ public int getLineCount(){
*
* @return the number of files
*/
@Exported(name="files")
public int getFileCount(){
return fileCount;
}
Expand Down
Expand Up @@ -8,11 +8,15 @@
import java.util.LinkedList;
import java.util.List;

import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

/**
* Report statistics. The class is thread safe.
*
* @author Michal Turek
*/
@ExportedBean
public class SloccountReportStatistics implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 0L;
Expand All @@ -26,14 +30,15 @@ public class SloccountReportStatistics implements Serializable {
* @param statistics the statistics per language
*/
public SloccountReportStatistics(List<SloccountLanguageStatistics> statistics) {
this.statistics = new ArrayList<SloccountLanguageStatistics>(statistics);
this.statistics = new ArrayList<SloccountLanguageStatistics>(statistics);
}

/**
* Get the statistics.
*
* @return the statistics per language
*/
@Exported(name="languages")
public List<SloccountLanguageStatistics> getStatistics() {
return Collections.unmodifiableList(statistics);
}
Expand All @@ -43,6 +48,7 @@ public List<SloccountLanguageStatistics> getStatistics() {
*
* @return the lines count
*/
@Exported(name="totalLines")
public int getLineCount() {
int lineCount = 0;

Expand All @@ -58,6 +64,7 @@ public int getLineCount() {
*
* @return the files count
*/
@Exported(name="totalFiles")
public int getFileCount() {
int fileCount = 0;

Expand All @@ -73,6 +80,7 @@ public int getFileCount() {
*
* @return the languages count
*/
@Exported(name="totalLanguages")
public int getLanguageCount() {
return statistics.size();
}
Expand Down

0 comments on commit 2453b1e

Please sign in to comment.