Skip to content

Commit

Permalink
Add Altmetric J identifier, ISSNs, and quotes properties
Browse files Browse the repository at this point in the history
  • Loading branch information
vtourraine committed Apr 11, 2013
1 parent 4673464 commit f30c4fd
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 178 deletions.
Expand Up @@ -25,5 +25,8 @@

@end

@interface SZNArrayToStringTransformer: NSValueTransformer
@interface SZNArrayToStringWithCommaTransformer: NSValueTransformer
@end

@interface SZNArrayToStringWithLineBreakTransformer: NSValueTransformer
@end
Expand Up @@ -43,7 +43,7 @@ - (IBAction)openDetailsURL:(id)sender
@end


@implementation SZNArrayToStringTransformer
@implementation SZNArrayToStringWithCommaTransformer

+ (Class)transformedValueClass
{
Expand All @@ -60,4 +60,23 @@ - (id)transformedValue:(id)value
return (value == nil) ? nil : [(NSArray *)value componentsJoinedByString:@", "];
}

@end

@implementation SZNArrayToStringWithLineBreakTransformer

+ (Class)transformedValueClass
{
return [NSArray class];
}

+ (BOOL)allowsReverseTransformation
{
return NO;
}

- (id)transformedValue:(id)value
{
return (value == nil) ? nil : [(NSArray *)value componentsJoinedByString:@"\n"];
}

@end
438 changes: 266 additions & 172 deletions Examples/SZNAltmetricDemoOSX/SZNAltmetricDemoOSX/en.lproj/MainMenu.xib

Large diffs are not rendered by default.

Expand Up @@ -23,6 +23,7 @@ - (void)testArticleFromRespondeDictionary

STAssertEqualObjects(article.addedOn, [NSDate dateWithTimeIntervalSince1970:1324491937], @"Added on not extracted");
STAssertEqualObjects(article.identifier, @"502878", @"Identifier not extracted");
STAssertEqualObjects(article.altmetricJIdentifier, @"4f6fa62f3cf058f6100082d3", @"J Identifier not extracted");
STAssertEqualObjects(article.ADSBibcode, @"2011natur.480..426v", @"ADS not extracted");
STAssertEqualObjects(article.citedByAccountsCount, @(393), @"Cited by accounts not extracted");
STAssertEqualObjects(article.citedByFacebookWallsCount, @(12), @"Cited by Facebook walls not extracted");
Expand All @@ -39,6 +40,10 @@ - (void)testArticleFromRespondeDictionary
STAssertEqualObjects(article.score, @(353.626), @"Score not extracted");
STAssertEqualObjects(article.subjects, @[@"science"], @"Subjects not extracteds");
STAssertEqualObjects(article.scopusSubjects, @[], @"Scopus subjects not extracteds");
NSArray *quotes = @[@"Take a look...", @"Third...", @"Nature..."];
STAssertEqualObjects(article.quotes, quotes, @"Quotes not extracteds");
NSArray *ISSNs = @[@"0028-0836", @"1744-7933"];
STAssertEqualObjects(article.ISSNs, ISSNs, @"ISSNs not extracteds");
STAssertEqualObjects(article.imageSmallURL.absoluteString, @"http://fastly.altmetric.com/?size=64&score=354&types=bfgttttt", @"Image small URL not extracted");
STAssertEqualObjects(article.imageMediumURL.absoluteString, @"http://fastly.altmetric.com/?size=100&score=354&types=bfgttttt", @"Image medium URL not extracted");
STAssertEqualObjects(article.imageLargeURL.absoluteString, @"http://fastly.altmetric.com/?size=180&score=354&types=bfgttttt", @"Image large URL not extracted");
Expand Down
Expand Up @@ -4,10 +4,9 @@
"pmid":"22193080",
"nlmid":"0410462",
"tq":[
"Take a look back at the year in science with our review of the biggest stories of 2011",
"Third: Our round-up of the year in research and science policy +interactive timeline",
"Nature's 'year in science' review is really rather essential @NatureNews",
"Scientific Paper Trail 2011 #HigherEd"],
"Take a look...",
"Third...",
"Nature..."],
"ads_id":"2011natur.480..426v",
"arxiv_id": "arXiv-123",
"altmetric_jid":"4f6fa62f3cf058f6100082d3",
Expand Down
15 changes: 15 additions & 0 deletions SZNAltmetric/SZNAltmetricArticle.h
Expand Up @@ -34,6 +34,11 @@
*/
@property (copy, nonatomic) NSString *identifier;

/**
The Altmetric J Identifier of the article.
*/
@property (copy, nonatomic) NSString *altmetricJIdentifier;

/**
The title of the article.
*/
Expand Down Expand Up @@ -99,6 +104,11 @@
*/
@property (strong, nonatomic) NSNumber *score;

/**
The ISSNs of the article.
*/
@property (strong, nonatomic) NSArray *ISSNs;

/**
The Altmetric image URL of the article (large).
*/
Expand Down Expand Up @@ -159,6 +169,11 @@
*/
@property (strong, nonatomic) NSArray *scopusSubjects;

/**
The quotes of the article.
*/
@property (strong, nonatomic) NSArray *quotes;

/**
The readers count of the article.
*/
Expand Down
3 changes: 3 additions & 0 deletions SZNAltmetric/SZNAltmetricArticle.m
Expand Up @@ -30,6 +30,7 @@ + (SZNAltmetricArticle *)articleWithAPIResponseObject:(id)responseObject
SZNAltmetricArticle *article = [SZNAltmetricArticle new];
article.addedOn = [NSDate dateWithTimeIntervalSince1970:[responseObject[@"added_on"] doubleValue]];
article.identifier = [NSString stringWithFormat:@"%@", responseObject[@"altmetric_id"]];
article.altmetricJIdentifier = [NSString stringWithFormat:@"%@", responseObject[@"altmetric_jid"]];
article.ADSBibcode = responseObject[@"ads_id"];
article.citedByAccountsCount = responseObject[@"cited_by_accounts_count"];
article.citedByFacebookWallsCount = responseObject[@"cited_by_fbwalls_count"];
Expand All @@ -46,6 +47,8 @@ + (SZNAltmetricArticle *)articleWithAPIResponseObject:(id)responseObject
article.score = responseObject[@"score"];
article.subjects = responseObject[@"subjects"];
article.scopusSubjects = responseObject[@"scopus_subjects"];
article.quotes = responseObject[@"tq"];
article.ISSNs = responseObject[@"issns"];
article.imageLargeURL = [NSURL URLWithString:responseObject[@"images"][@"large"]];
article.imageMediumURL = [NSURL URLWithString:responseObject[@"images"][@"medium"]];
article.imageSmallURL = [NSURL URLWithString:responseObject[@"images"][@"small"]];
Expand Down

0 comments on commit f30c4fd

Please sign in to comment.