diane 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 98fcb7ec286e01666ff8367b214104fed956bba09deda226f66910bfe6749ba2
4
+ data.tar.gz: 37fd5c4cf665cb094a8536fe8b8703b9228b07fca61265c804cd3f54dfc19c01
5
+ SHA512:
6
+ metadata.gz: 58194d040d9fa9ab90bd5806aa86547640956842b59849465b30bda25264981c8aacf10d85a1cab648599f231b40cb5be97f0a93235915231161ac6661932146
7
+ data.tar.gz: 69bdc8c0eaef3ef0ec0bb8672f0fe95233735a4a44759187210b9b6899b2242410ef629c56347e988c828d5101065bb403b89ca0a6646aba4e830cae91b84b3a
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+ ./DIANE
data/DIANE ADDED
@@ -0,0 +1,3 @@
1
+ user,message,time
2
+ mnyrop,"test",01/06/2018 17:12
3
+ mnyrop,"test",01/06/2018 17:30
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in diane.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 mar-ii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Diane
2
+
3
+ > *I have been assigned a secretary. Her name is Diane. She seems an interesting cross between a saint and a cabaret singer.*
4
+
5
+ A tiny + salty Ruby CL utility for recording and playing back your thoughts/intel/motivations, without bloating the Git logs.
6
+
7
+ <img src="https://media.giphy.com/media/WubJTtnWXKfmM/giphy.gif" width="400"/>
8
+
9
+ ![diane screen gif](./docs/diane.gif)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'diane'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install diane
26
+
27
+ ## Usage
28
+
29
+ TODO: Write usage instructions here
30
+
31
+
32
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "diane"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/diane ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mercenary'
4
+ require 'diane'
5
+
6
+ Mercenary.program(:diane) do |p|
7
+ p.version Diane::VERSION
8
+ p.description ''
9
+ p.syntax "diane <subcommand> [options]"
10
+
11
+ p.command(:record) do |c|
12
+ c.syntax 'record MESSAGE'
13
+ c.description ''
14
+ c.option 'user', '--user', 'Override'
15
+ c.action do |args, opts|
16
+ message = args.first
17
+ Diane::Recorder.new(message, opts)
18
+ end
19
+ end
20
+
21
+ p.command(:playback) do |c|
22
+ c.syntax 'playback NUMBER'
23
+ c.description ''
24
+ c.option 'all', '--all', 'Playback all matching recordings (no int limit)'
25
+ c.option 'inorder', '--inorder', 'Playback oldest recordings first'
26
+ c.option 'everyone', '--everyone', 'Playback everyone\'s recording, not just your own'
27
+ c.action do |args, opts|
28
+ num = args.first.to_i.abs
29
+ num += 1 if num == 0
30
+ Diane::Player.new(num, opts)
31
+ end
32
+ end
33
+ end
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/diane.gemspec ADDED
@@ -0,0 +1,26 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "diane/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "diane"
8
+ spec.version = Diane::VERSION
9
+ spec.authors = ["mnyrop"]
10
+ spec.email = ["m.nyrop@columbia.edu"]
11
+
12
+ spec.summary = %q{CL gem for recording and playing back thoughts/intel/motivations without bloating the Git logs.}
13
+ spec.description = %q{I have been assigned a secretary. Her name is Diane. She seems an interesting cross between a saint and a cabaret singer.}
14
+ spec.homepage = "https://github.com/mnyrop/diane"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.executables = ["diane"]
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "mercenary", "~> 0.3"
24
+ spec.add_dependency "colorize", "~> 0.3"
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ end
data/docs/DIANE ADDED
@@ -0,0 +1,11 @@
1
+ user,message,time
2
+ cooper,"entering the town of twin peaks, five miles south of the canadian border, twelve miles west of the state line",01/06/2018 15:02
3
+ cooper,"i've never seen so many trees in my life",01/06/2018 15:02
4
+ cooper,"i almost forgot, i've got to find out what kind of trees these are. they're really something.",01/06/2018 15:03
5
+ cooper,"the owls are not what they seem",01/06/2018 15:03
6
+ cooper,"I have no idea where this will lead us. But I have a definite feeling it will be a place both wonderful and strange.",01/06/2018 16:46
7
+ cooper,"MAY A SMILE BE YOUR UMBRELLA. WE'VE ALL HAD OUR SOCKS TOSSED AROUND.",01/06/2018 16:46
8
+ cooper,"Pie. Whoever invented the pie? Here was a great person.",01/06/2018 16:48
9
+ cooper,"I believe I was visited by a giant last night. Twice.",01/06/2018 16:53
10
+ mnyrop,"when you see me again, it won't be me",01/06/2018 16:58
11
+ mnyrop,"one day my log will have something to say about this",01/06/2018 17:04
data/docs/diane.gif ADDED
Binary file
@@ -0,0 +1,47 @@
1
+ require 'csv'
2
+ require 'colorize'
3
+
4
+ module Diane
5
+ class Player
6
+ def initialize(num, opts)
7
+ @num = num
8
+ @inorder = opts.fetch('inorder', false)
9
+ @everyone = opts.fetch('everyone', false)
10
+ @all = opts.fetch('all', false)
11
+ @recordings = recordings
12
+
13
+ play
14
+ end
15
+
16
+ def recordings
17
+ r = CSV.read(DIFILE, { headers: true }).map(&:to_hash)
18
+ r.select!{ |d| d['user'] == USER } unless @everyone
19
+ limit = @all ? r.length : [@num, r.length].min
20
+ r.reverse! unless @inorder
21
+ r.take(limit)
22
+ end
23
+
24
+ def preface
25
+ position = @inorder ? 'first' : 'last'
26
+ scope = @everyone ? "everyone's" : 'your'
27
+ if @recordings.length == 1
28
+ preface = "\nHere's the #{position} of #{scope} recordings:"
29
+ else
30
+ preface = "\nHere's the #{position} #{@recordings.length} of #{scope} recordings:"
31
+ end
32
+ preface.green
33
+ end
34
+
35
+ def play
36
+ if @recordings.empty?
37
+ puts "\nFuck off.".magenta
38
+ else
39
+ puts preface
40
+ recordings.each do |r|
41
+ puts "\n#{r['time']} : ".cyan + "@#{r['user']}".yellow
42
+ puts "#{r['message']}"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,28 @@
1
+
2
+ module Diane
3
+ class Recorder
4
+ def initialize(message, opts)
5
+ @message = escape(message)
6
+ record
7
+ end
8
+
9
+ def record
10
+ if File.exist? DIFILE
11
+ File.open(DIFILE, 'a') { |f| f.puts("#{USER},#{@message},#{TIME}") }
12
+ else
13
+ File.open(DIFILE, 'a') do |f|
14
+ f.puts('user,message,time')
15
+ f.puts("#{USER},#{@message},#{TIME}")
16
+ end
17
+ end
18
+ puts "✓".green
19
+ rescue => e
20
+ abort "Broken".magenta + "#{e}"
21
+ end
22
+
23
+ def escape(s)
24
+ abort "Message is Nil. Fuck off.".magenta if s.nil?
25
+ "\"#{s.gsub('"','\\"')}\""
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Diane
2
+ VERSION = "0.0.1"
3
+ end
data/lib/diane.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'date'
2
+
3
+ require 'diane/version'
4
+ require 'diane/player'
5
+ require 'diane/recorder'
6
+
7
+ module Diane
8
+ DIFILE = './DIANE'
9
+ USER = `git config user.name`.strip
10
+ TIME = DateTime.now.strftime("%d/%m/%Y %H:%M")
11
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diane
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - mnyrop
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mercenary
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colorize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ description: I have been assigned a secretary. Her name is Diane. She seems an interesting
56
+ cross between a saint and a cabaret singer.
57
+ email:
58
+ - m.nyrop@columbia.edu
59
+ executables:
60
+ - diane
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - DIANE
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - bin/console
70
+ - bin/diane
71
+ - bin/setup
72
+ - diane.gemspec
73
+ - docs/DIANE
74
+ - docs/diane.gif
75
+ - lib/diane.rb
76
+ - lib/diane/player.rb
77
+ - lib/diane/recorder.rb
78
+ - lib/diane/version.rb
79
+ homepage: https://github.com/mnyrop/diane
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.7.6
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: CL gem for recording and playing back thoughts/intel/motivations without
103
+ bloating the Git logs.
104
+ test_files: []