Merge pull request #2 from codecop/topull

add Eclipse and IDEA project settings and do some code formatting
This commit is contained in:
Emily Bache 2014-01-26 00:02:13 -08:00
commit 370c77bb6b
27 changed files with 388 additions and 298 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/workspace.xml

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
GuildedRose

23
.idea/compiler.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,5 @@
<component name="CopyrightManager">
<settings default="">
<module2copyright />
</settings>
</component>

5
.idea/encodings.xml Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

10
.idea/misc.xml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

9
.idea/modules.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Java/Java.iml" filepath="$PROJECT_DIR$/Java/Java.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

8
.idea/vcs.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

7
Java/.classpath Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path=""/>
</classpath>

1
Java/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.class

17
Java/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GildedRose.java</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

22
Java/Java.iml Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$" />
<output-test url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.10.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

1
Java/com/gildedrose/GildedRose.java Executable file → Normal file
View File

@ -1,4 +1,5 @@
package com.gildedrose; package com.gildedrose;
class GildedRose { class GildedRose {
Item[] items; Item[] items;

View File

@ -1,4 +1,5 @@
package com.gildedrose; package com.gildedrose;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
@ -12,4 +13,5 @@ public class GildedRoseTest {
app.updateQuality(); app.updateQuality();
assertEquals("fixme", app.items[0].name); assertEquals("fixme", app.items[0].name);
} }
} }

1
Java/com/gildedrose/Item.java Executable file → Normal file
View File

@ -1,4 +1,5 @@
package com.gildedrose; package com.gildedrose;
public class Item { public class Item {
public String name; public String name;

9
Java/com/gildedrose/TexttestFixture.java Executable file → Normal file
View File

@ -4,10 +4,11 @@ public class TexttestFixture {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("OMGHAI!"); System.out.println("OMGHAI!");
Item[] items = new Item[] { new Item("+5 Dexterity Vest", 10, 20), Item[] items = new Item[] {
new Item("Aged Brie", 2, 0), new Item("+5 Dexterity Vest", 10, 20), //
new Item("Elixir of the Mongoose", 5, 7), new Item("Aged Brie", 2, 0), //
new Item("Sulfuras, Hand of Ragnaros", 0, 80), new Item("Elixir of the Mongoose", 5, 7), //
new Item("Sulfuras, Hand of Ragnaros", 0, 80), //
new Item("Sulfuras, Hand of Ragnaros", -1, 80), new Item("Sulfuras, Hand of Ragnaros", -1, 80),
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),

3
js/.gitignore vendored
View File

@ -1,3 +0,0 @@
*.swp
*~
*.bak

View File

@ -1,61 +0,0 @@
If you want to get cracking on the JavaScript source then do this:
git clone git@github.com:guyroyse/gilded-rose-javascript.git
Hi and welcome to team Gilded Rose.
As you know, we are a small inn with a prime location in a prominent city ran
by a friendly innkeeper named Allison. We also buy and sell only the finest
goods. Unfortunately, our goods are constantly degrading in quality as they
approach their sell by date.
We have a system in place that updates our inventory for us. It was developed
by a no-nonsense type named Leeroy, who has moved on to new adventures. Your
task is to add the new feature to our system so that we can begin selling a
new category of items.
First an introduction to our system:
- All items have a *sell_in* value which denotes the number of days we have to
sell the item
- All items have a *quality* value which denotes how valuable the item is
- At the end of each day our system lowers both values for every item
Pretty simple, right? Well this is where it gets interesting:
- Once the *sell_in* days is less then zero, *quality* degrades twice as fast
- The *quality* of an item is never negative
- "Aged Brie" actually increases in *quality* the older it gets
- The *quality* of an item is never more than 50
- "Sulfuras", being a legendary item, never has to be sold nor does it
decrease in *quality*
- "Backstage passes", like aged brie, increases in *quality* as it's *sell_in*
value decreases; *quality* increases by 2 when there are 10 days or less
and by 3 when there are 5 days or less but *quality* drops to 0 after the
concert
We have recently signed a supplier of conjured items. This requires an update
to our system:
- "Conjured" items degrade in *quality* twice as fast as normal items
Feel free to make any changes to the *update_quality* method and add any new
code as long as everything still works correctly. However, do not alter the
*Item* class or *items* property as those belong to the goblin in the corner
who will insta-rage and one-shot you as he doesn't believe in shared code
ownership.
Just for clarification, an item can never have its *quality* increase above 50,
however "Sulfuras" is a legendary item and as such its *quality* is 80 and it
never alters.
Sources:
<http://www.iamnotmyself.com/2011/02/13/RefactorThisTheGildedRoseKata.aspx>
<https://github.com/professor/GildedRose>

View File

@ -1,7 +1,9 @@
describe("Gilded Rose", function() { describe("Gilded Rose", function() {
it("should do something", function() { it("should foo", function() {
update_quality items = [ new Item("foo", 0, 0) ];
update_quality();
expect(items[0].name).toEqual("fixme");
}); });
}); });

View File

@ -3,7 +3,6 @@ import unittest
from gilded_rose import Item, GildedRose from gilded_rose import Item, GildedRose
class GildedRoseTest(unittest.TestCase): class GildedRoseTest(unittest.TestCase):
def test_foo(self): def test_foo(self):
items = [Item("foo", 0, 0)] items = [Item("foo", 0, 0)]

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function from __future__ import print_function
from gilded_rose import * from gilded_rose import *
if __name__ == "__main__": if __name__ == "__main__":

5
ruby/.buildpath Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry kind="con" path="org.eclipse.dltk.launching.INTERPRETER_CONTAINER"/>
</buildpath>

5
ruby/.loadpath Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<loadpath>
<pathentry path="" type="src" />
<pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con" />
</loadpath>

23
ruby/.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GildedRose.rb</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.rubypeople.rdt.core.rubybuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.dltk.core.scriptbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.rubypeople.rdt.core.rubynature</nature>
<nature>org.eclipse.dltk.ruby.core.nature</nature>
</natures>
</projectDescription>

2
ruby/gilded_rose.rb Executable file → Normal file
View File

@ -1,5 +1,5 @@
class GildedRose class GildedRose
def initialize(items) def initialize(items)
@items = items @items = items
end end

View File

@ -14,7 +14,7 @@ items = [
Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49), Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49),
# This Conjured item does not work properly yet # This Conjured item does not work properly yet
Item.new(name="Conjured Mana Cake", sell_in=3, quality=6), # <-- :O Item.new(name="Conjured Mana Cake", sell_in=3, quality=6), # <-- :O
] ]
days = 2 days = 2
if ARGV.size > 0 if ARGV.size > 0