usno-transit 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a41783523cf4e3dca24b182e583ad002dd43b6b4
4
- data.tar.gz: 6383da1b4c395f565764aed3e748372edb34a867
3
+ metadata.gz: 346421780a3ff413dcfb2a47a47f4d021f4c2f74
4
+ data.tar.gz: a5816c9ec240e236b98cb57eeb158ad10c73b353
5
5
  SHA512:
6
- metadata.gz: 314e61f00a2385baccf0d863d57d2e514fea20ce434274bc4fff0672152e5fbc54f680a4c39fdea82362a209ab983a2bef5630d6e2a59c819d92687df3170dad
7
- data.tar.gz: 53491020edfc69097bbd37aa3830c092571cb90b254a037f72f0c755dfef8ab2b40781d6da6d6c29abb3bea8703b7a4f69cbaa1ac1ef0cbedda58684e41bf208
6
+ metadata.gz: e06209b065cfa2442e81082ba8f96bed140e61c44c7e159682c48fc41bb245970f6a44798ce3a6e5817274419a55a644602ead474f0a47c3c075daba58dbdcdc
7
+ data.tar.gz: ab125769ecf8a66f64e3716d755b55c32a9d40b6bad82bdaf705183adc918480ef675141e94a9be8c22866d517eeff34f811e232c2e6a1368e76758707d8340e
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Usno::Transit [![Code Climate](https://codeclimate.com/github/rthbound/usno-transit.png)](https://codeclimate.com/github/rthbound/usno-transit)[![Coverage Status](https://coveralls.io/repos/rthbound/usno-transit/badge.png)](https://coveralls.io/r/rthbound/usno-transit)
1
+ # Usno::Transit [![Code Climate](https://codeclimate.com/github/rthbound/usno-transit.png)](https://codeclimate.com/github/rthbound/usno-transit)[![Coverage Status](https://coveralls.io/repos/rthbound/usno-transit/badge.png)](https://coveralls.io/r/rthbound/usno-transit)[![Build Status](https://travis-ci.org/rthbound/usno-transit.png?branch=master)](https://travis-ci.org/rthbound/usno-transit)
2
2
 
3
3
  ## Installation
4
4
 
@@ -1,30 +1,34 @@
1
1
  require "pay_dirt"
2
2
  require_relative "transit/version"
3
+ require_relative "transit/states"
3
4
  require_relative "transit/us_request"
4
5
 
5
6
  module USNO
6
7
  module Transit
7
8
  BODIES = {
8
- "Sun" => 10, "Moon" => 11, "Mercury" => 1, "Venus" => 2,"Jupiter" => 5,
9
- "Mars" => 4, "Saturn" => 6, "Uranus" => 7, "Neptune" => 8, "Pluto" => 9,
10
- "Achernar" => -1, "Adhara" => -2, "Aldebaran" => -3, "Altair" => -4,
11
- "Antares" => -5, "Arcturus" => -6, "Betelgeuse" => -7, "Canopus" => -8,
12
- "Capella" => -9, "Deneb" => -10, "Fomalhaut" => -11, "Hadar" => -12,
13
- "Mimosa" => -13, "Polaris" => -14, "Pollux" => -15, "Procyon" => -16,
14
- "Regulus" => -17, "Rigel" => -18, "RigilKentaurus" => -19, "Vega" => -22,
15
- "Sirius" => -20, "Spica" => -21,
9
+ "Sun" => 10, "Moon" => 11, "Mercury" => 1,
10
+ "Venus" => 2,"Jupiter" => 5, "Mars" => 4,
11
+ "Saturn" => 6, "Uranus" => 7, "Neptune" => 8,
12
+ "Pluto" => 9, "Achernar" => -1, "Adhara" => -2,
13
+ "Aldebaran" => -3, "Altair" => -4, "Antares" => -5,
14
+ "Arcturus" => -6, "Betelgeuse" => -7, "Canopus" => -8,
15
+ "Capella" => -9, "Deneb" => -10, "Fomalhaut" => -11,
16
+ "Hadar" => -12, "Mimosa" => -13, "Polaris" => -14,
17
+ "Pollux" => -15, "Procyon" => -16, "Regulus" => -17,
18
+ "Rigel" => -18, "RigilKentaurus" => -19, "Vega" => -22,
19
+ "Sirius" => -20, "Spica" => -21,
16
20
  }
17
21
 
18
22
  class View < PayDirt::Base
19
23
  def initialize(options = {})
24
+ raise "Cannot instantiate this class directly" if self.class.name == "View"
25
+
26
+ # Default options
20
27
  options = {
21
28
  request_class: USNO::Transit::USRequest,
22
29
  object: USNO::Transit::BODIES.fetch(self.class.name.split("::")[-1]) {
23
30
  raise "Celestial object not recognized"
24
31
  },
25
- state: "Alabama",#USNO::Transit::STATES.fetch(options[:state]) {
26
- #raise "US state not recognized"
27
- #},
28
32
  z_meters: 0,
29
33
  date: Time.now,
30
34
  days: 5,
@@ -37,12 +41,11 @@ module USNO
37
41
  result(true, @request_class.new({
38
42
  obj: @object,
39
43
  city: @city,
40
- state: @state,
44
+ state: USNO::Transit::States.by_key_or_value(@state),
41
45
  z_meters: @z_meters,
42
46
  date: @date,
43
47
  days: @days
44
48
  }).call.data)
45
-
46
49
  end
47
50
  end
48
51
 
@@ -0,0 +1,34 @@
1
+ module USNO
2
+ module Transit
3
+ module States
4
+ def self.states
5
+ {
6
+ "Alabama" => "AL", "Alaska" => "AK", "American Samoa" => "AS",
7
+ "Arizona" => "AZ", "Arkansas" => "AR", "California" => "CA",
8
+ "Colorado" => "CO", "Connecticut" => "CT", "Delaware" => "DE",
9
+ "District of Columbia" => "DC", "Florida" => "FL", "Georgia" => "GA",
10
+ "Guam" => "GU", "Hawaii" => "HI", "Idaho" => "ID",
11
+ "Indiana" => "IN", "Iowa" => "IA", "Kansas" => "KS",
12
+ "Kentucky" => "KY", "Louisiana" => "LA", "Maine" => "ME",
13
+ "Maryland" => "MD", "Massachusetts" => "MA", "Michigan" => "MI",
14
+ "Minnesota" => "MN", "Mississippi" => "MS", "Missouri" => "MO",
15
+ "Montana" => "MT", "Nebraska" => "NE", "Nevada" => "NV",
16
+ "New Hampshire" => "NH", "New Jersey" => "NJ", "New Mexico" => "NM",
17
+ "New York" => "NY", "North Carolina" => "NC", "North Dakota" => "ND",
18
+ "N. Mariana Islands" => "MP", "Ohio" => "OH", "Oklahoma" => "OK",
19
+ "Oregon" => "OR", "Pennsylvania" => "PA", "Puerto Rico" => "PR",
20
+ "Rhode Island" => "RI", "South Carolina" => "SC", "South Dakota" => "SD",
21
+ "Tennessee" => "TN", "Texas" => "TX", "Utah" => "UT",
22
+ "Vermont" => "VT", "Virgin Islands" => "VI", "Virginia" => "VA",
23
+ "Washington" => "WA", "West Virginia" => "WV", "Wisconsin" => "WI",
24
+ "Wyoming" => "WY", "Illinois" => "IL"
25
+ }
26
+ end
27
+
28
+ def self.by_key_or_value(kv)
29
+ states.has_value? kv and return kv
30
+ states.fetch(kv) { raise "USNO State not recognized" }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  module Usno
2
2
  module Transit
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -0,0 +1,7 @@
1
+ require "test_helper"
2
+
3
+ describe USNO::Transit::View do
4
+ it "cannot be instantiated directly" do
5
+ -> { USNO::Transit::View.new }.must_raise RuntimeError
6
+ end
7
+ end
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
16
16
  }
17
17
  spec.homepage = "http://github.com/rthbound/usno-transit"
18
18
  spec.license = "MIT"
19
-
20
19
  spec.files = `git ls-files`.split($/)
21
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
@@ -26,6 +25,5 @@ Gem::Specification.new do |spec|
26
25
  spec.add_development_dependency "minitest"
27
26
  spec.add_development_dependency "coveralls"
28
27
  spec.add_development_dependency "rake"
29
- spec.add_development_dependency "pry"
30
- spec.add_runtime_dependency "pay_dirt"
28
+ spec.add_runtime_dependency "pay_dirt"
31
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usno-transit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan T. Hosford
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: pay_dirt
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -109,12 +95,12 @@ files:
109
95
  - README.md
110
96
  - Rakefile
111
97
  - lib/usno/transit.rb
112
- - lib/usno/transit/client.rb
98
+ - lib/usno/transit/states.rb
113
99
  - lib/usno/transit/us_request.rb
114
- - lib/usno/transit/vega.rb
115
100
  - lib/usno/transit/version.rb
116
101
  - test/test_helper.rb
117
102
  - test/unit/usno/transit/us_request_test.rb
103
+ - test/unit/usno/transit/view_test.rb
118
104
  - usno-transit.gemspec
119
105
  homepage: http://github.com/rthbound/usno-transit
120
106
  licenses:
@@ -144,3 +130,4 @@ summary: Consumes USNO resources to return times of rise, set, and transit for t
144
130
  test_files:
145
131
  - test/test_helper.rb
146
132
  - test/unit/usno/transit/us_request_test.rb
133
+ - test/unit/usno/transit/view_test.rb
@@ -1,12 +0,0 @@
1
- module USNO
2
- module Transit
3
- class Client
4
- attr_accessor :konstants
5
-
6
- def initialize
7
- @konstants = []
8
- USNO::Transit::BODIES.each { |k,v| @konstants << instance_eval("class #{k}; def initialize() #{v} end; end") }
9
- end
10
- end
11
- end
12
- end
@@ -1,6 +0,0 @@
1
- module USNO
2
- module Transit
3
- class Vega < View
4
- end
5
- end
6
- end