enr 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +4 -0
- data/exe/enr +169 -0
- data/lib/enr/version.rb +5 -0
- data/lib/enr.rb +8 -0
- data/sig/enr.rbs +4 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cda4dac639e331c7289bf3cf37d1c237bf8cf9262a03104a5e4f059552293962
|
4
|
+
data.tar.gz: 0a15d5986c7841f5182243482d45c9d9b268594312c148e91c1e4772e392e759
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a70d0cff5d11d894ec99fb327b41014dd900c69576da1ca4abf067d9abe637f6352781ac4759bd46cd9769d5e2b9e0b0ea6c2f216c86d58b348765456a1b3639
|
7
|
+
data.tar.gz: 7130beacd41a3d2bee9518c467770d71a4b126e56adb1417ca27a040bf05dd6459e3b43db3f960758b5b3f7e43a1aae4609f7963304ecc45cb7f72a06253c2cb
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2024 Yuya.Nishida.
|
2
|
+
|
3
|
+
X11 License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# enr: EverNote Request
|
2
|
+
|
3
|
+
An Evernote command line program
|
4
|
+
|
5
|
+
[![License X11](https://img.shields.io/badge/license-X11-blue.svg)](https://raw.githubusercontent.com/nishidayuya/enr/master/LICENSE.txt)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/enr.svg)](https://rubygems.org/gems/enr)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```console
|
11
|
+
$ gem install enr
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
### Setup
|
17
|
+
|
18
|
+
Set `ENR_TOKEN` environment your [developer token](https://www.evernote.com/api/DeveloperToken.action).
|
19
|
+
|
20
|
+
```console
|
21
|
+
$ export ENR_TOKEN='your developer token'
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
### Read ENML from GUID
|
26
|
+
|
27
|
+
```console
|
28
|
+
$ enr get GUID
|
29
|
+
```
|
30
|
+
|
31
|
+
### Create note from ENML file
|
32
|
+
|
33
|
+
```console
|
34
|
+
$ enr post INPUT-PATH
|
35
|
+
```
|
36
|
+
|
37
|
+
### Update existing note from ENML file
|
38
|
+
|
39
|
+
```console
|
40
|
+
$ enr put GUID INPUT-PATH
|
41
|
+
```
|
42
|
+
|
43
|
+
### Destroy note by GUID
|
44
|
+
|
45
|
+
```console
|
46
|
+
$ enr delete GUID
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nishidayuya/enr .
|
data/Rakefile
ADDED
data/exe/enr
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "evernote_oauth"
|
4
|
+
# workaround https://github.com/Evernote/evernote-sdk-ruby/pull/23
|
5
|
+
Fixnum = Integer if !defined?(Fixnum)
|
6
|
+
|
7
|
+
require "enr"
|
8
|
+
|
9
|
+
module Enr
|
10
|
+
class << self
|
11
|
+
def token
|
12
|
+
return ENV.fetch("ENR_TOKEN")
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_evernote_client
|
16
|
+
client = EvernoteOAuth::Client.new(token:, sandbox: false)
|
17
|
+
user_store = client.user_store
|
18
|
+
api_version_ok = user_store.checkVersion(
|
19
|
+
"Enr",
|
20
|
+
Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR,
|
21
|
+
Evernote::EDAM::UserStore::EDAM_VERSION_MINOR,
|
22
|
+
)
|
23
|
+
raise "Evernote API version mismatch" if !api_version_ok
|
24
|
+
|
25
|
+
return client
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Enr::Cli
|
31
|
+
USAGE = <<~USAGE
|
32
|
+
Usage: #{File.basename(Process.argv0)} SUB-COMMAND
|
33
|
+
|
34
|
+
SUB-COMMANDs are:
|
35
|
+
|
36
|
+
- get
|
37
|
+
- post
|
38
|
+
- put
|
39
|
+
- delete
|
40
|
+
USAGE
|
41
|
+
|
42
|
+
class << self
|
43
|
+
def call(argv)
|
44
|
+
sub_command, *rest_argv = *argv
|
45
|
+
sub_command_class_name = (sub_command || "dummy").capitalize
|
46
|
+
begin
|
47
|
+
sub_command_class = const_get(sub_command_class_name)
|
48
|
+
rescue NameError
|
49
|
+
$stderr.puts(USAGE)
|
50
|
+
exit(1)
|
51
|
+
end
|
52
|
+
sub_command_class.(rest_argv)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module Enr::Cli::Get
|
58
|
+
USAGE = <<~USAGE
|
59
|
+
Usage: #{File.basename(Process.argv0)} get GUID
|
60
|
+
USAGE
|
61
|
+
|
62
|
+
class << self
|
63
|
+
def call(argv)
|
64
|
+
guid, _attachment_name = *argv
|
65
|
+
if !guid
|
66
|
+
$stderr.puts(USAGE)
|
67
|
+
exit(1)
|
68
|
+
end
|
69
|
+
client = Enr.create_evernote_client
|
70
|
+
note_store = client.note_store
|
71
|
+
note = note_store.getNote(Enr.token, guid, true, false, false, false)
|
72
|
+
puts(note.content)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
module Enr::Cli::Post
|
78
|
+
USAGE = <<~USAGE
|
79
|
+
Usage: #{File.basename(Process.argv0)} post INPUT-PATH
|
80
|
+
USAGE
|
81
|
+
|
82
|
+
class << self
|
83
|
+
def call(argv)
|
84
|
+
note = build_note_from_argv(argv)
|
85
|
+
client = Enr.create_evernote_client
|
86
|
+
note_store = client.note_store
|
87
|
+
created_note = note_store.createNote(Enr.token, note)
|
88
|
+
puts("created note: guid=#{created_note.guid}")
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def build_note_from_argv(argv)
|
94
|
+
s_input_path = argv.shift
|
95
|
+
if !s_input_path
|
96
|
+
$stderr.puts(USAGE)
|
97
|
+
exit(1)
|
98
|
+
end
|
99
|
+
|
100
|
+
input_path = Pathname(s_input_path)
|
101
|
+
title = input_path.basename.to_s
|
102
|
+
note = Evernote::EDAM::Type::Note.new(
|
103
|
+
title:,
|
104
|
+
content: input_path.read,
|
105
|
+
)
|
106
|
+
return note
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
module Enr::Cli::Put
|
112
|
+
USAGE = <<~USAGE
|
113
|
+
Usage: #{File.basename(Process.argv0)} put GUID INPUT-PATH
|
114
|
+
USAGE
|
115
|
+
|
116
|
+
class << self
|
117
|
+
def call(argv)
|
118
|
+
guid = argv.shift
|
119
|
+
note_from_argv = build_note_from_argv(argv)
|
120
|
+
client = Enr.create_evernote_client
|
121
|
+
note_store = client.note_store
|
122
|
+
note = note_store.getNote(Enr.token, guid, false, false, false, false)
|
123
|
+
note.content = note_from_argv.content
|
124
|
+
updated_note = note_store.updateNote(Enr.token, note)
|
125
|
+
puts("updated note: guid=#{updated_note.guid}")
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def build_note_from_argv(argv)
|
131
|
+
s_input_path = argv.shift
|
132
|
+
if !s_input_path
|
133
|
+
$stderr.puts(USAGE)
|
134
|
+
exit(1)
|
135
|
+
end
|
136
|
+
|
137
|
+
input_path = Pathname(s_input_path)
|
138
|
+
title = input_path.basename.to_s
|
139
|
+
note = Evernote::EDAM::Type::Note.new(
|
140
|
+
title:,
|
141
|
+
content: input_path.read,
|
142
|
+
)
|
143
|
+
return note
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
module Enr::Cli::Delete
|
149
|
+
USAGE = <<~USAGE
|
150
|
+
Usage: #{File.basename(Process.argv0)} delete GUID
|
151
|
+
USAGE
|
152
|
+
|
153
|
+
class << self
|
154
|
+
def call(argv)
|
155
|
+
guid = argv.shift
|
156
|
+
if !guid
|
157
|
+
$stderr.puts(USAGE)
|
158
|
+
exit(1)
|
159
|
+
end
|
160
|
+
|
161
|
+
client = Enr.create_evernote_client
|
162
|
+
note_store = client.note_store
|
163
|
+
sequence_number = note_store.deleteNote(Enr.token, guid)
|
164
|
+
puts("deleted note: guid=#{guid} sequence_number=#{sequence_number.inspect}")
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
Enr::Cli.(ARGV)
|
data/lib/enr/version.rb
ADDED
data/lib/enr.rb
ADDED
data/sig/enr.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: enr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuya.Nishida.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base64
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: evernote_oauth
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: debug
|
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
|
+
description: An Evernote command program
|
56
|
+
email:
|
57
|
+
executables:
|
58
|
+
- enr
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- LICENSE.txt
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- exe/enr
|
66
|
+
- lib/enr.rb
|
67
|
+
- lib/enr/version.rb
|
68
|
+
- sig/enr.rbs
|
69
|
+
homepage: https://github.com/nishidayuya/enr
|
70
|
+
licenses: []
|
71
|
+
metadata:
|
72
|
+
homepage_uri: https://github.com/nishidayuya/enr
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 2.6.0
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubygems_version: 3.5.3
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: 'enr: EverNote Request'
|
92
|
+
test_files: []
|