gistim 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cf3de881ce74a91aba2ba9f96e8245e9957b7821ead1efa8d5c7c6adc0a72c2
4
- data.tar.gz: afe882580e39e0045ed97ce8721ff3e7535de8f5bff5b3d6c53f06da65a8e0b0
3
+ metadata.gz: c28928cf1dc92cb6a9109e5006c46aea31718e09b5011b8e38f489c741d83127
4
+ data.tar.gz: 7c6a1d4d6797d02421bc388458a6c4ca17094ddc103d262e79708ad35b02ca87
5
5
  SHA512:
6
- metadata.gz: 83fda0cb20ebc15c4b9a96301071d5cb69a1675759ac444a9380b92afcbfed442dad03631f3297e9fc9afe2d5322bde29abf397d40c5e6a67333e2d5498b3cb8
7
- data.tar.gz: d909f585ff392087c38a1a00d7669db284d839bcffa6c54bdcc3c03b4b5910a719ddd1985f1fb7ad4daa3c0f7fb684340cc7dbe888eb334c41ed9f5130ee3043
6
+ metadata.gz: 8b047dee82c692140bd614751e01370e38ac270ce7abb0261de4d8814ab7178c493d0edb2220594e2914fab6205b00c34049efdb6bd96b31a652d5c09d55ac34
7
+ data.tar.gz: 862071d90863a5cee45ff380f053aedf6c16be520af07a26696b87ab80193dccd939e4ec6113fdc482beeeb141692e26bb05a27cbf32a06c6151fc6cf7ad5664
data/.github.url ADDED
@@ -0,0 +1 @@
1
+ https://github.com/YumaInaura/gistim
data/.rubygems.url ADDED
@@ -0,0 +1 @@
1
+ https://rubygems.org/gems/gistim
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gistim (0.1.0)
4
+ gistim (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -2,22 +2,39 @@
2
2
 
3
3
  ## Installation
4
4
 
5
- Add this line to your application's Gemfile:
6
-
7
- ```ruby
8
- gem 'gistim'
5
+ ```
6
+ $ gem install gistim
9
7
  ```
10
8
 
11
- And then execute:
9
+ ## Ready
12
10
 
13
- $ bundle
11
+ ```
12
+ gist --login
13
+ ```
14
14
 
15
- Or install it yourself as:
15
+ ( Not `gistim --login` )
16
16
 
17
- $ gem install gistim
17
+ And enable access to github by git protocol.
18
18
 
19
19
  ## Usage
20
20
 
21
+ We can clone both specify hash or URL.
22
+
23
+ ```
24
+ gistim clone 32b6d6ba379d4a65d22c06e3f8d284c0
25
+ ```
26
+
27
+ ```
28
+ gistim clone https://gist.github.com/YumaInaura/32b6d6ba379d4a65d22c06e3f8d284c0
29
+ ```
30
+
31
+ Even if you specify https URL gistim clone by git protocol. Because we can push to Gist repository by git protocol.
32
+
33
+ We can specifiy directory name.
34
+
35
+ ```
36
+ gistim clone https://gist.github.com/YumaInaura/32b6d6ba379d4a65d22c06e3f8d284c0 mac_replace_clipboard
37
+ ```
21
38
 
22
39
  ## Development
23
40
 
data/exe/gistim CHANGED
@@ -1,11 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'pry'
4
+ require 'gistim'
5
+
3
6
  subcommand = ARGV[0]
4
7
 
5
8
  if subcommand == 'clone'
6
- hash = ARGV[1].match(/[a-z0-9]+\z/)[0]
7
- clone_directory = ARGV[2] || ''
8
- `git clone git@gist.github.com:#{hash} #{clone_directory}`
9
+ Gistim::Clone.clone(ARGV[1], clone_directory: ARGV[2])
10
+ elsif subcommand == 'create'
11
+ Gistim::Create.new(alias_name: ARGV[1]).create
12
+ else
13
+ puts <<~TEXT
14
+ =====================================
15
+ $ gistim command delegated to $ gist command
16
+ =====================================
17
+ TEXT
18
+ puts `gist #{ARGV.join(' ')}`
9
19
  end
10
20
 
11
-
@@ -0,0 +1,11 @@
1
+ module Gistim
2
+ class Clone
3
+ def initialize(alias_name: nil)
4
+ end
5
+
6
+ def self.clone(hash_or_url, clone_directory: nil)
7
+ hash = hash_or_url.match(/[a-z0-9]+\z/)[0]
8
+ `git clone git@gist.github.com:#{hash} #{clone_directory}`
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,58 @@
1
+ module Gistim
2
+ class Create
3
+ def initialize(alias_name: nil)
4
+ @alias_name = alias_name
5
+ end
6
+
7
+ attr_reader :alias_name
8
+
9
+ def create
10
+ File.write(initialize_file_path, 'Wellcome to Gist! ( created by gistim )')
11
+
12
+ create_empty
13
+ clone
14
+
15
+ 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
+
21
+ self
22
+ end
23
+
24
+ def gist_hash
25
+ gist_url.chomp.gsub(/\A.+\//, '')
26
+ end
27
+
28
+ private
29
+
30
+ def clone
31
+ Clone.clone(gist_url, clone_directory: clone_directory)
32
+ end
33
+
34
+ def create_empty
35
+ # Execute `$ gist [some_file]` command and get gist url result
36
+ @gist_url ||= `gist #{initialize_file_path}`.chomp
37
+ end
38
+
39
+ def gist_url
40
+ @gist_url ||= create_empty
41
+ end
42
+
43
+ def initialize_file_path
44
+ '.gistim.tmp'
45
+ end
46
+
47
+ def clone_directory
48
+ alias_name || gist_hash
49
+ end
50
+
51
+ # public
52
+ class << self
53
+ def implement
54
+ self.class.new.create
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,3 +1,3 @@
1
1
  module Gistim
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/gistim.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require "gistim/version"
2
+ require 'gist'
3
+ require 'gistim/clone'
4
+ require 'gistim/create'
2
5
 
3
6
  module Gistim
4
- # Your code goes here...
5
7
  end
8
+
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.1.0
4
+ version: 0.1.1
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-14 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gist
@@ -88,8 +88,10 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
+ - ".github.url"
91
92
  - ".gitignore"
92
93
  - ".rspec"
94
+ - ".rubygems.url"
93
95
  - ".travis.yml"
94
96
  - CODE_OF_CONDUCT.md
95
97
  - Gemfile
@@ -102,6 +104,8 @@ files:
102
104
  - exe/gistim
103
105
  - gistim.gemspec
104
106
  - lib/gistim.rb
107
+ - lib/gistim/clone.rb
108
+ - lib/gistim/create.rb
105
109
  - lib/gistim/version.rb
106
110
  homepage: https://github.com/YumaInaura/gistim
107
111
  licenses: