skiplan_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +26 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +79 -0
- data/Rakefile +1 -0
- data/data/lumi_response.xml +1485 -0
- data/lib/skiplan_client/version.rb +3 -0
- data/lib/skiplan_client/weather_object.rb +79 -0
- data/lib/skiplan_client.rb +32 -0
- data/skiplan_client.gemspec +27 -0
- data/test/skiplan_client/skiplan_client_test.rb +39 -0
- data/test/skiplan_client/weather_object_test.rb +25 -0
- metadata +142 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
class WeatherObject
|
2
|
+
|
3
|
+
attr_accessor :name,
|
4
|
+
:langue,
|
5
|
+
:date_heur_maj,
|
6
|
+
:zone_nom,
|
7
|
+
:zone_altitude,
|
8
|
+
:date_maj,
|
9
|
+
:reference_zone,
|
10
|
+
:rsq_reel,
|
11
|
+
:val_risque,
|
12
|
+
:lib_risque,
|
13
|
+
:temperature_mtn,
|
14
|
+
:temperature_apm,
|
15
|
+
:temperature_rst,
|
16
|
+
:neige,
|
17
|
+
:cumul,
|
18
|
+
:neige_horspiste,
|
19
|
+
:lib_qualite,
|
20
|
+
:id_qualite,
|
21
|
+
:id_qualitehorspiste,
|
22
|
+
:date_dern_neige,
|
23
|
+
:vitesse_vent,
|
24
|
+
:direction_vent,
|
25
|
+
:rafales_vent,
|
26
|
+
:visibilite,
|
27
|
+
:id_ciel_mtn,
|
28
|
+
:id_ciel_apm,
|
29
|
+
:indice_uv,
|
30
|
+
:risque_orage,
|
31
|
+
:commentaire,
|
32
|
+
:meteo_jour,
|
33
|
+
:meteo_lendemain,
|
34
|
+
:meteo_semaine,
|
35
|
+
:auj_ciel_id_matin,
|
36
|
+
:auj_ciel_id_apm,
|
37
|
+
:dem_ciel_id_matin,
|
38
|
+
:dem_ciel_id_apm
|
39
|
+
|
40
|
+
def initialize(attributes = {})
|
41
|
+
@nom = attributes[:name]
|
42
|
+
@langue = attributes[:langue]
|
43
|
+
@dateheur = attributes[:date_heur_maj]
|
44
|
+
@zonenom = attributes[:zone_nom]
|
45
|
+
@zonealtitude = attributes[:zone_altitude]
|
46
|
+
@datemaj = attributes[:date_maj]
|
47
|
+
@reference = attributes[:reference_zone]
|
48
|
+
@wrsqreel = attributes[:rsq_reel]
|
49
|
+
@valrisque = attributes[:val_risque]
|
50
|
+
@librisque = attributes[:lib_risque]
|
51
|
+
@temperaturemtn = attributes[:temperature_mtn]
|
52
|
+
@temperatureapm = attributes[:temperature_apm]
|
53
|
+
@temperaturerst = attributes[:temperature_rst]
|
54
|
+
@neige = attributes[:neige]
|
55
|
+
@cumul = attributes[:cumul]
|
56
|
+
@neigehorspiste = attributes[:neige_horspiste]
|
57
|
+
@libqualite = attributes[:lib_qualite]
|
58
|
+
@idqualite = attributes[:id_qualite]
|
59
|
+
@idqualitehorspiste = attributes[:id_qualitehorspiste]
|
60
|
+
@datelastsnow = attributes[:date_dern_neige]
|
61
|
+
@vitesse = attributes[:vitesse_vent]
|
62
|
+
@direction = attributes[:direction_vent]
|
63
|
+
@rafales = attributes[:rafales_vent]
|
64
|
+
@visibilite = attributes[:visibilite]
|
65
|
+
@id_ciel_mtn = attributes[:id_ciel_mtn]
|
66
|
+
@id_ciel_apm = attributes[:id_ciel_apm]
|
67
|
+
@indice_uv = attributes[:indice_uv]
|
68
|
+
@risque_orage = attributes[:risque_orage]
|
69
|
+
@commentaire = attributes[:commentaire]
|
70
|
+
@meteo_jour = attributes[:meteo_jour]
|
71
|
+
@meteo_lendemain = attributes[:meteo_lendemain]
|
72
|
+
@meteo_semaine = attributes[:meteo_semaine]
|
73
|
+
@auj_ciel_id_matin = attributes[:auj_ciel_id_matin]
|
74
|
+
@auj_ciel_id_apm = attributes[:auj_ciel_id_apm]
|
75
|
+
@dem_ciel_id_matin = attributes[:dem_ciel_id_matin]
|
76
|
+
@dem_ciel_id_apm = attributes[:dem_ciel_id_apm]
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'skiplan_client/version'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
module SkiplanClient
|
6
|
+
|
7
|
+
# Configuration defaults
|
8
|
+
@config = {
|
9
|
+
:base_url => 'http://www.skiplan.com/php/genererXml.php?pays=france®ion=alpes& station=legrandbornand&v=1'
|
10
|
+
}
|
11
|
+
|
12
|
+
def self.configure(url)
|
13
|
+
@config[:base_url] = url
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.get_weather
|
17
|
+
@info = []
|
18
|
+
|
19
|
+
xml = Nokogiri::XML(open(@config[:base_url]))
|
20
|
+
|
21
|
+
ciel_id_auj_mat = xml.xpath('//ZONE[@nom="CHINAILLON"]/CIEL_ID').text
|
22
|
+
ciel_id_auj_apm = xml.xpath('//ZONE[@nom="CHINAILLON"]/CIEL_ID_APM').text
|
23
|
+
ciel_id_dem_mat = xml.xpath('//ZONE[@nom="J+1"]/CIEL_ID').text
|
24
|
+
ciel_id_dem_apm = xml.xpath('//ZONE[@nom="J+1"]/CIEL_ID_APM').text
|
25
|
+
|
26
|
+
@info = WeatherObject.new(:auj_ciel_id_matin => ciel_id_auj_mat,
|
27
|
+
:auj_ciel_id_apm => ciel_id_auj_apm,
|
28
|
+
:dem_ciel_id_matin => ciel_id_dem_mat,
|
29
|
+
:dem_ciel_id_apm => ciel_id_dem_apm)
|
30
|
+
@info
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'skiplan_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "skiplan_client"
|
8
|
+
spec.version = SkiplanClient::VERSION
|
9
|
+
spec.authors = ["SimonRonzani"]
|
10
|
+
spec.email = ["ronzani.simon@gmail.com"]
|
11
|
+
spec.description = "SkiPlan API client gem"
|
12
|
+
spec.summary = "A simple Ruby wrapper for the SkiPlan XML api"
|
13
|
+
spec.homepage = "https://github.com/jeanbaptistevilain/skiplan_client"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.0"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "test-unit"
|
24
|
+
spec.add_development_dependency "shoulda"
|
25
|
+
spec.add_runtime_dependency "rails", "~> 3.2.14"
|
26
|
+
spec.add_runtime_dependency "nokogiri"
|
27
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding : UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
gem 'shoulda'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'shoulda'
|
6
|
+
require 'skiplan_client'
|
7
|
+
require 'skiplan_client/weather_object'
|
8
|
+
|
9
|
+
class SkiplanClientTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
should 'test nokogiri open and xpath text function' do
|
12
|
+
|
13
|
+
xml = Nokogiri::XML(open('http://api.openweathermap.org/data/2.5/forecast/daily?q=tokyo&mode=xml&units=metric&cnt=1'))
|
14
|
+
city = xml.xpath('//name').text
|
15
|
+
country = xml.xpath('//country').text
|
16
|
+
|
17
|
+
assert_equal 'Tokyo', city
|
18
|
+
assert_equal 'JP', country
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
should 'test get_weather founction' do
|
23
|
+
|
24
|
+
weather = SkiplanClient.get_weather
|
25
|
+
|
26
|
+
assert_equal '101' , weather.auj_ciel_id_matin
|
27
|
+
assert_equal '101' , weather.auj_ciel_id_apm
|
28
|
+
assert_equal '104' , weather.dem_ciel_id_matin
|
29
|
+
assert_equal '106' , weather.dem_ciel_id_apm
|
30
|
+
end
|
31
|
+
|
32
|
+
should 'change config url' do
|
33
|
+
|
34
|
+
config = SkiplanClient.configure('http://api.openweathermap.org/data/2.5/forecast/daily?q=tokyo&mode=xml&units=metric&cnt=1')
|
35
|
+
|
36
|
+
assert_equal 'http://api.openweathermap.org/data/2.5/forecast/daily?q=tokyo&mode=xml&units=metric&cnt=1', config
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding : UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
gem 'shoulda'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'shoulda'
|
6
|
+
require 'skiplan_client/weather_object'
|
7
|
+
|
8
|
+
class WeatherObjectTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
should 'test information completed' do
|
11
|
+
@weather_object = []
|
12
|
+
hash_result = {:auj_ciel_id_matin => 'id_ciel_test1',
|
13
|
+
:auj_ciel_id_apm => 'id_ciel_test2',
|
14
|
+
:dem_ciel_id_matin => 'id_ciel_test3',
|
15
|
+
:dem_ciel_id_apm => 'id_ciel_test4'}
|
16
|
+
|
17
|
+
@weather_object = WeatherObject.new(hash_result)
|
18
|
+
|
19
|
+
assert_equal 'id_ciel_test1', @weather_object.auj_ciel_id_matin
|
20
|
+
assert_equal 'id_ciel_test2', @weather_object.auj_ciel_id_apm
|
21
|
+
assert_equal 'id_ciel_test3', @weather_object.dem_ciel_id_matin
|
22
|
+
assert_equal 'id_ciel_test4', @weather_object.dem_ciel_id_apm
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skiplan_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SimonRonzani
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: shoulda
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.2.14
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.2.14
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: SkiPlan API client gem
|
98
|
+
email:
|
99
|
+
- ronzani.simon@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- data/lumi_response.xml
|
110
|
+
- lib/skiplan_client.rb
|
111
|
+
- lib/skiplan_client/version.rb
|
112
|
+
- lib/skiplan_client/weather_object.rb
|
113
|
+
- skiplan_client.gemspec
|
114
|
+
- test/skiplan_client/skiplan_client_test.rb
|
115
|
+
- test/skiplan_client/weather_object_test.rb
|
116
|
+
homepage: https://github.com/jeanbaptistevilain/skiplan_client
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.3.0
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: A simple Ruby wrapper for the SkiPlan XML api
|
140
|
+
test_files:
|
141
|
+
- test/skiplan_client/skiplan_client_test.rb
|
142
|
+
- test/skiplan_client/weather_object_test.rb
|