Skip to content
Browse files

switching to maven and adding tests

  • Loading branch information...
1 parent 3dbf3aa commit 7e87577230f2e985948bb7f9bd705b595a650a1b @cosmin committed Feb 21, 2012
View
11 .gitignore
@@ -1,8 +1,3 @@
-/pom.xml
-*jar
-/lib
-/classes
-/native
-/.lein-failures
-/checkouts
-/.lein-deps-sum
+/target
+/.idea
+*.iml
View
159 pom.xml
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.offbytwo.class-finder</groupId>
+ <artifactId>class-finder</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <packaging>clojure</packaging>
+ <name>class-finder</name>
+ <description>A utility to find classes, designed for use at the REPL</description>
+ <url>http://github.com/cosmin/class-finder/</url>
+
+ <parent>
+ <groupId>org.sonatype.oss</groupId>
+ <artifactId>oss-parent</artifactId>
+ <version>7</version>
+ </parent>
+
+ <scm>
+ <connection>scm:git:git@github.com:cosmin/class-finder.git</connection>
+ <developerConnection>scm:git:git@github.com:cosmin/class-finder.git</developerConnection>
+ <url>https://github.com/cosmin/class-finder</url>
+ </scm>
+
+ <licenses>
+ <license>
+ <name>Eclipse Public License</name>
+ <url>http://www.eclipse.org/legal/epl-v10.html</url>
+ </license>
+ </licenses>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <developers>
+ <developer>
+ <name>Cosmin Stejerean</name>
+ <email>cosmin@offbytwo.com</email>
+ </developer>
+ </developers>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.theoryinpractise</groupId>
+ <artifactId>clojure-maven-plugin</artifactId>
+ <version>1.3.8</version>
+ <extensions>true</extensions>
+ <configuration>
+ <temporaryOutputDirectory>true</temporaryOutputDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3.1</version>
+ <inherited>true</inherited>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.2</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.5</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.clojure</groupId>
+ <artifactId>clojure</artifactId>
+ <version>1.3.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>release</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <repositories>
+ <repository>
+ <id>sonatype-oss</id>
+ <url>http://oss.sonatype.org/content/groups/public/</url>
+ </repository>
+ </repositories>
+</project>
View
7 project.clj
@@ -1,7 +0,0 @@
-(defproject class-finder "1.0.0-SNAPSHOT"
- :description "A utility to find classes, designed for use at the REPL"
- :dependencies [[org.clojure/clojure "1.3.0"]]
- :source-path "src/clojure"
- :test-path "test/clojure"
- :java-source-path "src/java"
- )
View
4 src/clojure/class_finder/core.clj → src/main/clojure/class_finder/core.clj
@@ -10,11 +10,11 @@
(let [classes (if (glob? classname)
(.findClassesByGlob @class-finder classname)
(.findClassesByName @class-finder classname))]
- (apply list classes)))
+ (apply sorted-set classes)))
([classname package-prefix]
(let [classes (if (glob? classname)
(.findClassesInPackageByGlob @class-finder
package-prefix classname)
(.findClassesInPackageByName @class-finder
package-prefix classname))]
- (apply list classes))))
+ (apply sorted-set classes))))
View
0 ...om/offbytwo/class_finder/ClassFinder.java → ...om/offbytwo/class_finder/ClassFinder.java
File renamed without changes.
View
27 src/test/clojure/class_finder/test/core.clj
@@ -0,0 +1,27 @@
+(ns class-finder.test.core
+ (:require [class-finder.core :as cf])
+ (:use [clojure.test]))
+
+(deftest test-find-class-by-name
+ (is (contains? (cf/find-classes "Pattern") "java.util.regex.Pattern")))
+
+(deftest test-find-class-by-name-in-package
+ (let [results (cf/find-classes "List" "java.util")]
+ (is (contains? results "java.util.List") "java.util.List not found")
+ (is (not (contains? results "java.awt.List")) "java.awt.List should not be found")))
+
+(deftest test-find-classes-by-glob
+ (let [results (cf/find-classes "*List")]
+ (is (contains? results "java.awt.List"))
+ (is (contains? results "java.text.DigitList"))
+ (is (contains? results "java.util.ArrayList"))
+ (is (contains? results "java.util.LinkedList"))
+ (is (contains? results "java.util.List"))))
+
+(deftest test-find-classes-by-glob-in-package
+ (let [results (cf/find-classes "*List" "java.util")]
+ (is (not (contains? results "java.awt.List")))
+ (is (not (contains? results "java.text.DigitList")))
+ (is (contains? results "java.util.ArrayList"))
+ (is (contains? results "java.util.LinkedList"))
+ (is (contains? results "java.util.List"))))
View
6 test/clojure/class_finder/test/core.clj
@@ -1,6 +0,0 @@
-(ns class-finder.test.core
- (:use [class-finder.core])
- (:use [clojure.test]))
-
-(deftest replace-me ;; FIXME: write
- (is false "No tests have been written."))

0 comments on commit 7e87577

Please sign in to comment.
Something went wrong with that request. Please try again.