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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f65468515f43f105fb2d1b079c5fd6bf3b0dd2e2
4
- data.tar.gz: 81d81e92b821af9cd45ce67561d568c9edff4f44
3
+ metadata.gz: f0c913d4664e70586af61cbfb861dabe1825c4d1
4
+ data.tar.gz: 2221021319f83107159a9ec0313a7859339cb802
5
5
  SHA512:
6
- metadata.gz: 95c5f2a20a38ce3c42980d4ee6b095b0f74708338146db0316317cac4942b1b37b524569799b7afd2f377c4cddd2140dc9b4d3837adeb0dda980d79c962fdbb9
7
- data.tar.gz: b42aba9aa3a77c8a954ca6b3212b64158d06b8fea02ca8904819d061f5db43225cd56fafe2666224d2bdb1b2a60f7318cb088ae6ab9f9d1b1973db3ff786d103
6
+ metadata.gz: aa8886a8504fef785592789ac42d1a52eacdfb2e0834aee24b548c2080387d75e65195e25c8dd5be3d489c77b85ba178f9c37b3ebce7425d1729ede9d541d3a5
7
+ data.tar.gz: 1146ba68f18cea3587d51fe618333abafa9777cc70a12749b284decf289e57b9fbce91d587bdae206ce36010589a1efb36d9e148935e58fc4a650304babbd05b
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
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
- Currently this done nothing! :)
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
@@ -1,2 +1,11 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :console do
9
+ exec 'pry -r tusker -I ./lib'
10
+ end
2
11
 
@@ -1,5 +1,22 @@
1
- require "tusker/version"
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
- # Your code goes here...
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,5 @@
1
+ require 'evernote_oauth'
2
+
3
+ module Tusker
4
+ class Client < EvernoteOAuth::Client; end
5
+ 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
@@ -1,3 +1,3 @@
1
1
  module Tusker
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,2 @@
1
+ ---
2
+ token: '12345'
@@ -1,9 +1,5 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
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,11 @@
1
+ require 'spec_helper'
2
+
3
+ module Tusker
4
+ describe Client do
5
+ it "is a subclass of EvernoteOAuth::Client" do
6
+ token = "12345"
7
+ client = Client.new(token: token)
8
+ expect(client.class.ancestors).to include EvernoteOAuth::Client
9
+ end
10
+ end
11
+ end
@@ -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
@@ -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.1
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-19 00:00:00.000000000 Z
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
- has_rdoc:
146
+ - spec/tusker/client_spec.rb
147
+ - spec/tusker/config_spec.rb