gistim 0.1.1 → 0.2.0
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 +4 -4
- data/.gistim.tmp +1 -0
- data/.gitignore +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/exe/gistim +27 -3
- data/lib/command/create.rb +4 -0
- data/lib/gistim/command.rb +17 -0
- data/lib/gistim/create.rb +32 -25
- data/lib/gistim/version.rb +1 -1
- data/lib/gistim.rb +2 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84f019162ca9bc2b3c91325fd779c78e3e89bf19869730a3be4351ece6bb3fbb
|
4
|
+
data.tar.gz: d50479f09998f99993b8ae07341d42493f82c00e53036486f5565ceb4370fb6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46544d692c449d93fa7742996ee73490af6069f5e41f4610ac8df0dd632df6327d4b051f5af89267254d30c51c5b04f63a6cd8e4d2754ba3275b1ce6cd3de098
|
7
|
+
data.tar.gz: 973fe40ec2f905ac6483d3b3393752c9ef73a8b4a7dc8af2ca96ee80f8ca0649dfb8e6ad790d8424a99062b5ea534e97ee1c668b79568ca65f3aa53117e72411
|
data/.gistim.tmp
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Hello gist!
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -44,7 +44,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
44
44
|
|
45
45
|
## Contributing
|
46
46
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/YumaInaura/gistim. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
48
48
|
|
49
49
|
## License
|
50
50
|
|
data/exe/gistim
CHANGED
@@ -2,13 +2,37 @@
|
|
2
2
|
|
3
3
|
require 'pry'
|
4
4
|
require 'gistim'
|
5
|
-
|
6
5
|
subcommand = ARGV[0]
|
7
6
|
|
8
|
-
if subcommand == '
|
7
|
+
if subcommand == 'help'
|
8
|
+
puts <<~HELP
|
9
|
+
$ gistim create some_word
|
10
|
+
|
11
|
+
Crete new gist and git clone
|
12
|
+
HELP
|
13
|
+
elsif subcommand == 'clone'
|
9
14
|
Gistim::Clone.clone(ARGV[1], clone_directory: ARGV[2])
|
10
15
|
elsif subcommand == 'create'
|
11
|
-
Gistim::Create.new(alias_name: ARGV[1]).
|
16
|
+
create = Gistim::Create.new(alias_name: ARGV[1]).implement
|
17
|
+
puts "#{create.directory}"
|
18
|
+
`cd #{create.directory}` if ARGV.include? ["--cd"]
|
19
|
+
elsif ['list', 'history'].include? subcommand
|
20
|
+
require 'json'
|
21
|
+
|
22
|
+
list = `gist --list`
|
23
|
+
|
24
|
+
history_file_path = "#{Gistim::Command.home}/gist-history.txt"
|
25
|
+
File.write(history_file_path, list)
|
26
|
+
results = File.read(history_file_path).split("\n").map do |line|
|
27
|
+
[
|
28
|
+
["url", line.split(/\s/)[0]],
|
29
|
+
["description", line.split(/\s/)[1..-1].join]
|
30
|
+
].to_h
|
31
|
+
end
|
32
|
+
# FIXME: escape backslash
|
33
|
+
puts JSON.pretty_generate(results, quirks_mode: true)
|
34
|
+
elsif ['open'].include? subcommand
|
35
|
+
`open $(echo https://gist.github.com/$(git config user.username)/$(git remote -v | head -n 1 | awk '{ print $2 }' | awk -F':' '{ print $2 }'))`
|
12
36
|
else
|
13
37
|
puts <<~TEXT
|
14
38
|
=====================================
|
data/lib/gistim/create.rb
CHANGED
@@ -1,58 +1,65 @@
|
|
1
1
|
module Gistim
|
2
2
|
class Create
|
3
|
-
def initialize(alias_name: nil)
|
3
|
+
def initialize(description: nil, alias_name: nil)
|
4
4
|
@alias_name = alias_name
|
5
|
+
@description = description
|
5
6
|
end
|
6
7
|
|
7
|
-
attr_reader :alias_name
|
8
|
+
attr_reader :alias_name, :url
|
8
9
|
|
9
|
-
def
|
10
|
-
File.write(initialize_file_path,
|
10
|
+
def implement
|
11
|
+
File.write(initialize_file_path, description)
|
11
12
|
|
12
|
-
create_empty
|
13
|
+
@url = create_empty
|
13
14
|
clone
|
14
15
|
|
16
|
+
File.write(url_file_path, url)
|
17
|
+
File.write(hash_file_path, hash)
|
18
|
+
|
15
19
|
File.delete(initialize_file_path)
|
16
|
-
|
17
|
-
# FIME: write good structured work flow and good test
|
18
|
-
# File.write("#{clone_directory}/.gist.url", gist_url)
|
19
|
-
# File.write("#{clone_directory}/.gist.hash", gist_hash)
|
20
20
|
|
21
21
|
self
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
24
|
+
def hash
|
25
|
+
url.nil? ? nil : url.chomp.gsub(/\A.+\//, '')
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
|
+
def description
|
29
|
+
@description ||= '# Hello Gist!'
|
30
|
+
end
|
31
|
+
|
32
|
+
def hash_file_path
|
33
|
+
"#{directory}/.hash"
|
34
|
+
end
|
35
|
+
|
36
|
+
def url_file_path
|
37
|
+
"#{directory}/.url"
|
38
|
+
end
|
39
|
+
|
28
40
|
private
|
29
41
|
|
30
42
|
def clone
|
31
|
-
Clone.clone(
|
43
|
+
Clone.clone(url, clone_directory: directory)
|
32
44
|
end
|
33
45
|
|
34
46
|
def create_empty
|
35
47
|
# Execute `$ gist [some_file]` command and get gist url result
|
36
|
-
|
37
|
-
end
|
48
|
+
url = `gist #{initialize_file_path}`.chomp
|
38
49
|
|
39
|
-
|
40
|
-
@gist_url ||= create_empty
|
50
|
+
url
|
41
51
|
end
|
42
52
|
|
43
53
|
def initialize_file_path
|
44
|
-
'.
|
54
|
+
'GIST.md'
|
45
55
|
end
|
46
56
|
|
47
|
-
def
|
48
|
-
|
57
|
+
def directory
|
58
|
+
"#{Gistim::Command.home}/#{name}"
|
49
59
|
end
|
50
60
|
|
51
|
-
|
52
|
-
|
53
|
-
def implement
|
54
|
-
self.class.new.create
|
55
|
-
end
|
61
|
+
def name
|
62
|
+
alias_name || hash
|
56
63
|
end
|
57
64
|
end
|
58
65
|
end
|
data/lib/gistim/version.rb
CHANGED
data/lib/gistim.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gistim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yumainaura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gist
|
@@ -88,6 +88,7 @@ executables:
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
+
- ".gistim.tmp"
|
91
92
|
- ".github.url"
|
92
93
|
- ".gitignore"
|
93
94
|
- ".rspec"
|
@@ -103,8 +104,10 @@ files:
|
|
103
104
|
- bin/setup
|
104
105
|
- exe/gistim
|
105
106
|
- gistim.gemspec
|
107
|
+
- lib/command/create.rb
|
106
108
|
- lib/gistim.rb
|
107
109
|
- lib/gistim/clone.rb
|
110
|
+
- lib/gistim/command.rb
|
108
111
|
- lib/gistim/create.rb
|
109
112
|
- lib/gistim/version.rb
|
110
113
|
homepage: https://github.com/YumaInaura/gistim
|