toothpick 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,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2VkNGY1ZTBhY2M2ZTg3ZWY1MDU2MzJiOTI4MzNlZTlhZmUwYmJlMQ==
5
+ data.tar.gz: !binary |-
6
+ ZWI0ZmYxYzM3YjhkMGEyMmIyMjczODlkMDhiMmVjMzg5MjJjNThjNg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YWJkOTI5ZWNkNGI4Y2QyYzk4MDU2OTMxZjY5ZDMyNTFlNGNlMmU1YmIwYzgx
10
+ OTI5NDJiN2EzMWJjYzE2YWY4Zjc2ZTg2MjcwZGM4ZmFiYzM0OWUzY2NiOTE5
11
+ YzdkYzdjYTFlMjU2ZjEyOGE3YzIwOTNhMDdjNGRhYmRjYTgyODk=
12
+ data.tar.gz: !binary |-
13
+ MTYyODljMjM4MmNkZWU1YjVmOWFiYjFjZTQzNmE4ZmIyNDU4OGUzOTg0OTkw
14
+ NDkwMDI1YTEzMTQzNzhlOGQzN2E3MDQyMjY3MGU5ODRhYmU4ZDlhMTFiZTRh
15
+ YzBiZmU1YWY5NGFjYWU2ZDE5MzQxNmQ0NjJmYWMwOTdhZWFjNWI=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in toothpick.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Emil Soman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Toothpick
2
+ ![toothpick](http://i39.tinypic.com/2vw7erb.png)
3
+
4
+ For the art of picking.
5
+
6
+ ## Installation
7
+
8
+ $ gem install toothpick
9
+
10
+ ## Usage
11
+
12
+ #Setup toothpick
13
+ toothpick init
14
+
15
+ #Open today's pick file for editing
16
+ toothpick new
17
+ #Save and quit to commit and push pick to repo
18
+
19
+ #NOTE: Experimental feature
20
+ #Search for a pick and open containing files in your $EDITOR
21
+ toothpick search STRING
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/toothpick ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'toothpick'
5
+ require 'toothpick/errors'
6
+
7
+ class ToothpickRunner < Thor
8
+ include Toothpick
9
+
10
+ default_task :help
11
+
12
+ desc "init PICKS_GIT_REPO", "Clones PICKS_GIT_REPO"
13
+ def init(picks_repo)
14
+ Commands::init(picks_repo)
15
+ say("Initialized toothpick", :green)
16
+ rescue Errors::ToothpickError => e
17
+ say "Error: #{e.message}", :red
18
+ end
19
+
20
+ desc "new", "Creates a new pick"
21
+ def new
22
+ Commands::new_pick
23
+ say("New pick added", :green)
24
+ rescue Errors::ToothpickError => e
25
+ say "Error: #{e.message}", :red
26
+ end
27
+
28
+ desc "search STRING", "Searches for STRING and opens files in your $EDITOR"
29
+ def search(string)
30
+ Commands::search(string)
31
+ rescue Errors::ToothpickError => e
32
+ say "Error: #{e.message}", :red
33
+ end
34
+
35
+
36
+ end
37
+
38
+ ToothpickRunner.start
data/lib/toothpick.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "toothpick/version"
2
+ require "toothpick/commands"
@@ -0,0 +1,47 @@
1
+ require 'toothpick/git'
2
+ require 'toothpick/search'
3
+ require 'toothpick/errors'
4
+ require 'date'
5
+
6
+ module Toothpick
7
+ module Commands
8
+
9
+ TOOTHPICK_HOME = ENV['HOME'] + "/.toothpick"
10
+ PICK_FILENAME = Date.today.strftime + ".md"
11
+
12
+ def self.init(picks_repo)
13
+ Git.clone_repo(picks_repo, TOOTHPICK_HOME)
14
+ end
15
+
16
+ def self.new_pick
17
+ abort_if_setup_not_done!
18
+ git = Git.new(TOOTHPICK_HOME)
19
+ git.update
20
+ pid = Kernel.spawn("$EDITOR #{pick_file_path}")
21
+ Process.waitpid(pid)
22
+ if $?.success? and File.exists?(pick_file_path)
23
+ git.commit
24
+ git.push
25
+ end
26
+ end
27
+
28
+ def self.search(string)
29
+ abort_if_setup_not_done!
30
+ Search.new(TOOTHPICK_HOME, string)
31
+ end
32
+
33
+ private
34
+
35
+ def self.abort_if_setup_not_done!
36
+ unless Git.on_git?(TOOTHPICK_HOME)
37
+ raise Errors::ToothpickNotInitialized,
38
+ "You need to run 'toothpick init' first"
39
+ end
40
+ end
41
+
42
+ def self.pick_file_path
43
+ File.join(TOOTHPICK_HOME, PICK_FILENAME)
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,6 @@
1
+ module Toothpick
2
+ module Errors
3
+ class ToothpickError < StandardError; end;
4
+ class ToothpickNotInitialized < ToothpickError; end;
5
+ end
6
+ end
@@ -0,0 +1,33 @@
1
+ module Toothpick
2
+ class Git
3
+
4
+ attr_reader :git_dir
5
+
6
+ def self.clone_repo(repo, target_dir)
7
+ system("git clone #{repo} #{target_dir}")
8
+ end
9
+
10
+ def self.on_git?(dir)
11
+ return system("cd #{dir} && git rev-parse --git-dir")
12
+ end
13
+
14
+ def initialize(git_dir)
15
+ @git_dir = git_dir
16
+ end
17
+
18
+ def update
19
+ system("cd #{git_dir} && git pull --rebase")
20
+ end
21
+
22
+ def commit
23
+ system("cd #{git_dir} "\
24
+ "&& git add --all "\
25
+ "&& git commit --allow-empty-message -m ''")
26
+ end
27
+
28
+ def push
29
+ system("cd #{git_dir} && git push origin master")
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ module Toothpick
2
+ class Search
3
+
4
+ def initialize(picks_dir, string)
5
+ # Works only with the_silver_searcher for now
6
+ unless `cd #{picks_dir} && ag --version`.nil?
7
+ space_separated_filenames = `ag -l #{string}`
8
+ unless space_separated_filenames.empty?
9
+ system("$EDITOR #{space_separated_filenames}")
10
+ end
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Toothpick
2
+ VERSION = "0.0.1"
3
+ end
data/toothpick.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'toothpick/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "toothpick"
8
+ spec.version = Toothpick::VERSION
9
+ spec.authors = ["Emil Soman"]
10
+ spec.email = ["emil.soman@gmail.com"]
11
+ spec.description = %q{For the art of picking}
12
+ spec.summary = %q{Easily create and share your picks over git}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "pry"
24
+ spec.add_dependency "thor"
25
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: toothpick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Emil Soman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-18 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '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'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: For the art of picking
70
+ email:
71
+ - emil.soman@gmail.com
72
+ executables:
73
+ - toothpick
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/toothpick
83
+ - lib/toothpick.rb
84
+ - lib/toothpick/commands.rb
85
+ - lib/toothpick/errors.rb
86
+ - lib/toothpick/git.rb
87
+ - lib/toothpick/search.rb
88
+ - lib/toothpick/version.rb
89
+ - toothpick.gemspec
90
+ homepage: ''
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.1.11
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Easily create and share your picks over git
114
+ test_files: []
115
+ has_rdoc: