envryo 0.0.1 → 0.0.2

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: cd7fd737740fa7c49475e357c0a46450c7af14d1
4
- data.tar.gz: 6a254096cdaf23e8d2b7623df690d9fcc6a8df3a
3
+ metadata.gz: e1f6902b8d6737b78e6736a3569995ba230db76e
4
+ data.tar.gz: 6c6178aa97fdefbe30e48f0ccb5286470bdcbbc4
5
5
  SHA512:
6
- metadata.gz: ffb3f2dd782aa70f890fb68e5f2a0a324a31f4a171a87da599bd09e118fad7a9cfd14ea6f9b62bebb0f4cfc7efeee56225b854f082c452722d050508cdd0cd2a
7
- data.tar.gz: ddc77fc02f29de5f7affcd4ce1df98ff46e8ba2a0f897b3864c4975ecb4a53d196510d359bfa738aafbfb293062fb01b168c9151b8d8828ff47c8a84fb18c40d
6
+ metadata.gz: 98773f8b50060898bdbabbf40632240052ad6a9b6f40c57be15c8145848b9e685c09b5421c3e1499a168f7e76f6258719e026d394732f329d0fea7e54951b77b
7
+ data.tar.gz: 680940af027d2b9ecbf65f25d5290923927248daad1807474cf93b1e702fa80186406c1ffb010cd3172b35c1053cc7d79c821d4a715bf48b3317536224f8e9a0
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Envryo
2
2
 
3
- Evernote various notifier via Yo.
3
+ [![Gem Version](https://img.shields.io/gem/v/envryo.svg)](http://badge.fury.io/rb/envryo)
4
+ [![Code Climate](https://img.shields.io/codeclimate/github/meganemura/envryo.svg)](https://codeclimate.com/github/meganemura/envryo)
5
+ [![Dependency Status](https://gemnasium.com/meganemura/envryo.svg)](https://gemnasium.com/meganemura/envryo)
6
+
7
+ Evernote various events notifier via Yo.
4
8
 
5
9
  ## Usage
6
10
 
@@ -8,17 +12,21 @@ Evernote various notifier via Yo.
8
12
 
9
13
  `envryo --config=config.yml`
10
14
 
11
- 2. Update evernote note
15
+ 2. Update evernote note which is tagged as `notify` (configurable)
12
16
 
13
- 3. Envryo yo to you or all
17
+ 3. Envryo sends yo to you or all subscribers
14
18
 
15
19
  ## Configuration (config.yml)
16
20
 
17
21
  ```yaml
18
- evernote_token: "Your evernote token"
19
- yo_api_key: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
20
- yo_user: "Yo username" # Set null to yo all
21
- interval: 300 # polling interval
22
+ evernote_token: "Your evernote authentication token"
23
+ evernote_filter: "tag:notify" # Search filter
24
+ # https://dev.evernote.com/doc/articles/search_grammar.php
25
+
26
+ yo_api_key: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
27
+ yo_user: "Yo username" # Send Yo to (set null to send Yo to all subscribers)
28
+
29
+ interval: 900 # polling interval
22
30
  ```
23
31
 
24
32
  ## Installation
@@ -1,4 +1,8 @@
1
- evernote_token: "Your evernote token"
2
- yo_api_key: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
3
- yo_user: "Yo username" # Set null to yo all
4
- interval: 300 # polling interval
1
+ evernote_token: "Your evernote authentication token"
2
+ evernote_filter: "tag:notify" # Search filter
3
+ # https://dev.evernote.com/doc/articles/search_grammar.php
4
+
5
+ yo_api_key: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
6
+ yo_user: "Yo username" # Send Yo to (set null to send Yo to all subscribers)
7
+
8
+ interval: 900 # polling interval
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Envryo::VERSION
9
9
  spec.authors = ["meganemura"]
10
10
  spec.email = ["mura2megane@gmail.com"]
11
- spec.summary = %q{Evernote various notifier via Yo.}
11
+ spec.summary = %q{Evernote various events notifier via Yo.}
12
12
  spec.description = spec.description
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
@@ -8,6 +8,17 @@ module Envryo
8
8
  def initialize(config = {})
9
9
  evernote = EvernoteOAuth::Client.new(:token => config[:evernote_token])
10
10
  @note_store = evernote.note_store
11
+ if config[:evernote_filter]
12
+ @filter = Evernote::EDAM::NoteStore::NoteFilter.new.tap do |filter|
13
+ filter.words = config[:evernote_filter]
14
+ filter.order = Evernote::EDAM::Type::NoteSortOrder::UPDATE_SEQUENCE_NUMBER
15
+ filter.ascending = false
16
+ end
17
+
18
+ @result_spec = Evernote::EDAM::NoteStore::NotesMetadataResultSpec.new.tap do |spec|
19
+ spec.includeUpdateSequenceNum = true
20
+ end
21
+ end
11
22
 
12
23
  @yo = Yoyo::Yo.new(config[:yo_api_key])
13
24
  @yo_user = config[:yo_user]
@@ -19,7 +30,9 @@ module Envryo
19
30
  setup
20
31
 
21
32
  loop do
22
- notify if updated?
33
+ if updated? && detect_event?
34
+ notify
35
+ end
23
36
  sleep @interval
24
37
  end
25
38
  end
@@ -31,9 +44,16 @@ module Envryo
31
44
  end
32
45
 
33
46
  def updated?
34
- old_count, @update_count = @update_count, current_state.updateCount
47
+ @latest_count, @update_count = @update_count, current_state.updateCount
48
+
49
+ @latest_count != @update_count
50
+ end
51
+
52
+ def detect_event?
53
+ return true unless @filter
35
54
 
36
- old_count != @update_count
55
+ metadata = @note_store.findNotesMetadata(@filter, 0, 1, @result_spec)
56
+ metadata.notes.any? {|note| note.updateSequenceNum > @latest_count }
37
57
  end
38
58
 
39
59
  def notify
@@ -1,3 +1,3 @@
1
1
  module Envryo
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envryo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - meganemura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-02 00:00:00.000000000 Z
11
+ date: 2014-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evernote_oauth
@@ -141,7 +141,7 @@ rubyforge_project:
141
141
  rubygems_version: 2.0.3
142
142
  signing_key:
143
143
  specification_version: 4
144
- summary: Evernote various notifier via Yo.
144
+ summary: Evernote various events notifier via Yo.
145
145
  test_files:
146
146
  - spec/envryo_spec.rb
147
147
  - spec/spec_helper.rb