toothpick 0.0.1 → 0.0.2
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 +8 -8
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/README.md +4 -4
- data/Rakefile +6 -0
- data/lib/toothpick/commands.rb +5 -2
- data/lib/toothpick/git.rb +5 -1
- data/lib/toothpick/search.rb +1 -1
- data/lib/toothpick/version.rb +1 -1
- data/spec/commands_spec.rb +51 -0
- data/spec/git_spec.rb +63 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/fake_env.rb +2 -0
- data/spec/support/git_shared_examples.rb +8 -0
- data/spec/support/mock_process_spawn.rb +0 -0
- data/spec/support/pickfile_shared_examples.rb +12 -0
- data/toothpick.gemspec +1 -0
- metadata +33 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmYzYmU2NjJmZTg2MWU2NTNjNWE5OTI1ZDNhMmI3ODNlMmEzMjE5Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDM2YWM0NjVjMDRkN2NkYzVjMDMzYjgzZmM4NmQ3MGJlOTI4ZDlmMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDZiNjQ5YmE3MWZkM2U3ZjE0MTQxODRmYTUyNDdmZjQ5ZmJiZWJjNGRhYWI2
|
10
|
+
N2FmNTcyYjI4NzIxM2Y4MmIwZGQ3Y2Q5NzA4NTM2NjE1Mjk4ZWI3YWY2MjFk
|
11
|
+
MDM5N2ZhNmQ3ZGU4MDgwOTc4YmYxNzg3ZmNiNjU3YjBiYjFiZjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGQyNTUyNGM3YWY2OTA5YzJhNWIyYjBiNmJkODJkMTcwNjgxM2UyYmJkMWNi
|
14
|
+
OTViZDExMGE4NjQ3Yzc4NjE1ZDhlYjI0OTFhZjQ3OTVjMzcwNDliNmE3ZDU5
|
15
|
+
NzEyYjQ2YWFkMzRkMzk3OTc4MmFkNDNhODVhMDVmM2M2ZmUwNjM=
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
 *For the fine art of picking*
|
2
|
+
|
3
|
+
[](https://travis-ci.org/code-mancers/toothpick)
|
3
4
|
|
4
|
-
For the art of picking.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -10,7 +10,7 @@ For the art of picking.
|
|
10
10
|
## Usage
|
11
11
|
|
12
12
|
#Setup toothpick
|
13
|
-
toothpick init
|
13
|
+
toothpick init git@github.com:code-mancers/picks.git
|
14
14
|
|
15
15
|
#Open today's pick file for editing
|
16
16
|
toothpick new
|
data/Rakefile
CHANGED
data/lib/toothpick/commands.rb
CHANGED
@@ -7,7 +7,6 @@ module Toothpick
|
|
7
7
|
module Commands
|
8
8
|
|
9
9
|
TOOTHPICK_HOME = ENV['HOME'] + "/.toothpick"
|
10
|
-
PICK_FILENAME = Date.today.strftime + ".md"
|
11
10
|
|
12
11
|
def self.init(picks_repo)
|
13
12
|
Git.clone_repo(picks_repo, TOOTHPICK_HOME)
|
@@ -40,7 +39,11 @@ module Toothpick
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def self.pick_file_path
|
43
|
-
File.join(TOOTHPICK_HOME,
|
42
|
+
File.join(TOOTHPICK_HOME, pick_filename)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.pick_filename
|
46
|
+
Time.now.utc.to_date.strftime + ".md"
|
44
47
|
end
|
45
48
|
|
46
49
|
end
|
data/lib/toothpick/git.rb
CHANGED
@@ -22,7 +22,11 @@ module Toothpick
|
|
22
22
|
def commit
|
23
23
|
system("cd #{git_dir} "\
|
24
24
|
"&& git add --all "\
|
25
|
-
"&& git commit
|
25
|
+
"&& git commit -m '#{make_commit_message}'")
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_commit_message
|
29
|
+
"Added pick by #{ENV['USER']} on #{Time.now}"
|
26
30
|
end
|
27
31
|
|
28
32
|
def push
|
data/lib/toothpick/search.rb
CHANGED
@@ -4,7 +4,7 @@ module Toothpick
|
|
4
4
|
def initialize(picks_dir, string)
|
5
5
|
# Works only with the_silver_searcher for now
|
6
6
|
unless `cd #{picks_dir} && ag --version`.nil?
|
7
|
-
space_separated_filenames = `ag -l #{string}
|
7
|
+
space_separated_filenames = `ag -l #{string}`.split.join(' ')
|
8
8
|
unless space_separated_filenames.empty?
|
9
9
|
system("$EDITOR #{space_separated_filenames}")
|
10
10
|
end
|
data/lib/toothpick/version.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/fake_env'
|
3
|
+
require 'support/pickfile_shared_examples'
|
4
|
+
require 'support/git_shared_examples'
|
5
|
+
require 'toothpick/commands'
|
6
|
+
|
7
|
+
describe Toothpick::Commands do
|
8
|
+
let(:git_repo) { 'git@github.com:code-mancers/picks.git' }
|
9
|
+
let(:toothpick_home) { Toothpick::Commands::TOOTHPICK_HOME }
|
10
|
+
let(:git) { double(Toothpick::Git) }
|
11
|
+
|
12
|
+
describe "::TOOTHPICK_HOME" do
|
13
|
+
it "should return .toothpick in user's home" do
|
14
|
+
expect(toothpick_home).to eql('/home/user/.toothpick')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".init" do
|
19
|
+
it "should clone the git repo" do
|
20
|
+
Toothpick::Git.should_receive(:clone_repo).with(git_repo, toothpick_home)
|
21
|
+
Toothpick::Commands::init(git_repo)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".new_pick" do
|
26
|
+
before(:each) do
|
27
|
+
end
|
28
|
+
context "when toothpick init was done" do
|
29
|
+
before(:each) do
|
30
|
+
Toothpick::Git.should_receive(:on_git?).and_return(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
include_examples "pickfile should be written successfully"
|
34
|
+
include_examples "it should update, commit and push git"
|
35
|
+
|
36
|
+
specify { Toothpick::Commands::new_pick }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when toothpick init was not done" do
|
40
|
+
before(:each) do
|
41
|
+
Toothpick::Git.should_receive(:on_git?).and_return(false)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should raise ToothpickNotInitialized error" do
|
45
|
+
Toothpick::Git.should_not_receive(:new)
|
46
|
+
expect { Toothpick::Commands::new_pick }
|
47
|
+
.to raise_error(Toothpick::Errors::ToothpickNotInitialized)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/git_spec.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'toothpick/git'
|
3
|
+
|
4
|
+
describe Toothpick::Git do
|
5
|
+
describe ".clone_repo" do
|
6
|
+
let(:repo) { 'git@github.com:code-mancers/picks.git' }
|
7
|
+
let(:target_dir) { '/home/emil' }
|
8
|
+
let(:expected_git_command) { "git clone #{repo} #{target_dir}" }
|
9
|
+
|
10
|
+
it "should git clone to target directory" do
|
11
|
+
Toothpick::Git.should_receive(:system).with(expected_git_command)
|
12
|
+
Toothpick::Git::clone_repo(repo, target_dir)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".on_git?" do
|
17
|
+
context "when directory is on git" do
|
18
|
+
it "should return true" do
|
19
|
+
Toothpick::Git.on_git?(Dir.pwd).should be_true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
context "when directory is not on git" do
|
23
|
+
it "should return false" do
|
24
|
+
Toothpick::Git.on_git?('/tmp').should be_false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "Instance methods" do
|
30
|
+
let(:git) { Toothpick::Git.new('/home/emil') }
|
31
|
+
before(:each) do
|
32
|
+
git.should_receive(:system).with(expected_git_command)
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#update" do
|
36
|
+
let(:expected_git_command) do
|
37
|
+
"cd /home/emil && git pull --rebase"
|
38
|
+
end
|
39
|
+
it "should git pull --rebase" do
|
40
|
+
git.update
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#commit" do
|
45
|
+
let(:expected_git_command) do
|
46
|
+
%r{cd /home/emil && git add --all && git commit}
|
47
|
+
end
|
48
|
+
it "should git add and commit without commit message" do
|
49
|
+
git.commit
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#push" do
|
54
|
+
let(:expected_git_command) do
|
55
|
+
"cd /home/emil && git push origin master"
|
56
|
+
end
|
57
|
+
it "should git push to origin master" do
|
58
|
+
git.push
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
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
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
shared_examples "pickfile should be written successfully" do
|
2
|
+
before(:each) do
|
3
|
+
today_in_utc = Time.now.utc.to_date.strftime
|
4
|
+
|
5
|
+
Kernel.should_receive(:spawn)
|
6
|
+
.with("$EDITOR #{toothpick_home}/#{today_in_utc}.md")
|
7
|
+
.and_return('pid')
|
8
|
+
Process.should_receive(:waitpid).with('pid')
|
9
|
+
$?.should_receive(:success?).and_return(true)
|
10
|
+
File.should_receive(:exists?).and_return(true)
|
11
|
+
end
|
12
|
+
end
|
data/toothpick.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toothpick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Soman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: thor
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,6 +89,8 @@ extensions: []
|
|
75
89
|
extra_rdoc_files: []
|
76
90
|
files:
|
77
91
|
- .gitignore
|
92
|
+
- .rspec
|
93
|
+
- .travis.yml
|
78
94
|
- Gemfile
|
79
95
|
- LICENSE.txt
|
80
96
|
- README.md
|
@@ -86,6 +102,13 @@ files:
|
|
86
102
|
- lib/toothpick/git.rb
|
87
103
|
- lib/toothpick/search.rb
|
88
104
|
- lib/toothpick/version.rb
|
105
|
+
- spec/commands_spec.rb
|
106
|
+
- spec/git_spec.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
- spec/support/fake_env.rb
|
109
|
+
- spec/support/git_shared_examples.rb
|
110
|
+
- spec/support/mock_process_spawn.rb
|
111
|
+
- spec/support/pickfile_shared_examples.rb
|
89
112
|
- toothpick.gemspec
|
90
113
|
homepage: ''
|
91
114
|
licenses:
|
@@ -111,5 +134,11 @@ rubygems_version: 2.1.11
|
|
111
134
|
signing_key:
|
112
135
|
specification_version: 4
|
113
136
|
summary: Easily create and share your picks over git
|
114
|
-
test_files:
|
115
|
-
|
137
|
+
test_files:
|
138
|
+
- spec/commands_spec.rb
|
139
|
+
- spec/git_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- spec/support/fake_env.rb
|
142
|
+
- spec/support/git_shared_examples.rb
|
143
|
+
- spec/support/mock_process_spawn.rb
|
144
|
+
- spec/support/pickfile_shared_examples.rb
|