greyhawkweather 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +28 -0
  5. data/History.txt +5 -0
  6. data/Manifest.txt +16 -14
  7. data/Rakefile +10 -22
  8. data/bin/greyweathergen +6 -2
  9. data/greyhawkweather.gemspec +33 -0
  10. data/lib/baselinedata.rb +1 -3
  11. data/lib/greyhawkweather.rb +2 -3
  12. data/lib/greyhawkweather/version.rb +4 -0
  13. data/lib/greyhawkweathergenerator.rb +4 -6
  14. data/lib/options.rb +15 -0
  15. data/lib/precipitationoccurance.rb +8 -4
  16. data/lib/singledayweather.rb +11 -3
  17. data/lib/skyconditions.rb +1 -1
  18. data/lib/temperaturerange.rb +10 -2
  19. data/lib/util/dieroller.rb +3 -3
  20. data/lib/weathergenerator.rb +15 -9
  21. data/lib/wind.rb +3 -1
  22. data/spec/acceptance_spec.rb +52 -0
  23. data/spec/dieroller_spec.rb +22 -0
  24. data/spec/latitude_spec.rb +25 -0
  25. data/spec/month_spec.rb +34 -0
  26. data/spec/options_spec.rb +25 -0
  27. data/spec/precipation_spec.rb +23 -0
  28. data/spec/precipitation_occurance_spec.rb +114 -0
  29. data/spec/singledayweather_spec.rb +44 -0
  30. data/spec/sky_conditions_spec.rb +20 -0
  31. data/spec/spec_helper.rb +22 -0
  32. data/spec/temperature_range_spec.rb +27 -0
  33. data/spec/weathergenerator_spec.rb +63 -0
  34. data/spec/wind_spec.rb +8 -0
  35. data/todo.org +3 -2
  36. metadata +67 -80
  37. data.tar.gz.sig +0 -1
  38. data/.gemtest +0 -0
  39. data/test/rollers/avgroller.rb +0 -7
  40. data/test/rollers/riggedroller.rb +0 -11
  41. data/test/test_acceptance.rb +0 -36
  42. data/test/test_dieroller.rb +0 -30
  43. data/test/test_greyhawkweather.rb +0 -11
  44. data/test/test_helper.rb +0 -3
  45. data/test/test_month.rb +0 -36
  46. data/test/test_precipitation.rb +0 -26
  47. data/test/test_precipitation_occurance.rb +0 -93
  48. data/test/test_singledayweather.rb +0 -61
  49. data/test/test_sky_conditions.rb +0 -23
  50. data/test/test_temperature_range.rb +0 -30
  51. data/test/test_weather_generator.rb +0 -59
  52. data/test/test_wind.rb +0 -11
  53. metadata.gz.sig +0 -1
@@ -1,61 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'singledayweather'
4
- require 'month'
5
-
6
- require 'rollers/avgroller'
7
- require 'rollers/riggedroller'
8
-
9
- class TestWeather < Test::Unit::TestCase
10
- def test_temp_range_is_calcuated_by_appropriate_die_rolls
11
- assert_equal(5..24, SingleDayWeather.new(create_month, AvgRoller.new).temperature_range)
12
- end
13
-
14
- def test_determines_sky_conditions
15
- assert_equal(:partly_cloudy, SingleDayWeather.new(create_month, AvgRoller.new).sky_conditions)
16
- assert_equal(:clear, SingleDayWeather.new(create_month, RiggedRoller.new(14)).sky_conditions)
17
- end
18
-
19
- def test_determines_precipitation
20
- assert_equal("precip",
21
- SingleDayWeather.new(create_month, RiggedRoller.new(10),
22
- PrecipitationOccurance.new({ 0..100 => PrecipitationInfo.new("precip")})).
23
- precipitation[0].name)
24
- assert_equal(NullPrecipitationInfo.new().name,
25
- SingleDayWeather.new(create_month, RiggedRoller.new(70),
26
- PrecipitationOccurance.new({ 0..100 => PrecipitationInfo.new("precip")})).
27
- precipitation[0].name)
28
- end
29
-
30
- def test_deals_with_record_highs
31
- assert_equal(24..36, SingleDayWeather.new(create_month, RiggedRoller.new(1),
32
- PrecipitationOccurance.new(),
33
- :high).temperature_range)
34
- end
35
-
36
- def test_determines_wind
37
- assert_equal("9SE", SingleDayWeather.new(create_month, AvgRoller.new).wind.to_s)
38
- end
39
-
40
- def test_checks_for_temp_ranges_on_weather
41
- assert_equal(NullPrecipitationInfo.new().name,
42
- SingleDayWeather.new(create_month, RiggedRoller.new(10),
43
- PrecipitationOccurance.new({ 0..100 => PrecipitationInfo.create_from_data({ :name => "precip",
44
- :min_temp => 100})})).
45
- precipitation[0].name)
46
- end
47
-
48
- def test_checks_for_terrain_on_precipitation
49
- assert_equal(NullPrecipitationInfo.new().name,
50
- SingleDayWeather.new(create_month, RiggedRoller.new(10),
51
- PrecipitationOccurance.new({ 0..100 =>
52
- PrecipitationInfo.create_from_data({ :name => "precip",
53
- :not_allowed_in => [:desert]})}), nil, :desert).
54
- precipitation[0].name)
55
- end
56
-
57
- private
58
- def create_month
59
- Month.new(TemperatureRange.new(13, [10,6], [8,4]), SkyConditions.new((01..23), (24..50), (51..100)), 50)
60
- end
61
- end
@@ -1,23 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'rollers/riggedroller'
4
-
5
- require 'skyconditions'
6
-
7
- class TestSkyConditions < Test::Unit::TestCase
8
- def test_pick_from_ranges
9
- conditions = SkyConditions.new((01..23), (24..50), (51..100))
10
- assert_equal(:clear, conditions.condition(RiggedRoller.new(01)))
11
- assert_equal(:clear, conditions.condition(RiggedRoller.new(23)))
12
- assert_equal(:partly_cloudy, conditions.condition(RiggedRoller.new(24)))
13
- assert_equal(:partly_cloudy, conditions.condition(RiggedRoller.new(50)))
14
- assert_equal(:cloudy, conditions.condition(RiggedRoller.new(51)))
15
- assert_equal(:cloudy, conditions.condition(RiggedRoller.new(99)))
16
- assert_equal(:cloudy, conditions.condition(RiggedRoller.new(100)))
17
- end
18
-
19
- def test_zero_equals_hundred
20
- conditions = SkyConditions.new((01..23), (24..50), (51..100))
21
- assert_equal(:cloudy, conditions.condition(RiggedRoller.new(0)))
22
- end
23
- end
@@ -1,30 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'rollers/avgroller'
4
-
5
- require 'temperaturerange'
6
-
7
- class TestTemperaratureRange < Test::Unit::TestCase
8
- def test_uses_die_roller_for_range_construction
9
- temp = TemperatureRange.new(10, [8, 4], [10, 4])
10
- assert_equal((1..18), temp.range(AvgRoller.new))
11
- end
12
-
13
- def test_handles_record_high
14
- temp = TemperatureRange.new(10, [8, 2], [8, 2])
15
- assert_equal(14..26, temp.range(AvgRoller.new, :high))
16
- assert_equal(24..36, temp.range(AvgRoller.new, [:high,:high]))
17
- end
18
-
19
- def test_handles_record_low
20
- temp = TemperatureRange.new(10, [8, 2], [8, 2])
21
- assert_equal(-6..6, temp.range(AvgRoller.new, :low))
22
- assert_equal(-16..-4, temp.range(AvgRoller.new, [:low,:low]))
23
- end
24
-
25
- def test_handles_mix_of_records
26
- temp = TemperatureRange.new(10, [8, 2], [8, 2])
27
- assert_equal(4..16, temp.range(AvgRoller.new, [:high,:low]))
28
- assert_equal(14..26, temp.range(AvgRoller.new, [:high,:low,:high]))
29
- end
30
- end
@@ -1,59 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'WeatherGenerator'
4
- require 'BaselineData'
5
-
6
- require 'rollers/avgroller'
7
- require 'rollers/riggedroller'
8
-
9
- class TestBaselineData < BaselineData
10
- def initialize (all_data)
11
- @all_data = all_data
12
- end
13
- end
14
-
15
- class TestWeatherGenerator < Test::Unit::TestCase
16
- def setup
17
- @testbaseline = TestBaselineData.new [{ :temp_range => TemperatureRange.new(10, [4, 0], [4, 0]),
18
- :sky_conditions => { :clear => (0..0), :partly => (0..0), :cloudy => (0..0) },
19
- :precipitation_chance => 40 },
20
- { :temp_range => TemperatureRange.new(100, [4, 0], [4, 0]),
21
- :sky_conditions => { :clear => (0..0), :partly => (0..0), :cloudy => (0..0) },
22
- :precipitation_chance => 70 }]
23
- @testprecipchart = PrecipitationOccurance.new({ 0..25 => PrecipitationInfo.create_from_data({ :name => "Rain", :not_allowed_in => [:desert]}),
24
- 26..50 => PrecipitationInfo.create_from_data({ :name => "Snow"}),
25
- 51..75 => PrecipitationInfo.create_from_data({ :name => "Hail"}),
26
- 76..100 => PrecipitationInfo.create_from_data({ :name => "Smog"})})
27
- end
28
-
29
- def test_generator_creates_num_days_of_weather
30
- generator = WeatherGenerator.new @testbaseline, @testprecipchart, 1, 1, AvgRoller.new
31
- assert_equal(1, generator.days.length, "Should have only generated 1 day of weeather")
32
-
33
- generator = WeatherGenerator.new @testbaseline, @testprecipchart, 1, 13, AvgRoller.new
34
- assert_equal(13, generator.days.length, "Should have generated 13 day of weeather")
35
- end
36
-
37
- def test_generated_days_cross_month_boundaries
38
- generator = WeatherGenerator.new @testbaseline, @testprecipchart, 1, 31, RiggedRoller.new(1)
39
- unique_ranges = generator.days.collect{ |d| d.temperature_range}.uniq
40
- assert_equal(2, unique_ranges.length, "Not all ranges should be the same")
41
- assert_equal(28, generator.days.select{ |d| d.temperature_range.begin < 50 }.length, "should have 28 items from the first month")
42
- assert_equal(3, generator.days.select{ |d| d.temperature_range.begin > 50 }.length, "Should have 3 items from the first month")
43
- end
44
-
45
- def test_months_wrap_around_if_past_end_of_year
46
- generator = WeatherGenerator.new @testbaseline, @testprecipchart, 2, 29, RiggedRoller.new(1)
47
- assert_equal(true, generator.days.last.temperature_range.begin < 50, "Last one should be first month")
48
- end
49
-
50
- def test_checks_for_record_high_low
51
- generator = WeatherGenerator.new @testbaseline, @testprecipchart, 1, 1, RiggedRoller.new(1)
52
- assert_equal(-3..-1, generator.days.first.temperature_range, "Extreme record low")
53
- end
54
-
55
- def test_uses_terrain_for_precipitation_check
56
- generator = WeatherGenerator.new @testbaseline, @testprecipchart, 1, 1, RiggedRoller.new(1), :desert
57
- assert_equal(NullPrecipitationInfo.new.name, generator.days.first.precipitation.first.name)
58
- end
59
- end
data/test/test_wind.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'rollers/avgroller'
4
-
5
- require 'wind'
6
-
7
- class TestWind < Test::Unit::TestCase
8
- def test_default_wind_calculation
9
- assert_equal("9SE", Wind.new(AvgRoller.new).to_s)
10
- end
11
- end
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- p��_�s��<�����Ľ"\S�f�Ef�I