Commit 7bf9bc8c authored by Brian Long's avatar Brian Long
Browse files

Merge branch 'develop' into stable

parents f774352b 64a65e35
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -98,9 +98,9 @@
									<mainClass>com.inteligr8.buxfer.CLI</mainClass>
								</manifest>
							</archive>
							<descriptorRefs>
								<descriptorRef>jar-with-dependencies</descriptorRef>
							</descriptorRefs>
							<descriptors>
								<descriptor>${basedir}/src/assembly/resources/assembly.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
+27 −0
Original line number Diff line number Diff line
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
	<id>full</id>
	
	<formats>
		<format>jar</format>
	</formats>
	
	<includeBaseDirectory>false</includeBaseDirectory>
	
	<dependencySets>
		<dependencySet>
			<outputDirectory>/</outputDirectory>
			<useProjectArtifact>true</useProjectArtifact>
			<unpack>true</unpack>
			<scope>runtime</scope>
		</dependencySet>
	</dependencySets>
	   
	<containerDescriptorHandlers>
		<containerDescriptorHandler>
			<handlerName>metaInf-services</handlerName>
		</containerDescriptorHandler>
	</containerDescriptorHandlers>
	
</assembly>
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class InvestNormalizeCLI {
									"Investment / Security / " + ptx.getSecuritySymbol(), null);
						return 1;
					} catch (IllegalArgumentException iae) {
						logger.trace("failed to parse: " + iae.getMessage(), iae);
						// try another
					}
				}
+14 −3
Original line number Diff line number Diff line
package com.inteligr8.buxfer;

import java.text.NumberFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -50,14 +51,14 @@ public class SofiInvestTransaction implements ParsedTransaction {
			this.throttle();
			
			this.securities = this.estimateSecurites();
			this.perSecurityPrice = this.estimatePrice(securities);
			this.perSecurityPrice = this.estimatePrice(this.securities);
			
			String action = Type.Buy.equals(type) ? "Bought" : "Sold";
			this.description = new StringBuilder()
					.append(action).append(' ')
					.append(this.securities == null ? "NaN" : NumberFormatFactory.getSecuritiesFormatter().format(this.securities)).append(' ')
					.append(this.getRange(NumberFormatFactory.getSecuritiesFormatter(), this.securities)).append(' ')
					.append(this.symbol).append(" @ ")
					.append(this.perSecurityPrice == null ? "NaN" : NumberFormatFactory.getPriceFormatter().format(this.perSecurityPrice)).toString();
					.append(this.getRange(NumberFormatFactory.getPriceFormatter(), this.perSecurityPrice)).toString();
		}
	}
	
@@ -160,4 +161,14 @@ public class SofiInvestTransaction implements ParsedTransaction {
		else return this.perSecurityPrice.getMidpoint();
	}
	
	private String getRange(NumberFormat formatter, NumericRange<? extends Number> range) {
		if (range == null) {
			return "NaN";
		} else if (range.isPoint()) {
			return formatter.format(range.getFrom().doubleValue());
		} else {
			return formatter.format(range.getFrom().doubleValue()) + "-" + formatter.format(range.getTo().doubleValue());
		}
	}

}
+0 −35
Original line number Diff line number Diff line
package com.inteligr8.buxfer;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.apache.http.impl.client.HttpClientBuilder;

import com.inteligr8.rs.ClientConfiguration;

public abstract class ConditionalIT {
	
	public abstract ClientConfiguration getConfiguration();
	
	public boolean hostExists() {
		String uri = this.getConfiguration().getBaseUrl();
		
		HttpUriRequest request = RequestBuilder.get()
				.setUri(uri)
				.build();
		
		HttpClient client = HttpClientBuilder.create()
				.setRedirectStrategy(DefaultRedirectStrategy.INSTANCE)
				.build();
		
		try {
			HttpResponse response = client.execute(request);
			return response.getStatusLine().getStatusCode() < 300;
		} catch (Exception e) {
			return false;
		}
	}

}
Loading