study_the_map 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a9b2d07fe10bc0882a29cc2018a3176d2fcb99f
4
- data.tar.gz: 2617dc07753de6e447cfff42e3b9f2a2cbe42b38
3
+ metadata.gz: 4f6d3dbdcf93b0843ac6fe8bbd2707c0b8a872eb
4
+ data.tar.gz: f3250d4616f7b588793054321950a7f3832f1760
5
5
  SHA512:
6
- metadata.gz: 7ed9c1ed9ef330d2c07efc7349a7519ef28a2cf210066d433bde37dc4105bbebc7cfd047a9f55957f0ca78c2ac1a6ee7a72f439b0bb4dd617115e6f4ae2d4524
7
- data.tar.gz: 030c82507f6d0f8e780696e09b517343057157da62755930cab926b3a01eaa78a5185ec3a248ae0879768fd537c1a18142d1c60ec7ecd4b0f7ed03c8f4c991fa
6
+ metadata.gz: 223dc091679cfa39ba3caafb17d292c635d2f3ee00445d2104c7fc6e3a4d3a96a76237f804adf170ffd3ffb9681140a3246de8429fe756d00fe922b3fc48143f
7
+ data.tar.gz: c9282db77bf3877df9d099b8d354c0e3ad4f0721e65ddfa448fb2d5f296ddb46a9cad4c1c91a204a4ffaf3571c56b4fd0c8974074eb6f702e5338688a3b5f998
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Run ./bin/study_the_map to start!
23
+ Check that it installed using require 'study_the_map'. Then you can run the app from irb with StudyTheMap::CLI.new.call or ./bin/study_the_map if you've downloaded the repo.
24
24
 
25
25
  ## Development
26
26
 
@@ -5,79 +5,118 @@ class SkiMaps
5
5
  attr_accessor :area_name, :area_info
6
6
 
7
7
  def initialize(area_name)
8
+
8
9
  @area_name = area_name
9
10
  area_doc = Nokogiri::XML(open("https://skimap.org/SkiAreas/view/#{LookupIDS.find_ski_area_id(area_name)}.xml"))
11
+
10
12
  @area_info = area_doc
11
13
  map_count = area_doc.search("skiMaps").attr('count').text
14
+
12
15
  puts "There are #{map_count} maps for this ski area."
16
+
13
17
  if map_count == "0"
18
+
14
19
  StudyTheMap::CLI.new.call
20
+
15
21
  elsif map_count == "1"
22
+
16
23
  self.pick_map(self.get_map_years.join)
24
+
17
25
  else
26
+
18
27
  puts "Please wait while we fetch the maps' years..."
19
28
  puts ""
29
+
20
30
  self.list_map_years
21
31
  map_years = self.get_map_years
32
+
22
33
  input = nil
34
+
23
35
  until map_years.include?(input)
24
36
  puts ""
25
37
  puts "Please pick a year that is listed."
26
38
  input = gets.strip
27
39
  end
40
+
28
41
  self.pick_map(input)
42
+
29
43
  end
30
44
  end
31
45
 
32
46
  def get_map_ids
47
+
33
48
  id_array = []
49
+
34
50
  @area_info.search("skiMaps skiMap").each do |map|
35
51
  id_array << map.attr('id')
36
52
  end
53
+
37
54
  id_array
55
+
38
56
  end
39
57
 
40
58
  def get_map_data
59
+
41
60
  map_data_array = []
61
+
42
62
  self.get_map_ids.each do |id|
43
63
  map_data_array << Nokogiri::XML(open("https://skimap.org/SkiMaps/view/#{id}.xml"))
44
64
  end
65
+
45
66
  map_data_array
67
+
46
68
  end
47
69
 
48
70
  def list_map_years
71
+
49
72
  self.get_map_data.each do |map|
50
73
  puts map.search("yearPublished").text
51
74
  end
75
+
52
76
  end
53
77
 
54
78
  def get_map_years
79
+
55
80
  map_years_array = []
81
+
56
82
  self.get_map_data.each do |map|
57
83
  map_years_array << map.search("yearPublished").text
58
84
  end
85
+
59
86
  map_years_array
87
+
60
88
  end
61
89
 
62
90
  def pick_map(year)
91
+
63
92
  map_data = self.get_map_data.detect do |map|
64
93
  map.search("yearPublished").text == year
65
94
  end
95
+
66
96
  begin
67
97
  url = map_data.search("render").attr('url').text
68
98
  rescue Exception
69
99
  url = map_data.search("unprocessed").attr('url').text
70
100
  end
101
+
71
102
  puts "Would you like to download the Map to your working directory or see it in your browser?"
72
103
  puts "Type 'browser', 'download', or 'exit'"
104
+
73
105
  input = gets.strip
106
+
74
107
  case input
75
- when "download"
108
+
109
+ when "download"
110
+
76
111
  exec "curl -O #{url}"
77
112
  puts "Enjoy your map!"
113
+
78
114
  when "browser"
115
+
79
116
  Launchy.open("#{url}")
80
117
  puts "Enjoy your map!"
118
+
81
119
  end
120
+
82
121
  end
83
122
  end
@@ -1,3 +1,3 @@
1
1
  module StudyTheMap
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: study_the_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bshap93
@@ -120,6 +120,7 @@ files:
120
120
  - lib/study_the_map/regions.rb
121
121
  - lib/study_the_map/ski_map.rb
122
122
  - lib/study_the_map/version.rb
123
+ - study_the_map-0.1.0.gem
123
124
  - study_the_map.gemspec
124
125
  homepage: https://github.com/bshap93/study_the_map
125
126
  licenses: