ghetto_notes 0.1.0

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: dfa14af26d1d7fc3305acfa35ba124f16c8654b2248b3c79cc6fee041b7d7360
4
+ data.tar.gz: d5334e4671658faad841c86c077e824f5dbea3ca8294b986a8bac72d754f9d89
5
+ SHA512:
6
+ metadata.gz: 7e02824425f666de3f5e73683c69e577a6d5261c0a39bc368f8c9f5485219f2a727e93e33faf84c97188c2326a545b670c32786988f85ec8851b2668c70cdb1e
7
+ data.tar.gz: 2e4c54cc281995a6aa27484fc695e9e5ee1ee64cd55d75d6614b0722fcd58eff98678ec2af84532bbbb37f247ba5edcabd697da639cc9e4e96587d0b4063bf6c
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ tags
2
+ tags.*
3
+ /pkg/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ghetto_notes.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ coderay (1.1.2)
5
+ diff-lcs (1.3)
6
+ method_source (1.0.0)
7
+ pry (0.13.0)
8
+ coderay (~> 1.1)
9
+ method_source (~> 1.0)
10
+ rspec (3.9.0)
11
+ rspec-core (~> 3.9.0)
12
+ rspec-expectations (~> 3.9.0)
13
+ rspec-mocks (~> 3.9.0)
14
+ rspec-core (3.9.1)
15
+ rspec-support (~> 3.9.1)
16
+ rspec-expectations (3.9.1)
17
+ diff-lcs (>= 1.2.0, < 2.0)
18
+ rspec-support (~> 3.9.0)
19
+ rspec-mocks (3.9.1)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.9.0)
22
+ rspec-support (3.9.2)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ pry
29
+ rspec
30
+
31
+ BUNDLED WITH
32
+ 1.16.3
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # GhettoNotes
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ghetto_notes`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ghetto_notes'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ghetto_notes
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/scrooloose/ghetto-notes.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ghetto_notes"
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__)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/ghetto_notes'
4
+
5
+ GhettoNotes.exit_with_usage unless ARGV.size == 2
6
+
7
+ GhettoNotes::Main.new(*ARGV).run
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
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ghetto_notes/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ghetto_notes"
8
+ spec.version = GhettoNotes::VERSION
9
+ spec.authors = ["Martin Grenfell"]
10
+ spec.email = ["martin.grenfell@gmail.com"]
11
+
12
+ spec.summary = %q{Extremely shit note syncing program.}
13
+ spec.description = %q{Sync a notes dir to and from a remote repo.}
14
+ spec.homepage = "https://github.com/scrooloose/ghetto-notes"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rspec", "~> 3.9.0"
27
+ spec.add_development_dependency "pry", "~> 0.13.0"
28
+ end
@@ -0,0 +1,31 @@
1
+ require 'tempfile'
2
+
3
+ module GhettoNotes
4
+ class Installer
5
+ attr_reader :sync_dir
6
+
7
+ def initialize(sync_dir)
8
+ @sync_dir = sync_dir
9
+ end
10
+
11
+ def perform
12
+ cmd = "#{GhettoNotes.bin_file} sync #{sync_dir}"
13
+ crontab_entry = "*/2 * * * * #{cmd}"
14
+ existing_tab = `crontab -l`.split("\n")
15
+
16
+ if existing_tab.include?(crontab_entry)
17
+ $stderr.puts 'Already installed'
18
+ return
19
+ end
20
+
21
+ new_crontab = Tempfile.new
22
+ new_crontab << existing_tab.join("\n")
23
+ new_crontab << "\n"
24
+ new_crontab << crontab_entry
25
+ new_crontab << "\n"
26
+ new_crontab.close
27
+
28
+ `crontab #{new_crontab.path}`
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ require 'optparse'
2
+
3
+ module GhettoNotes
4
+ class Main
5
+ def initialize(subcommand, sync_dir)
6
+ @subcommand = subcommand
7
+ @sync_dir = File.expand_path(sync_dir)
8
+ GhettoNotes.exit_with_usage unless ['install', 'sync'].include?(subcommand)
9
+ end
10
+
11
+ def run
12
+ send("#{subcommand}_subcommand")
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :subcommand, :sync_dir
18
+
19
+ def sync_subcommand
20
+ NotesDirectory.new(sync_dir).sync
21
+ end
22
+
23
+ def install_subcommand
24
+ Installer.new(sync_dir).perform
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ module GhettoNotes
2
+ class NotesDirectory
3
+ attr_reader :dir
4
+
5
+ def initialize(dir)
6
+ @dir = dir
7
+ end
8
+
9
+ def sync
10
+ Dir.chdir(dir)
11
+ system('git pull origin master')
12
+ system('git add .')
13
+ system('git commit -m "ghetto notes: add latest changes"')
14
+ system('git push')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module GhettoNotes
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'ghetto_notes/main'
2
+ require_relative 'ghetto_notes/notes_directory'
3
+ require_relative 'ghetto_notes/installer'
4
+ require_relative 'ghetto_notes/version'
5
+
6
+ module GhettoNotes
7
+ USAGE = <<~EOS
8
+ Usage: notes.rb <command>
9
+
10
+ One of the following commands must be specified
11
+
12
+ install Install the cronjob to invoke ghetto notes
13
+ sync Sync notes to remote - pull, commit then push
14
+ EOS
15
+
16
+ def self.exit_with_usage
17
+ $stderr.puts(USAGE)
18
+ exit(1)
19
+ end
20
+
21
+ def self.bin_file
22
+ path = File.join(File.dirname(__FILE__), '..', 'bin', 'ghetto_notes.rb')
23
+ File.expand_path(path)
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ghetto_notes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Martin Grenfell
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.9.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.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.13.0
55
+ description: Sync a notes dir to and from a remote repo.
56
+ email:
57
+ - martin.grenfell@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/ghetto_notes.rb
70
+ - bin/setup
71
+ - ghetto_notes.gemspec
72
+ - lib/ghetto_notes.rb
73
+ - lib/ghetto_notes/installer.rb
74
+ - lib/ghetto_notes/main.rb
75
+ - lib/ghetto_notes/notes_directory.rb
76
+ - lib/ghetto_notes/version.rb
77
+ homepage: https://github.com/scrooloose/ghetto-notes
78
+ licenses: []
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.7.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Extremely shit note syncing program.
100
+ test_files: []