tusker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +9 -0
- data/README.md +19 -1
- data/Rakefile +10 -1
- data/lib/tusker.rb +19 -2
- data/lib/tusker/client.rb +5 -0
- data/lib/tusker/config.rb +72 -0
- data/lib/tusker/version.rb +1 -1
- data/spec/fixtures/.tusker +2 -0
- data/spec/spec_helper.rb +2 -6
- data/spec/tusker/client_spec.rb +11 -0
- data/spec/tusker/config_spec.rb +50 -0
- data/tusker.gemspec +4 -0
- metadata +53 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0c913d4664e70586af61cbfb861dabe1825c4d1
|
4
|
+
data.tar.gz: 2221021319f83107159a9ec0313a7859339cb802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa8886a8504fef785592789ac42d1a52eacdfb2e0834aee24b548c2080387d75e65195e25c8dd5be3d489c77b85ba178f9c37b3ebce7425d1729ede9d541d3a5
|
7
|
+
data.tar.gz: 1146ba68f18cea3587d51fe618333abafa9777cc70a12749b284decf289e57b9fbce91d587bdae206ce36010589a1efb36d9e148935e58fc4a650304babbd05b
|
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -16,9 +16,27 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install tusker
|
18
18
|
|
19
|
+
## Setup
|
20
|
+
|
21
|
+
### Current Caveats
|
22
|
+
|
23
|
+
- Has only been run on `ruby 2.1.1`.
|
24
|
+
- Works on a Mac, and I presume Linux, machine.
|
25
|
+
- Only works with sandboxed developer tokens.
|
26
|
+
- You can obtain one from here: [https://sandbox.evernote.com/api/DeveloperToken.action](https://sandbox.evernote.com/api/DeveloperToken.action)
|
27
|
+
- Much lacking, so alpha.
|
28
|
+
|
19
29
|
## Usage
|
20
30
|
|
21
|
-
|
31
|
+
### To list Notebooks:
|
32
|
+
```
|
33
|
+
# in irb, pry, etc
|
34
|
+
|
35
|
+
> require 'tusker'
|
36
|
+
> Tusker.add_token(developer_token)
|
37
|
+
> Tusker.notebooks
|
38
|
+
# ===> ["thewatts' notebook"]
|
39
|
+
```
|
22
40
|
|
23
41
|
## Contributing
|
24
42
|
|
data/Rakefile
CHANGED
data/lib/tusker.rb
CHANGED
@@ -1,5 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require 'tusker/version'
|
2
|
+
require 'tusker/client'
|
3
|
+
require 'tusker/config'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'pry'
|
7
|
+
rescue
|
8
|
+
end
|
2
9
|
|
3
10
|
module Tusker
|
4
|
-
|
11
|
+
|
12
|
+
def self.add_token(token)
|
13
|
+
Config.write(token)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.notebooks
|
17
|
+
token = Config.read.token
|
18
|
+
client = Client.new(token: token)
|
19
|
+
client.note_store.listNotebooks.map { |notebook| notebook.name }
|
20
|
+
end
|
21
|
+
|
5
22
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'yaml/store'
|
3
|
+
|
4
|
+
module Tusker
|
5
|
+
class Config
|
6
|
+
|
7
|
+
def self.read(path = nil)
|
8
|
+
new(path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.write(token, path = nil)
|
12
|
+
config = new(path)
|
13
|
+
config.token = token
|
14
|
+
config.save
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :path
|
18
|
+
attr_writer :token
|
19
|
+
|
20
|
+
def initialize(path = nil)
|
21
|
+
@path = path || default_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_path
|
25
|
+
File.expand_path('~')
|
26
|
+
end
|
27
|
+
|
28
|
+
def save
|
29
|
+
FileUtils.mkdir_p(path)
|
30
|
+
save_token_to_file
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def token
|
35
|
+
@token ||= data_from_file['token']
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def data_from_file
|
41
|
+
@data ||= store.load(File.read(file))
|
42
|
+
end
|
43
|
+
|
44
|
+
def file
|
45
|
+
@file ||= find_or_create_file
|
46
|
+
end
|
47
|
+
|
48
|
+
def filename
|
49
|
+
'.tusker'
|
50
|
+
end
|
51
|
+
|
52
|
+
def find_or_create_file
|
53
|
+
filepath = File.join(path, filename)
|
54
|
+
|
55
|
+
if File.exists?(filepath)
|
56
|
+
filepath
|
57
|
+
else
|
58
|
+
FileUtils.touch(filepath)[0]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def save_token_to_file
|
63
|
+
store.transaction do
|
64
|
+
store['token'] = token
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def store
|
69
|
+
@store ||= YAML::Store.new(file)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/tusker/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
1
|
+
require 'tusker'
|
2
|
+
|
7
3
|
RSpec.configure do |config|
|
8
4
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
5
|
config.run_all_when_everything_filtered = true
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tusker
|
4
|
+
describe Config do
|
5
|
+
|
6
|
+
describe "::read" do
|
7
|
+
before do
|
8
|
+
store = YAML::Store.new(stub_file)
|
9
|
+
store.transaction do
|
10
|
+
store['token'] = sample_token
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "pulls the token from the .tusker file" do
|
15
|
+
config = Tusker::Config.read(stub_path)
|
16
|
+
expect(config.token).to eq sample_token
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "::write" do
|
21
|
+
before do
|
22
|
+
file = './spec/fixtures/.tusker'
|
23
|
+
FileUtils.rm(file) if File.exists?(file)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "adds the token to the config file" do
|
27
|
+
path = './spec/fixtures'
|
28
|
+
config = Tusker::Config.write(sample_token, path)
|
29
|
+
expect(config.token).to eq sample_token
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "uses the default path when not initialized with a path" do
|
34
|
+
config = Tusker::Config.new
|
35
|
+
expect(config.path).to eq '~'
|
36
|
+
end
|
37
|
+
|
38
|
+
def stub_file
|
39
|
+
'./spec/fixtures/.tusker'
|
40
|
+
end
|
41
|
+
|
42
|
+
def stub_path
|
43
|
+
'./spec/fixtures'
|
44
|
+
end
|
45
|
+
|
46
|
+
def sample_token
|
47
|
+
'12345'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/tusker.gemspec
CHANGED
@@ -18,7 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "evernote_oauth"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
24
|
spec.add_development_dependency "rake"
|
23
25
|
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "guard-rspec"
|
27
|
+
spec.add_development_dependency "pry"
|
24
28
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tusker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathaniel Watts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: evernote_oauth
|
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'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,34 @@ dependencies:
|
|
52
66
|
- - '>='
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
55
97
|
description: Tusker is a command line interface to create notes with Evernote.
|
56
98
|
email: reg@nathanielwatts.com
|
57
99
|
executables: []
|
@@ -61,12 +103,18 @@ files:
|
|
61
103
|
- .gitignore
|
62
104
|
- .rspec
|
63
105
|
- Gemfile
|
106
|
+
- Guardfile
|
64
107
|
- LICENSE.txt
|
65
108
|
- README.md
|
66
109
|
- Rakefile
|
67
110
|
- lib/tusker.rb
|
111
|
+
- lib/tusker/client.rb
|
112
|
+
- lib/tusker/config.rb
|
68
113
|
- lib/tusker/version.rb
|
114
|
+
- spec/fixtures/.tusker
|
69
115
|
- spec/spec_helper.rb
|
116
|
+
- spec/tusker/client_spec.rb
|
117
|
+
- spec/tusker/config_spec.rb
|
70
118
|
- tusker.gemspec
|
71
119
|
homepage: http://github.com/thewatts/tusker
|
72
120
|
licenses:
|
@@ -93,5 +141,7 @@ signing_key:
|
|
93
141
|
specification_version: 4
|
94
142
|
summary: Command line interface to use Evernote
|
95
143
|
test_files:
|
144
|
+
- spec/fixtures/.tusker
|
96
145
|
- spec/spec_helper.rb
|
97
|
-
|
146
|
+
- spec/tusker/client_spec.rb
|
147
|
+
- spec/tusker/config_spec.rb
|