gist_updater 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -1
- data/README.md +3 -1
- data/circle.yml +1 -0
- data/disabled.yml +0 -14
- data/enabled.yml +14 -0
- data/gist_updater.gemspec +6 -2
- data/lib/gist_updater/commands.rb +7 -0
- data/lib/gist_updater/config.rb +9 -0
- data/lib/gist_updater/content.rb +12 -0
- data/lib/gist_updater/debug.rb +1 -0
- data/lib/gist_updater/updater.rb +9 -0
- data/lib/gist_updater/version.rb +1 -1
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f08ce131e4b5da439fd9dbec0b196211d65bdc3d
|
4
|
+
data.tar.gz: c0ae0fddb076a17467d9bf7e795f6e60599a4459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8dee73553e37d1549b2267c97235a23a292b21cf723aa2bb82e9323abb1a2f8a979beb5c9b38f33c41d130e78837bf1dbbc748f8f5450b4730065363c75b59e
|
7
|
+
data.tar.gz: dc6bddcafd3b4855787cdc6c661946c1b6414146ad2c0be0ab8c47b09a0a6935246a0dda6b6021bb7094d2d13e6e0eabf699ea01aff73a5bf86c24442fe43f4f
|
data/.rspec
CHANGED
data/README.md
CHANGED
data/circle.yml
CHANGED
data/disabled.yml
CHANGED
@@ -23,20 +23,6 @@ Style/Copyright:
|
|
23
23
|
Description: 'Include a copyright notice in each file before any code.'
|
24
24
|
Enabled: false
|
25
25
|
|
26
|
-
Style/Documentation:
|
27
|
-
Description: 'Document classes and non-namespace modules.'
|
28
|
-
Enabled: false
|
29
|
-
Exclude:
|
30
|
-
- 'spec/**/*'
|
31
|
-
- 'test/**/*'
|
32
|
-
|
33
|
-
Style/DocumentationMethod:
|
34
|
-
Description: 'Public methods.'
|
35
|
-
Enabled: false
|
36
|
-
Exclude:
|
37
|
-
- 'spec/**/*'
|
38
|
-
- 'test/**/*'
|
39
|
-
|
40
26
|
Style/Encoding:
|
41
27
|
Description: 'Use UTF-8 as the source file encoding.'
|
42
28
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#utf-8'
|
data/enabled.yml
CHANGED
@@ -176,6 +176,20 @@ Style/PreferredHashMethods:
|
|
176
176
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key'
|
177
177
|
Enabled: true
|
178
178
|
|
179
|
+
Style/Documentation:
|
180
|
+
Description: 'Document classes and non-namespace modules.'
|
181
|
+
Enabled: true
|
182
|
+
Exclude:
|
183
|
+
- 'spec/**/*'
|
184
|
+
- 'test/**/*'
|
185
|
+
|
186
|
+
Style/DocumentationMethod:
|
187
|
+
Description: 'Public methods.'
|
188
|
+
Enabled: true
|
189
|
+
Exclude:
|
190
|
+
- 'spec/**/*'
|
191
|
+
- 'test/**/*'
|
192
|
+
|
179
193
|
Style/DotPosition:
|
180
194
|
Description: 'Checks the position of the dot in multi-line method calls.'
|
181
195
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
|
data/gist_updater.gemspec
CHANGED
@@ -10,8 +10,11 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ['Takashi Masuda']
|
11
11
|
spec.email = ['masutaka.net@gmail.com']
|
12
12
|
|
13
|
-
spec.summary = 'Updates your Gist files'
|
14
|
-
spec.description =
|
13
|
+
spec.summary = 'Updates your Gist files defined in YAML'
|
14
|
+
spec.description = <<~EOS
|
15
|
+
Updates your Gist files defined in YAML.
|
16
|
+
For example, it's useful for syncing GitHub and Gist in CI.
|
17
|
+
EOS
|
15
18
|
spec.homepage = 'https://github.com/masutaka/gist_updater'
|
16
19
|
spec.license = 'MIT'
|
17
20
|
|
@@ -29,4 +32,5 @@ Gem::Specification.new do |spec|
|
|
29
32
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
34
|
spec.add_development_dependency 'rubocop', '~> 0.43.0'
|
35
|
+
spec.add_development_dependency 'yard', '~> 0.9.5'
|
32
36
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'thor'
|
4
4
|
|
5
5
|
module GistUpdater
|
6
|
+
# CLI Interface
|
6
7
|
class Commands < Thor
|
7
8
|
package_name 'gist_updater'
|
8
9
|
default_task :update
|
@@ -17,11 +18,17 @@ module GistUpdater
|
|
17
18
|
desc: 'Debug mode', default: false
|
18
19
|
|
19
20
|
desc 'update', 'Update your Gist files (default)'
|
21
|
+
# CLI Interface to update your Gist
|
22
|
+
#
|
23
|
+
# @return (see GistUpdater::Updater#update)
|
20
24
|
def update
|
21
25
|
Updater.new(options).update
|
22
26
|
end
|
23
27
|
|
24
28
|
desc 'version', 'Display version'
|
29
|
+
# CLI Interface to display version
|
30
|
+
#
|
31
|
+
# @return (see Kernel.puts)
|
25
32
|
def version
|
26
33
|
puts VERSION
|
27
34
|
end
|
data/lib/gist_updater/config.rb
CHANGED
@@ -3,11 +3,20 @@
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
module GistUpdater
|
6
|
+
# User configuration
|
6
7
|
class Config
|
8
|
+
# @param file [String] a YAML file path
|
7
9
|
def initialize(file)
|
8
10
|
@file = file
|
9
11
|
end
|
10
12
|
|
13
|
+
# Calls block once for each element in config
|
14
|
+
#
|
15
|
+
# @yield [gist_id:, file_paths:] Gist file paths
|
16
|
+
# @yieldparam gist_id [String] a Gist id
|
17
|
+
# @yieldparam file_paths [Array<String>] file paths
|
18
|
+
# @yieldreturn [Array]
|
19
|
+
# @return [Enumerator]
|
11
20
|
def each
|
12
21
|
return enum_for(:each) unless block_given?
|
13
22
|
|
data/lib/gist_updater/content.rb
CHANGED
@@ -3,7 +3,12 @@
|
|
3
3
|
require 'octokit'
|
4
4
|
|
5
5
|
module GistUpdater
|
6
|
+
# A content related to a gist file
|
6
7
|
class Content
|
8
|
+
# @param user [String] GitHub username
|
9
|
+
# @param access_token [String] GitHub personal access token
|
10
|
+
# @param gist_id [String] A gist id
|
11
|
+
# @param file_path [String] A relative file path
|
7
12
|
def initialize(user:, access_token:, gist_id:, file_path:)
|
8
13
|
@user = user
|
9
14
|
@access_token = access_token
|
@@ -11,6 +16,10 @@ module GistUpdater
|
|
11
16
|
@file_path = file_path
|
12
17
|
end
|
13
18
|
|
19
|
+
# Update the content if needed
|
20
|
+
#
|
21
|
+
# @return [Sawyer::Resource] an updated resource
|
22
|
+
# @return [NilClass] isnot updated
|
14
23
|
def update_if_need
|
15
24
|
if need_to_update?
|
16
25
|
result = update
|
@@ -42,6 +51,9 @@ module GistUpdater
|
|
42
51
|
@local ||= File.read(file_path)
|
43
52
|
end
|
44
53
|
|
54
|
+
# Update a Gist file
|
55
|
+
#
|
56
|
+
# @return [Sawyer::Resource]
|
45
57
|
def update
|
46
58
|
client.edit_gist(
|
47
59
|
gist_id,
|
data/lib/gist_updater/debug.rb
CHANGED
data/lib/gist_updater/updater.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module GistUpdater
|
4
|
+
# Updates according to user configuration
|
4
5
|
class Updater
|
6
|
+
# @param options [Hash] options generated by Thor
|
7
|
+
# @param config_class [Class] a Class which has configuration duty
|
5
8
|
def initialize(options, config_class = Config)
|
6
9
|
@user = options[:user] || ENV['GISTUPDATER_USER']
|
7
10
|
@access_token = options[:token] || ENV['GISTUPDATER_ACCESS_TOKEN']
|
@@ -9,6 +12,9 @@ module GistUpdater
|
|
9
12
|
GistUpdater.debug = options[:debug]
|
10
13
|
end
|
11
14
|
|
15
|
+
# Update your Gist
|
16
|
+
#
|
17
|
+
# @return [Fixnum] Updated count
|
12
18
|
def update
|
13
19
|
count = 0
|
14
20
|
|
@@ -25,6 +31,9 @@ module GistUpdater
|
|
25
31
|
|
26
32
|
attr_reader :user, :access_token, :config
|
27
33
|
|
34
|
+
# Update a Gist file
|
35
|
+
#
|
36
|
+
# @return (see GistUpdater::Content#update_if_need)
|
28
37
|
def update_by_gist(id, file_path)
|
29
38
|
Content.new(
|
30
39
|
user: user,
|
data/lib/gist_updater/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gist_updater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Masuda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -94,7 +94,23 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.43.0
|
97
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.9.5
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.9.5
|
111
|
+
description: |
|
112
|
+
Updates your Gist files defined in YAML.
|
113
|
+
For example, it's useful for syncing GitHub and Gist in CI.
|
98
114
|
email:
|
99
115
|
- masutaka.net@gmail.com
|
100
116
|
executables:
|
@@ -149,5 +165,5 @@ rubyforge_project:
|
|
149
165
|
rubygems_version: 2.5.1
|
150
166
|
signing_key:
|
151
167
|
specification_version: 4
|
152
|
-
summary: Updates your Gist files
|
168
|
+
summary: Updates your Gist files defined in YAML
|
153
169
|
test_files: []
|