renote 0.0.7 → 0.1.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzlmNTYyNDUwOGVlNjRlOTFkM2VlMmU0NTJmMzU1MjdkYjIxNjk4ZQ==
4
+ YzAwZjkxODdhZTc3MDAzMmU0ZGVlYmIyYTk4ZjFiYjA4Njc1ZTNkNg==
5
5
  data.tar.gz: !binary |-
6
- YTE2OTczMDZhNjNiOGUxMTkyZTBkZDVkMWZhOGMwMWZmYzZhZWQ0OQ==
6
+ MDRhODU0ZDgwYmUyZjYwMTVjNWMwYTdlMDdhNmU3ZWU5OTA3ZWVhYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2UzNThkMGVkZGQ2N2E3MGZjZGE2NGU5ZTRkOGIyZDg5YTVjOWUzZWIyOWIz
10
- MDk5MzFlMjAyMjMwYzNkZTFiMjcxZGViZjE4N2I1MDUwMTA1YzZhYTEwNDJh
11
- OTRlYTMzNDU4OThkZjRiNzU1NmExMjdlYmZjZGZmMTA5MjgzZWQ=
9
+ OTY5NzA5NTI1YTlhZDEwZDRhYTAyZmExNzk1YzIzNGE5NmE5MjgzZmQ5OWIx
10
+ NzJmMWQ5MTkxY2I4YjQ1ZWM1YmEwYjJjNTYzOGNiMWQyMTUzYTVmNGY4NjBj
11
+ MzhmYzE0Y2QzZGMzZmQwZTJjNGU4YzdmZWUzMDIyYjRkNjM2NjU=
12
12
  data.tar.gz: !binary |-
13
- ZTBmNjY4NTA2OWI4NGIxNmNkOGJlZTM4YTM0MDIwYjIwMjc4NDJhMGRiMDVl
14
- MWEwYmI0NTdkZTY1ZWJlZTc4ZDk2YjFlY2MwOWEwOGZiY2E2YWRhNjkzYzcz
15
- ZDQ0ZDljZDQ3NTRhNDY3ZWZhNzBmMjhhMmNiODJhNDdlNmQwNmE=
13
+ MWQ4Y2M5MzYyZmNlNzRlNmI4MmZmY2FiZTAyYWMyMzMwMzkyZmMxMzI1MTk5
14
+ MWRiNDQ1YjE3MjM3Nzg4MDJmMDAwOGUyMWVmZmI1MWRiM2U1NTc0NjJjM2Vj
15
+ NGYzODMwOGZjYWUyM2YwZjZjNDkwYzE2MzY5N2FiNjA4NzNkMTA=
data/.gitignore CHANGED
@@ -14,4 +14,6 @@
14
14
  mkmf.log
15
15
 
16
16
  # IntelliJ IDEA
17
+ /.idea/
18
+ .rakeTasks
17
19
  *.iml
data/README.md CHANGED
@@ -15,7 +15,7 @@ Renote
15
15
 
16
16
  Description
17
17
  -----------
18
- Renote is a CLI for discreet note-taking. Use Renote in order to take notes discreetly.
18
+ Renote is a CLI for note-taking.
19
19
 
20
20
  Installation
21
21
  ------------
@@ -29,7 +29,7 @@ Install from the command line:
29
29
 
30
30
  ## Usage
31
31
 
32
- Because Renote is built on the extraordinarily nifty (Thor)[https://github.com/erikhuda/thor], you can simply run the CLI with no arguments to display the most up-to-date usage information.
32
+ Because Renote is built on the extraordinarily nifty [Thor](https://github.com/erikhuda/thor), you can simply run the CLI with no arguments to display the most up-to-date usage information.
33
33
 
34
34
  $ renote
35
35
 
@@ -45,4 +45,4 @@ Because Renote is built on the extraordinarily nifty (Thor)[https://github.com/e
45
45
 
46
46
  [A Simple Command Line Tool with Ruby + Thor](http://www.michaelrigart.be/en/blog/a-simple-ruby-command-line-tool.html)
47
47
 
48
- [Building Your Tools With Thor](http://blog.paracode.com/2012/05/17/building-your-tools-with-thor/)
48
+ [Building Your Tools With Thor](http://blog.paracode.com/2012/05/17/building-your-tools-with-thor/)
@@ -1,12 +1,14 @@
1
- require "renote/version"
2
- require "renote/cli/application"
1
+ require 'require_all'
2
+ require_all 'lib'
3
3
 
4
4
  module Renote
5
5
  module Cli
6
+ =begin
6
7
  puts ' _ '
7
8
  puts ' ___ ___ ___ ___| |_ ___ '
8
9
  puts ' | _| -_| | . | _| -_| '
9
10
  puts ' |_| |___|_|_|___|_| |___| '
10
11
  puts ' '
12
+ =end
11
13
  end
12
14
  end
@@ -4,10 +4,16 @@ module Renote
4
4
  module Cli
5
5
  class Application < Thor
6
6
 
7
- desc 'thru INFILE OUTFILE', 'Pass-through note taking records keyboard input to <OUTFILE> while synchronously displaying contents of <INFILE>.'
8
- def thru(infile,outfile)
9
- puts "IN #{infile}"
10
- puts "OUT #{outfile}"
7
+ desc 'into <FILE>', 'Shell appends keyboard input to <FILE> until ESCAPE key is pressed.'
8
+ def into(target_file_path)
9
+ @shell = Renote::Models::Shell.new
10
+ open(target_file_path, 'a') { |handle|
11
+ @shell.open handle
12
+ while @shell.alive?
13
+ @shell.run
14
+ end
15
+ }
16
+ puts ''
11
17
  end
12
18
 
13
19
  end
@@ -0,0 +1,102 @@
1
+ require 'state_machine'
2
+ require 'io/console'
3
+
4
+
5
+ module Renote
6
+ module Models
7
+ class Shell
8
+ attr_accessor :output_file_path
9
+
10
+ state_machine :state, :initial => :loading do
11
+
12
+ before_transition :on => :active do
13
+ if @output_file.nil?
14
+ raise 'Must specify an output file.'
15
+ end
16
+ end
17
+
18
+ event :start do
19
+ transition :loading => :active
20
+ end
21
+
22
+ event :finish do
23
+ transition :active => :done
24
+ end
25
+
26
+ state :loading, :active do
27
+ def alive?
28
+ true
29
+ end
30
+ end
31
+
32
+ state :active do
33
+ def run
34
+ c = read_char
35
+ handle_input c if c
36
+ end
37
+ end
38
+
39
+ state :done do
40
+ def alive?
41
+ false
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ def open(handle)
48
+ set_output_file handle
49
+ start!
50
+ end
51
+
52
+ def initialize
53
+ @output_file = nil
54
+ super() # NOTE: This *must* be called, otherwise states won't get initialized
55
+ end
56
+
57
+ private
58
+
59
+ def set_output_file(handle)
60
+ @output_file = handle
61
+ end
62
+
63
+ def handle_input(c)
64
+ if c=="\e"
65
+ finish!
66
+ end
67
+ @output_file.putc c
68
+ putc '.'
69
+ end
70
+
71
+ # read a character without pressing enter and without printing to the screen
72
+ def read_char
73
+ begin
74
+ # save previous state of stty
75
+ old_state = `stty -g`
76
+ # disable echoing and enable raw (not having to press enter)
77
+ system "stty raw -echo"
78
+ c = STDIN.getc.chr
79
+ # gather next two characters of special keys
80
+ if c=="\e"
81
+ extra_thread = Thread.new {
82
+ c = c + STDIN.getc.chr
83
+ c = c + STDIN.getc.chr
84
+ }
85
+ # wait just long enough for special keys to get swallowed
86
+ extra_thread.join(0.00001)
87
+ # kill thread so not-so-long special keys don't wait on getc
88
+ extra_thread.kill
89
+ end
90
+ rescue => ex
91
+ puts "#{ex.class}: #{ex.message}"
92
+ puts ex.backtrace
93
+ ensure
94
+ # restore previous state of stty
95
+ system "stty #{old_state}"
96
+ end
97
+ c
98
+ end
99
+
100
+ end
101
+ end
102
+ end
@@ -1,3 +1,3 @@
1
1
  module Renote
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -4,12 +4,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'renote/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
+
7
8
  s.name = 'renote'
8
9
  s.version = Renote::VERSION
9
10
  s.authors = ['Nick Kaye']
10
11
  s.email = ['nick.c.kaye@gmail.com']
11
- s.summary = %q{Renote is a CLI for discreet note-taking.}
12
- s.description = %q{Use Renote in order to take notes discreetly.}
12
+ s.summary = %q{Renote is a CLI for note-taking.}
13
+ s.description = %q{Use Renote to append keyboard input to a file, until ESCAPE is pressed.}
13
14
  s.homepage = 'https://github.com/outrightmental/renote'
14
15
  s.license = 'MIT'
15
16
 
@@ -22,5 +23,9 @@ Gem::Specification.new do |s|
22
23
  s.add_development_dependency 'rake', '~> 10.0'
23
24
  s.add_development_dependency 'coveralls', '~> 0.7'
24
25
  s.add_development_dependency 'rspec', '~> 3.1'
26
+
27
+ s.add_dependency 'require_all', '~> 1.3'
28
+ s.add_dependency 'state_machine', '~> 1.2'
25
29
  s.add_dependency 'thor', '~> 0.19'
30
+
26
31
  end
@@ -1,5 +1,5 @@
1
- require 'renote/cli/application'
2
- require 'yaml'
1
+ require 'require_all'
2
+ require_all 'lib'
3
3
 
4
4
  # Coveralls
5
5
  require 'coveralls'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Kaye
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: require_all
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: state_machine
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: thor
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +108,7 @@ dependencies:
80
108
  - - ~>
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0.19'
83
- description: Use Renote in order to take notes discreetly.
111
+ description: Use Renote to append keyboard input to a file, until ESCAPE is pressed.
84
112
  email:
85
113
  - nick.c.kaye@gmail.com
86
114
  executables:
@@ -99,6 +127,7 @@ files:
99
127
  - bin/renote
100
128
  - lib/renote.rb
101
129
  - lib/renote/cli/application.rb
130
+ - lib/renote/models/shell.rb
102
131
  - lib/renote/version.rb
103
132
  - renote.gemspec
104
133
  - spec/_helper.rb
@@ -126,7 +155,7 @@ rubyforge_project:
126
155
  rubygems_version: 2.2.2
127
156
  signing_key:
128
157
  specification_version: 4
129
- summary: Renote is a CLI for discreet note-taking.
158
+ summary: Renote is a CLI for note-taking.
130
159
  test_files:
131
160
  - spec/_helper.rb
132
161
  - spec/application_spec.rb