everlog 0.0.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.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/Guardfile +8 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +29 -0
  8. data/Rakefile +1 -0
  9. data/everlog.gemspec +33 -0
  10. data/lib/everlog.rb +42 -0
  11. data/lib/everlog/app.rb +15 -0
  12. data/lib/everlog/app/animetick.rb +14 -0
  13. data/lib/everlog/app/evernote.rb +9 -0
  14. data/lib/everlog/app/github.rb +9 -0
  15. data/lib/everlog/app/hatena.rb +13 -0
  16. data/lib/everlog/app/moves.rb +9 -0
  17. data/lib/everlog/app/twitter.rb +11 -0
  18. data/lib/everlog/app/weather.rb +9 -0
  19. data/lib/everlog/dom.rb +9 -0
  20. data/lib/everlog/dom/entity.rb +11 -0
  21. data/lib/everlog/dom/entity/config.rb +30 -0
  22. data/lib/everlog/dom/entity/content.erb +170 -0
  23. data/lib/everlog/dom/entity/content.rb +14 -0
  24. data/lib/everlog/dom/module.rb +6 -0
  25. data/lib/everlog/dom/module/github.rb +28 -0
  26. data/lib/everlog/dom/module/moves.rb +26 -0
  27. data/lib/everlog/dom/repository.rb +5 -0
  28. data/lib/everlog/dom/repository/evernote.rb +24 -0
  29. data/lib/everlog/dom/service.rb +5 -0
  30. data/lib/everlog/dom/service/nullobject.rb +18 -0
  31. data/lib/everlog/dom/value.rb +18 -0
  32. data/lib/everlog/dom/value/animetick.rb +25 -0
  33. data/lib/everlog/dom/value/github.rb +6 -0
  34. data/lib/everlog/dom/value/github/activity.rb +18 -0
  35. data/lib/everlog/dom/value/github/commit.rb +13 -0
  36. data/lib/everlog/dom/value/hatena.rb +20 -0
  37. data/lib/everlog/dom/value/moves.rb +16 -0
  38. data/lib/everlog/dom/value/moves/move.rb +31 -0
  39. data/lib/everlog/dom/value/moves/place.rb +13 -0
  40. data/lib/everlog/dom/value/moves/referer.rb +10 -0
  41. data/lib/everlog/dom/value/moves/referer/move.rb +7 -0
  42. data/lib/everlog/dom/value/moves/referer/place.rb +8 -0
  43. data/lib/everlog/dom/value/moves/summary.rb +30 -0
  44. data/lib/everlog/dom/value/twitter.rb +13 -0
  45. data/lib/everlog/dom/value/weather.rb +31 -0
  46. data/lib/everlog/inf.rb +5 -0
  47. data/lib/everlog/inf/api.rb +20 -0
  48. data/lib/everlog/inf/api/animetick.rb +25 -0
  49. data/lib/everlog/inf/api/evernote.rb +37 -0
  50. data/lib/everlog/inf/api/github.rb +26 -0
  51. data/lib/everlog/inf/api/googlemap.rb +15 -0
  52. data/lib/everlog/inf/api/hatena.rb +20 -0
  53. data/lib/everlog/inf/api/moves.rb +21 -0
  54. data/lib/everlog/inf/api/twitter.rb +26 -0
  55. data/lib/everlog/inf/api/wunderground.rb +15 -0
  56. data/lib/everlog/version.rb +3 -0
  57. data/spec/fixtures/animetick/list_ticket_response.json +1 -0
  58. data/spec/fixtures/hatena/feed_response.json +80 -0
  59. data/spec/fixtures/moves/daily_storyline_response.json +319 -0
  60. data/spec/fixtures/moves/daily_summary_response.json +29 -0
  61. data/spec/fixtures/moves/sample_for_erb.json +29 -0
  62. data/spec/fixtures/wunderground/yesterday_response.json +1 -0
  63. data/spec/lifelog/app/animetick_spec.rb +13 -0
  64. data/spec/lifelog/app/evernote_spec.rb +14 -0
  65. data/spec/lifelog/app/github_spec.rb +22 -0
  66. data/spec/lifelog/app/hatena_spec.rb +35 -0
  67. data/spec/lifelog/app/moves_spec.rb +9 -0
  68. data/spec/lifelog/app/twitter_spec.rb +33 -0
  69. data/spec/lifelog/app/weather_spec.rb +11 -0
  70. data/spec/lifelog/dom/entity/config_spec.rb +22 -0
  71. data/spec/lifelog/dom/entity/content_spec.rb +23 -0
  72. data/spec/lifelog/dom/module/github_spec.rb +60 -0
  73. data/spec/lifelog/dom/module/moves_spec.rb +37 -0
  74. data/spec/lifelog/dom/repository/evernote_spec.rb +26 -0
  75. data/spec/lifelog/dom/service/nullobject_spec.rb +19 -0
  76. data/spec/lifelog/dom/value/animetick_spec.rb +49 -0
  77. data/spec/lifelog/dom/value/github/activity_spec.rb +25 -0
  78. data/spec/lifelog/dom/value/github/commit_spec.rb +23 -0
  79. data/spec/lifelog/dom/value/hatena_spec.rb +23 -0
  80. data/spec/lifelog/dom/value/moves/move_spec.rb +45 -0
  81. data/spec/lifelog/dom/value/moves/place_spec.rb +18 -0
  82. data/spec/lifelog/dom/value/moves/referer/move_spec.rb +18 -0
  83. data/spec/lifelog/dom/value/moves/referer/place_spec.rb +17 -0
  84. data/spec/lifelog/dom/value/moves/summary_spec.rb +64 -0
  85. data/spec/lifelog/dom/value/twitter_spec.rb +23 -0
  86. data/spec/lifelog/dom/value/weather_spec.rb +43 -0
  87. data/spec/lifelog/inf/api/animetick_spec.rb +22 -0
  88. data/spec/lifelog/inf/api/evernote_spec.rb +49 -0
  89. data/spec/lifelog/inf/api/github_spec.rb +36 -0
  90. data/spec/lifelog/inf/api/googlemap_spec.rb +9 -0
  91. data/spec/lifelog/inf/api/hatena_spec.rb +23 -0
  92. data/spec/lifelog/inf/api/moves_spec.rb +13 -0
  93. data/spec/lifelog/inf/api/twitter_spec.rb +23 -0
  94. data/spec/lifelog/inf/api/wunderground_spec.rb +11 -0
  95. data/spec/spec_helper.rb +8 -0
  96. metadata +345 -0
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Github::Repository_Activity do
4
+ let(:instance) { described_class.new(repo_name, repo_commits) }
5
+
6
+ describe '#repo_name' do
7
+ context 'nil' do
8
+ let(:repo_name) { nil }
9
+ let(:repo_commits) { nil }
10
+ subject { instance.repo_name }
11
+
12
+ it { expect(subject).to eq '' }
13
+ end
14
+ end
15
+
16
+ describe '#commits' do
17
+ context 'nil' do
18
+ let(:repo_name) { nil }
19
+ let(:repo_commits) { nil }
20
+ subject { instance.commits }
21
+
22
+ it { expect(subject).to eq [] }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Github::Commit do
4
+ let(:instance) { described_class.new(response) }
5
+
6
+ describe '#url' do
7
+ subject { instance.url }
8
+
9
+ context 'nil' do
10
+ let(:response) { double('response', rels: { html: double('href', href: nil) }) }
11
+ it { expect(subject).to eq '' }
12
+ end
13
+ end
14
+
15
+ describe '#message' do
16
+ subject { instance.message }
17
+
18
+ context 'nil' do
19
+ let(:response) { double('response', commit: { message: nil }) }
20
+ it { expect(subject).to eq '' }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Hatena do
4
+ let(:instance) { described_class.new(response) }
5
+
6
+ describe '#title' do
7
+ subject { instance.title }
8
+
9
+ context 'with no title in response' do
10
+ let(:response) { {} }
11
+ it { expect(subject).to eq '' }
12
+ end
13
+ end
14
+
15
+ describe '#issued' do
16
+ subject { instance.issued }
17
+
18
+ context 'with no issued in response' do
19
+ let(:response) { {} }
20
+ it { expect(subject).to be_instance_of Time }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Moves::Move do
4
+ let(:instance) { described_class.new(response) }
5
+ let(:response) do
6
+ load_fixture('moves/daily_storyline_response.json').first['segments'][1]['activities'].first
7
+ end
8
+
9
+ describe '#action' do
10
+ subject { instance.action }
11
+ context 'normal case' do
12
+ it { expect(subject).to eq 'wlk' }
13
+ end
14
+ end
15
+
16
+ describe '#duration' do
17
+ subject { instance.duration }
18
+ context 'normal case' do
19
+ it 'round of' do
20
+ expect(subject).to eq '13.0'
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '#start_time' do
26
+ subject { instance.start_time }
27
+ context 'normal case' do
28
+ it { expect(subject).to eq '16:14' }
29
+ end
30
+ end
31
+
32
+ describe '#end_time' do
33
+ subject { instance.end_time }
34
+ context 'normal case' do
35
+ it { expect(subject).to eq '16:27' }
36
+ end
37
+ end
38
+
39
+ describe '#distance' do
40
+ subject { instance.distance }
41
+ context 'normal case' do
42
+ it { expect(subject).to be 1.251 }
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Moves::Place do
4
+ let(:instance) { described_class.new(response) }
5
+ let(:response) do
6
+ load_fixture('moves/daily_storyline_response.json').first['segments'][0]
7
+ end
8
+
9
+ describe '#latitude' do
10
+ subject { instance.latitude }
11
+ it { expect(subject).to eq '55.55555' }
12
+ end
13
+
14
+ describe '#longitude' do
15
+ subject { instance.longitude }
16
+ it { expect(subject).to eq '33.33333' }
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Moves::Referer::Move do
4
+ let(:instance) { described_class.new(response) }
5
+ let(:response) do
6
+ load_fixture('moves/daily_storyline_response.json').first['segments'][1]
7
+ end
8
+
9
+ describe '#name' do
10
+ it { expect(instance.name).to eq 'move' }
11
+ end
12
+
13
+ describe '#to_a' do
14
+ subject { instance.to_a }
15
+ it { expect(subject).to be_instance_of Array }
16
+ it { expect(subject.first.action).to eq 'wlk' }
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Moves::Referer::Place do
4
+ let(:instance) { described_class.new(response) }
5
+ let(:response) do
6
+ load_fixture('moves/daily_storyline_response.json').first['segments'][0]
7
+ end
8
+
9
+ describe '#name' do
10
+ it { expect(instance.name).to eq 'place' }
11
+ end
12
+
13
+ describe '#screen_name' do
14
+ subject { instance.screen_name }
15
+ it { expect(subject).to eq "O18, スモレンスク ロシア" }
16
+ end
17
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Moves::Summary do
4
+ let(:instance) { described_class.new(response) }
5
+
6
+ shared_examples_for 'return fixture val with normal case and return 0.0 with abnormal case' do
7
+ context 'normal' do
8
+ let(:response) { load_fixture('moves/daily_summary_response.json').first['summary'] }
9
+ it { expect(subject).to be fixture_val }
10
+ end
11
+
12
+ context 'abnormal' do
13
+ context 'with no applied activity' do
14
+ let(:response) do
15
+ r = load_fixture('moves/daily_summary_response.json').first['summary']
16
+ r.delete_at(fixture_index)
17
+ r
18
+ end
19
+
20
+ it { expect(subject).to be 0.0 }
21
+ end
22
+
23
+ context 'with response nil' do
24
+ let(:response) { nil }
25
+ it { expect(subject).to be 0.0 }
26
+ end
27
+
28
+ context 'with response empty array' do
29
+ let(:response) { [] }
30
+ it { expect(subject).to be 0.0 }
31
+ end
32
+ end
33
+ end
34
+
35
+
36
+ describe '#walk' do
37
+ subject { instance.walk }
38
+ let(:fixture_index) { 0 }
39
+ let(:fixture_val) { 1.847 }
40
+ it_behaves_like 'return fixture val with normal case and return 0.0 with abnormal case'
41
+ end
42
+
43
+ describe '#cycle' do
44
+ subject { instance.cycle }
45
+ let(:fixture_index) { 2 }
46
+ let(:fixture_val) { 4.049 }
47
+ it_behaves_like 'return fixture val with normal case and return 0.0 with abnormal case'
48
+ end
49
+
50
+ describe '#transport' do
51
+ subject { instance.transport }
52
+ let(:fixture_index) { 3 }
53
+ let(:fixture_val) { 0.419 }
54
+ it_behaves_like 'return fixture val with normal case and return 0.0 with abnormal case'
55
+ end
56
+
57
+ describe '#cal' do
58
+ subject { instance.cal }
59
+ let(:response) { load_fixture('moves/daily_summary_response.json').first['summary'] }
60
+ context 'normal' do
61
+ it { expect(subject).to be 1098 }
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Twitter do
4
+ let(:instance) { described_class.new(response) }
5
+
6
+ describe '#tweet' do
7
+ context 'with Twitter::Tweet nil' do
8
+ subject { instance.tweet }
9
+ let(:response) { double('Twitter::Tweet', text: nil) }
10
+
11
+ it { expect(subject).to eq '' }
12
+ end
13
+ end
14
+
15
+ describe '#created_at' do
16
+ context 'with Twitter::Tweet nil' do
17
+ subject { instance.created_at }
18
+ let(:response) { double('Twitter::Tweet', created_at: nil) }
19
+
20
+ it { expect(subject).to eq '' }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Dom::Value::Weather do
4
+ let(:valid_response) do
5
+ load_fixture('wunderground/yesterday_response.json')['history']
6
+ end
7
+
8
+ describe '#max_temp' do
9
+ context 'normal' do
10
+ subject { described_class.new(valid_response).max_temp }
11
+ it { expect(subject).to be 10 }
12
+ end
13
+
14
+ context 'abnormal' do
15
+ subject { described_class.new(nil).max_temp }
16
+ it { expect(subject).to be 0 }
17
+ end
18
+ end
19
+
20
+ describe '#max_temp' do
21
+ context 'normal' do
22
+ subject { described_class.new(valid_response).min_temp }
23
+ it { expect(subject).to be 7 }
24
+ end
25
+
26
+ context 'abnormal' do
27
+ subject { described_class.new(nil).max_temp }
28
+ it { expect(subject).to be 0 }
29
+ end
30
+ end
31
+
32
+ describe '#condition' do
33
+ context 'normal' do
34
+ subject { described_class.new(valid_response).condition }
35
+ it { expect(subject).to eq 'rain' }
36
+ end
37
+
38
+ context 'abnormal' do
39
+ subject { described_class.new(nil).condition }
40
+ it { expect(subject).to eq '' }
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Inf::Api::Animetick do
4
+ let(:instance) do
5
+ config = double('config', access_token: ENV['animetick_session'], access_secret: ENV['animetick_csrf_token'])
6
+ described_class.new(config)
7
+ end
8
+
9
+ describe '#client' do
10
+ it 'memo @client' do
11
+ expect(instance.client).to be instance.client
12
+ end
13
+ end
14
+
15
+ describe '#ticket_list' do
16
+ subject { instance.ticket_list }
17
+ it { expect(subject).to be_instance_of Array }
18
+ it { expect(subject.first).to have_key 'title' }
19
+ it { expect(subject.first).to have_key 'sub_title' }
20
+ it { expect(subject.first).to have_key 'updated_at' }
21
+ end
22
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Inf::Api::Evernote do
4
+ let(:instance) do
5
+ config = double('config', access_secret: ENV['evernote_sandbox_access_token'])
6
+ described_class.new(true, config)
7
+ end
8
+
9
+ describe '#client' do
10
+ subject { instance.client }
11
+ it 'memo @client' do
12
+ expect(subject).to be instance.client
13
+ end
14
+ end
15
+
16
+ describe '#note' do
17
+ it 'memo @note' do
18
+ expect(instance.note).to be instance.note
19
+ end
20
+ end
21
+
22
+ describe '#post_note' do
23
+ before { EvernoteOAuth::Client.any_instance.stub_chain(:note_store, :createNote) }
24
+ let(:content) do
25
+ <<EOS
26
+ <?xml version='1.0' encoding='UTF-8'?>
27
+ <!DOCTYPE en-note SYSTEM 'http://xml.evernote.com/pub/enml2.dtd'>
28
+ <en-note> <div>hi</div> <div>hello</div> </en-note>
29
+ EOS
30
+ end
31
+
32
+ it { expect { instance.post_note('title', content) }.not_to raise_error }
33
+ end
34
+
35
+ describe '#create_notebook' do
36
+ subject { instance.create_notebook(title) }
37
+
38
+ context 'duplicate notebook title' do
39
+ let(:title) { 'from rspec' }
40
+ it { expect { subject }.to raise_error ::Evernote::EDAM::Error::EDAMUserException }
41
+ end
42
+ end
43
+
44
+ describe '#notebooks' do
45
+ subject { instance.notebooks }
46
+
47
+ it { expect(subject).to be_instance_of Array }
48
+ end
49
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Inf::Api::Github do
4
+ let(:instance) do
5
+ described_class.new(double('config', access_secret: ENV['github_access_secret']))
6
+ end
7
+
8
+ describe '#client' do
9
+ it 'memo @client' do
10
+ expect(instance.client).to be instance.client
11
+ end
12
+ end
13
+
14
+ describe '#repos' do
15
+ subject { instance.repos }
16
+ it { expect(subject).to be_instance_of Array }
17
+ end
18
+
19
+ describe '#commits_on' do
20
+ subject { instance.commits_on(repo, date) }
21
+ let(:repo) { 'everlog' }
22
+
23
+ context 'with commit existing' do
24
+ let(:date) { '2014-01-17' }
25
+
26
+ it { expect(subject).to be_instance_of Array }
27
+ it { expect(subject.size).to be 2 }
28
+ end
29
+
30
+ context 'with no commit existing' do
31
+ let(:date) { '9999-09-09' }
32
+
33
+ it { expect(subject).to eq [] }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Inf::Api::GoogleMap do
4
+ let(:instance) { described_class.new }
5
+
6
+ describe '#initialize' do
7
+ it { expect { instance }.not_to raise_error }
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Everlog::Inf::Api::Hatena do
4
+ let(:instance) do
5
+ config = double('config',
6
+ consumer_key: ENV['hatena_consumer_key'],
7
+ consumer_secret: ENV['hatena_consumer_sec'],
8
+ access_token: ENV['hatena_access_token'],
9
+ access_secret: ENV['hatena_access_secret'])
10
+ described_class.new(config)
11
+ end
12
+
13
+ describe '#client' do
14
+ it 'memo @client' do
15
+ expect(instance.client).to be instance.client
16
+ end
17
+ end
18
+
19
+ describe '#feed_entry' do
20
+ subject { instance.feed_entry }
21
+ it { expect(subject).to be_instance_of Array }
22
+ end
23
+ end