everlog 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: 04a54d53fcd53d7266550b8650a6bc9aca875ed4
4
- data.tar.gz: 7fd648b9bf03dbdf7712d0eee5e745c20551b513
3
+ metadata.gz: 593aadef0699ed990c3a8169046423de22afe5d7
4
+ data.tar.gz: 4408157735df19b6e45ebe685e978abe84eb1533
5
5
  SHA512:
6
- metadata.gz: 6abcfcf65a2bb5953974c5dc0eea1dc9451d2ccc73f00ea1aa38e4883122fc3466ed8523f0ed1953335371f389c5671f6791e43b7587ff6f7863cd10444e094c
7
- data.tar.gz: 4a7c5046aa67496e8b7dbc23ee59bc74b671e2c654062a098c625f4f460224cb66055c56c327b39151bcd0d3a695d5ac9d9d66f488614892d176c673438cd2ec
6
+ metadata.gz: dc7ad61e373a7d3c6a59e20b3d4027dadc381f0c81ab675af5f5c4a7f11edf8d9b702036eec534495fa73fefc3ecb4c5fb34ff49d260b42256cd73429bffd269
7
+ data.tar.gz: d40da3484d3cd79be9056414fe72e6081ac483abca5876d15caf8a04b4353a56473785e774b3d560b63e72da3f532a32c152a6f3710e384b922cac732241a0e3
@@ -29,15 +29,10 @@ class Everlog
29
29
 
30
30
  private
31
31
  def setup_config(service, option)
32
- case service
33
- when :weather
34
- Config.wunderground.access_token = option[:access_token]
35
- else
36
- Config.send(service).consumer_key = option[:consumer_key]
37
- Config.send(service).consumer_secret = option[:consumer_secret]
38
- Config.send(service).access_token = option[:access_token]
39
- Config.send(service).access_secret = option[:access_secret]
40
- end
32
+ Config.send(service).consumer_key = option[:consumer_key]
33
+ Config.send(service).consumer_secret = option[:consumer_secret]
34
+ Config.send(service).access_token = option[:access_token]
35
+ Config.send(service).access_secret = option[:access_secret]
41
36
  end
42
37
  end
43
38
  end
@@ -1,6 +1,6 @@
1
1
  class Everlog
2
2
  class Dom::Entity::Config < Dom::Entity
3
- THIRD_PARTY = %w(evernote twitter hatena github moves animetick wunderground googlemap).freeze
3
+ THIRD_PARTY = %w(evernote twitter hatena github moves animetick weather googlemap).freeze
4
4
 
5
5
  THIRD_PARTY.each do |service|
6
6
  const_set service.capitalize, Class.new {
@@ -3,7 +3,7 @@
3
3
  <en-note>
4
4
 
5
5
  <table border="0" cellspacing="0" cellpadding="9">
6
- <% unless @weather.nil? || @weather.empty? %>
6
+ <% unless @weather.nil? %>
7
7
  <tr bgcolor="ffaa33">
8
8
  <td></td>
9
9
  <td><font size="+1" color="ffffff">Weather</font></td>
@@ -1,7 +1,7 @@
1
1
  class Everlog
2
2
  class Dom::Module::Weather < Dom::Module
3
3
  def self.fetch_since(date)
4
- config = Dom::Entity::Config.wunderground
4
+ config = Dom::Entity::Config.weather
5
5
  api_response = Inf::Api::Wunderground.new(config).yesterday('Tokyo')
6
6
  Dom::Value::Weather.new(api_response)
7
7
  end
@@ -3,13 +3,15 @@ class Everlog
3
3
  require 'wunderground'
4
4
 
5
5
  def client
6
- @client ||= Wunderground.new(@config.access_secret, throws_exceptions: true)
6
+ @client ||= ::Wunderground.new(@config.access_token, throws_exceptions: true)
7
7
  end
8
8
 
9
9
  def yesterday place
10
10
  client.yesterday_for(place)['history']
11
- rescue
12
- nil
11
+ rescue => e
12
+ raise InfrastructureWeatherError, "yesterday error / #{e.message}"
13
13
  end
14
+
15
+ class InfrastructureWeatherError < StandardError; end
14
16
  end
15
17
  end
@@ -1,3 +1,3 @@
1
1
  class Everlog
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -3,6 +3,11 @@ require 'spec_helper'
3
3
  describe Everlog::Dom::Module::Weather do
4
4
 
5
5
  describe '.fetch_since' do
6
+ before do
7
+ response = load_fixture('wunderground/yesterday_response.json')['response']
8
+ Everlog::Inf::Api::Wunderground.any_instance.should_receive(:yesterday).and_return(response)
9
+ end
10
+
6
11
  subject { described_class.fetch_since('dummy') }
7
12
  it { expect(subject.max_temp).to be_instance_of Fixnum }
8
13
  it { expect(subject.min_temp).to be_instance_of Fixnum }
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Everlog::Inf::Api::Wunderground do
4
4
  let(:instance) do
5
- described_class.new(double('config', access_secret: ENV['wunderground_token']))
5
+ described_class.new(double('config', access_token: ENV['wunderground_token']))
6
6
  end
7
7
 
8
8
  describe '#yesterday' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everlog
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
  - gong023