gist_directory 0.1.1 → 0.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -4
  3. data/lib/gist_directory.rb +16 -9
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0080a71489798fc02f6e2a875949d6b490dc5ab9
4
- data.tar.gz: f2216c59729f4a82451b568214bc78a1299ac892
3
+ metadata.gz: d88c4f62cd37050e8b94e536bd110f51216e46c0
4
+ data.tar.gz: 7c10015a6af1395f36688679eb00f5840f309a2c
5
5
  SHA512:
6
- metadata.gz: 9d348e279867f93f0911e24fcac2a8526e9bafcc6946f91acad84180a037b16bed1cb8d414d0d775e468127a7368adedaf98b953272498e09833dc6b3a9ed935
7
- data.tar.gz: b362c710f3887e208150d6fb9782aef57452ad0c01161c425bd0c243b4c98162e9dcb2ffe016b43bc03c4f7c04f75da227e6c02596d561139fdc1ce9592e8c54
6
+ metadata.gz: e1b510bf17b3958036d7ef1bfd6758d897c472f7e49bf8b786c4668596e43191c1a9c6fd6f42490f44c9c98d6ea67cef2f71ff8e04779d9fe869546cbcefa7f9
7
+ data.tar.gz: b1ecbd3aeeda1abbf3ecc89d41877524c598681f3debe51784014200177c5e6085725b106ae1266698133e5eb5d436da550a753cff22590647301dc2b412cf5a
data/README.md CHANGED
@@ -1,11 +1,22 @@
1
- # gist_directory
1
+ # `gist_directory`
2
2
 
3
3
  Create and maintain collections of public gists in a local directory
4
4
 
5
5
  # Dependencies
6
6
 
7
- ```
8
- npm install gulp-octodown-livereload
7
+ In order to view files while you're editing them, you'll need
8
+ [gulp-octodown-livereload][gulp-octodown-livereload].
9
+
10
+ [gulp-octodown-livereload]: https://github.com/joeyates/gulp-octodown-livereload
11
+
12
+ (The following assumes you have a `~/bin` directory and that it's in your
13
+ `PATH`)
14
+
15
+ ```shell
16
+ gem install octodown
17
+ npm install -g gulp-octodown-livereload
18
+ cd ~/bin
19
+ ln -s /usr/local/lib/node_modules/gulp-octodown-livereload/bin/gulp-octodown-livereload
9
20
  ```
10
21
 
11
22
  # Usage
@@ -23,7 +34,7 @@ Edit in your favourite editor (creating if necessary):
23
34
  gist_directory edit ~/food/bacon.md
24
35
  ```
25
36
 
26
- View compiled Markdown in your browser (ith livereload):
37
+ View compiled Markdown in your browser (with livereload):
27
38
 
28
39
  ```shell
29
40
  gist_directory view ~/food/bacon.md
@@ -12,7 +12,12 @@ class GistFile
12
12
  if ! File.directory?(path)
13
13
  create_gist
14
14
  else
15
- create_file_if_missing
15
+ if exists?
16
+ add_if_not_in_repo
17
+ else
18
+ create_empty_file pathname
19
+ add
20
+ end
16
21
  end
17
22
  end
18
23
 
@@ -36,18 +41,16 @@ class GistFile
36
41
  Git.clone("git@gist.github.com:#{gist_hash}", path)
37
42
  end
38
43
 
39
- def create_file_if_missing
40
- raise "The file #{pathname} already exists" if exists?
41
- create_empty_file pathname
42
- add
43
- end
44
-
45
44
  def create_empty_file(pathname)
46
45
  File.open(pathname, "w") { |f| f.puts content_for_empty_file }
47
46
  end
48
47
 
48
+ def add_if_not_in_repo
49
+ files = git.ls_files.keys
50
+ add if ! files.include?(basename)
51
+ end
52
+
49
53
  def add
50
- git = Git.open(path)
51
54
  git.add(pathname)
52
55
  git.commit("Added '#{basename}'")
53
56
  git.push
@@ -68,12 +71,16 @@ class GistFile
68
71
  def content_for_empty_file
69
72
  "Empty Gist"
70
73
  end
74
+
75
+ def git
76
+ @git ||= Git.open(path)
77
+ end
71
78
  end
72
79
 
73
80
  class GistDirectory
74
81
  MAJOR = 0
75
82
  MINOR = 1
76
- REVISION = 1
83
+ REVISION = 2
77
84
  VERSION = [MAJOR, MINOR, REVISION].map(&:to_s).join('.')
78
85
 
79
86
  attr_reader :filename
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gist_directory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git