get_github_pub_keys 0.0.6 → 0.0.7

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -6
  3. data/lib/get_github_pub_keys.rb +1 -1
  4. data/lib/get_github_pub_keys/client.rb +6 -12
  5. data/lib/get_github_pub_keys/connection.rb +3 -4
  6. data/lib/get_github_pub_keys/error.rb +1 -2
  7. data/lib/get_github_pub_keys/file.rb +19 -0
  8. data/lib/get_github_pub_keys/response.rb +1 -2
  9. data/lib/get_github_pub_keys/response/raise_error.rb +2 -2
  10. data/lib/get_github_pub_keys/version.rb +1 -1
  11. data/spec/get_github_pub_keys/connection_spec.rb +10 -0
  12. data/{test/dummy/log/development.log → spec/get_github_pub_keys/request_spec.rb} +0 -0
  13. data/spec/spec_helper.rb +18 -0
  14. metadata +22 -152
  15. data/lib/get_github_pub_keys/files.rb +0 -25
  16. data/test/dummy/5493704_20140505 +0 -1
  17. data/test/dummy/5493704_20140505.pub +0 -1
  18. data/test/dummy/5493704_20140505210112.pub +0 -1
  19. data/test/dummy/5971290_20140505 +0 -1
  20. data/test/dummy/5971290_20140505.pub +0 -1
  21. data/test/dummy/5971290_20140505210112.pub +0 -1
  22. data/test/dummy/7825422_20140505 +0 -1
  23. data/test/dummy/7825422_20140505.pub +0 -1
  24. data/test/dummy/7825422_20140505210112.pub +0 -1
  25. data/test/dummy/README.rdoc +0 -28
  26. data/test/dummy/Rakefile +0 -6
  27. data/test/dummy/app/assets/javascripts/application.js +0 -13
  28. data/test/dummy/app/assets/javascripts/index.js +0 -2
  29. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  30. data/test/dummy/app/assets/stylesheets/index.css +0 -4
  31. data/test/dummy/app/controllers/application_controller.rb +0 -5
  32. data/test/dummy/app/controllers/index_controller.rb +0 -3
  33. data/test/dummy/app/helpers/application_helper.rb +0 -2
  34. data/test/dummy/app/helpers/index_helper.rb +0 -2
  35. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  36. data/test/dummy/bin/bundle +0 -3
  37. data/test/dummy/bin/rails +0 -4
  38. data/test/dummy/bin/rake +0 -4
  39. data/test/dummy/config.ru +0 -4
  40. data/test/dummy/config/application.rb +0 -23
  41. data/test/dummy/config/boot.rb +0 -5
  42. data/test/dummy/config/database.yml +0 -25
  43. data/test/dummy/config/environment.rb +0 -5
  44. data/test/dummy/config/environments/development.rb +0 -37
  45. data/test/dummy/config/environments/production.rb +0 -83
  46. data/test/dummy/config/environments/test.rb +0 -39
  47. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  48. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  49. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  50. data/test/dummy/config/initializers/inflections.rb +0 -16
  51. data/test/dummy/config/initializers/mime_types.rb +0 -4
  52. data/test/dummy/config/initializers/session_store.rb +0 -3
  53. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  54. data/test/dummy/config/locales/en.yml +0 -23
  55. data/test/dummy/config/routes.rb +0 -56
  56. data/test/dummy/config/secrets.yml +0 -22
  57. data/test/dummy/public/404.html +0 -67
  58. data/test/dummy/public/422.html +0 -67
  59. data/test/dummy/public/500.html +0 -66
  60. data/test/dummy/public/favicon.ico +0 -0
  61. data/test/dummy/test/controllers/index_controller_test.rb +0 -7
  62. data/test/dummy/test/helpers/index_helper_test.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 879e045976343de429fc2d04c19e2166c7dee8f9
4
- data.tar.gz: b020f340a931f1f45d13e4b8670167ebc3ddb626
3
+ metadata.gz: 6580f1385b360e0462f5d38de71772698d23d7c6
4
+ data.tar.gz: 5189d820dd44757a312ca52a11147efa04e10a9d
5
5
  SHA512:
6
- metadata.gz: 5fca0dd38ca647f2a1dafb52dc4144eec7b44bc800f7094764fd8189e67c170beaecb5fb8481c04c85896a31d825223f88c7e43c9a2750fc312a036a9559ceaa
7
- data.tar.gz: a2028bafc7dfd296d1a8dd8d7de4581738bc86450a9bcba0fbc1063f9ea58912c762525dab1500504ec8bc65998c8d0903bc7f40933daa841ec5fd9a123265ea
6
+ metadata.gz: e926db784c453c5a8803f45a4317657c6de5ba3d055bf5ae864931ff8a30647e1a8130efc6189d29567c3575f458e81687b240395bd1fa3253321d4ba192a0f8
7
+ data.tar.gz: a3937f52f05400bf0f8d9be884280b18c43eec4dc9e107d46d40e681c12cbc3dd8f7349ea362c05eb33ad6d9880f631f08f061f38ac9d27d9f516fa2d9995f91
data/Rakefile CHANGED
@@ -14,6 +14,9 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
+
18
+
19
+
17
20
  Bundler::GemHelper.install_tasks
18
21
 
19
22
  require 'rake/testtask'
@@ -25,11 +28,5 @@ Rake::TestTask.new(:test) do |t|
25
28
  t.verbose = false
26
29
  end
27
30
 
28
- require 'rubygems'
29
- require 'rake'
30
- require 'rspec/core/rake_task'
31
-
32
- desc "Run all specs in spec directory"
33
- Rspec::Core::RakeTask.new()
34
31
 
35
32
  task default: :spec
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'get_github_pub_keys/connection'
4
- require 'get_github_pub_keys/files'
4
+ require 'get_github_pub_keys/file'
5
5
  require 'get_github_pub_keys/client'
6
6
 
7
7
  module GetGithubPubKeys
@@ -1,29 +1,23 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module GetGithubPubKeys
4
-
5
4
  class Client
6
5
  include Connection
7
- include GetGithubPubKeys::Files
6
+ include GetGithubPubKeys::File
8
7
 
9
- def initialize(user=nil)
8
+ def initialize(user = nil)
10
9
  @user = user
11
10
  end
12
11
 
13
- def find_and_create( options = {} )
14
- response = Connection.new(options).get("users/#{@user}/keys")
12
+ def find_and_create(options = {})
13
+ response = Connection.new(options).get("users/#{@user}/keys")
15
14
  public_keys = response.body
16
15
 
17
- # FIXME:response.raise_errorが正しく動作するのかを確認する
18
- # 登録されていないUserだとfile_nameがとれない
19
16
  if public_keys.is_a? Array
20
- public_keys.each do |public_key|
21
- GetGithubPubKeys::Files.create public_key["id"], public_key["key"]
22
- end
17
+ public_keys.each { |public_key| GetGithubPubKeys::File.create public_key['id'], public_key['key'] }
23
18
  else
24
- GetGithubPubKeys::Files.create public_keys["id"], public_keys["key"]
19
+ GetGithubPubKeys::File.create public_keys['id'], public_keys['key']
25
20
  end
26
21
  end
27
22
  end
28
23
  end
29
-
@@ -4,15 +4,14 @@ require 'faraday_middleware'
4
4
 
5
5
  module GetGithubPubKeys
6
6
  module Connection
7
- def self.new( options = {} )
8
- Faraday.new( url: 'https://api.github.com' ) do |faraday|
7
+ def self.new(option)
8
+ Faraday.new(url: 'https://api.github.com') do |faraday|
9
9
  faraday.request :url_encoded
10
10
  faraday.request :json
11
- faraday.response :json, :content_type => /\bjson$/
11
+ faraday.response :json, content_type: /\bjson$/
12
12
  faraday.response :logger
13
13
  faraday.adapter Faraday.default_adapter
14
14
  end
15
15
  end
16
16
  end
17
17
  end
18
-
@@ -5,7 +5,7 @@ module GetGithubPubKeys
5
5
  Error = Class.new(StandardError)
6
6
 
7
7
  ClientError = Class.new(Error)
8
-
8
+
9
9
  BadRequest = Class.new(ClientError)
10
10
 
11
11
  NotAuthorized = Class.new(ClientError)
@@ -20,4 +20,3 @@ module GetGithubPubKeys
20
20
 
21
21
  ServiceUnavailable = Class.new(ServerError)
22
22
  end
23
-
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+
3
+ module GetGithubPubKeys
4
+ module File
5
+ DEFAULT_SSH_DIRECTORY = "/#{ENV['HOME']}/.ssh".freeze
6
+ DEFAULT_IDENTIFY = '.pub'.freeze
7
+ def self.create(file_name, body)
8
+ file_name = ::File.basename(file_name.to_s)
9
+ file_name = file_name + '_' + Time.now.strftime('%Y%0m%0d%0H%0M%0S') + DEFAULT_IDENTIFY
10
+ body.chomp!
11
+ ::File.open(DEFAULT_SSH_DIRECTORY + '/' + file_name, 'w') do |file|
12
+ file.puts body
13
+ end
14
+ puts "Create public_key file: #{file_name}."
15
+ rescue => e
16
+ abort e.message
17
+ end
18
+ end
19
+ end
@@ -4,5 +4,4 @@ require 'faraday'
4
4
  require 'get_github_pub_keys/response/raise_error'
5
5
 
6
6
  Faraday.register_middleware :response,
7
- raise_error: -> { GetGithubPubKeys::Response::RaiseError }
8
-
7
+ raise_error: -> { GetGithubPubKeys::Response::RaiseError }
@@ -29,13 +29,13 @@ module GetGithubPubKeys
29
29
  end
30
30
 
31
31
  private
32
-
32
+
33
33
  def error_message(env)
34
34
  body = env[:body]
35
35
  if body.nil?
36
36
  nil
37
37
  elsif body['error'] && body['error']['message']
38
- body['error']['message']
38
+ body['error']['message']
39
39
  elsif body['fault'] && body['fault']['faultstring']
40
40
  body['fault']['faultstring']
41
41
  end
@@ -1,3 +1,3 @@
1
1
  module GetGithubPubKeys
2
- VERSION = "0.0.6"
2
+ VERSION = '0.0.7'.freeze
3
3
  end
@@ -0,0 +1,10 @@
1
+ # coding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'get_github_pub_keys/connection'
5
+
6
+ describe GetGithubPubKeysi::Connection do
7
+ describe '#connection' do
8
+ pending
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+
3
+
4
+ require 'get_github_pub_keys'
5
+ require 'rspec'
6
+ require 'webmock/rspec'
7
+
8
+ Rspec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ config.order = 'random'
14
+
15
+ def stube_get(path, endpoint = "https://api.github.com")
16
+ stub_request(:get, endpoint + '/' + path)
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_github_pub_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuyuki Ikeda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2017-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,50 +16,16 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.8'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.8.9
19
+ version: 0.10.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.8'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.8.9
26
+ version: 0.10.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: faraday_middleware
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: rspec-core
63
29
  requirement: !ruby/object:Gem::Requirement
64
30
  requirements:
65
31
  - - ">="
@@ -73,37 +39,31 @@ dependencies:
73
39
  - !ruby/object:Gem::Version
74
40
  version: '0'
75
41
  - !ruby/object:Gem::Dependency
76
- name: rails
42
+ name: rspec
77
43
  requirement: !ruby/object:Gem::Requirement
78
44
  requirements:
79
45
  - - "~>"
80
46
  - !ruby/object:Gem::Version
81
- version: '4.0'
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: 4.0.4
47
+ version: '3.5'
85
48
  type: :development
86
49
  prerelease: false
87
50
  version_requirements: !ruby/object:Gem::Requirement
88
51
  requirements:
89
52
  - - "~>"
90
53
  - !ruby/object:Gem::Version
91
- version: '4.0'
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: 4.0.4
54
+ version: '3.5'
95
55
  - !ruby/object:Gem::Dependency
96
- name: sqlite3
56
+ name: rake
97
57
  requirement: !ruby/object:Gem::Requirement
98
58
  requirements:
99
- - - "~>"
59
+ - - ">="
100
60
  - !ruby/object:Gem::Version
101
61
  version: '0'
102
62
  type: :development
103
63
  prerelease: false
104
64
  version_requirements: !ruby/object:Gem::Requirement
105
65
  requirements:
106
- - - "~>"
66
+ - - ">="
107
67
  - !ruby/object:Gem::Version
108
68
  version: '0'
109
69
  description: This gem get publick_keys from registered of github.
@@ -113,65 +73,20 @@ executables: []
113
73
  extensions: []
114
74
  extra_rdoc_files: []
115
75
  files:
76
+ - MIT-LICENSE
77
+ - Rakefile
78
+ - lib/get_github_pub_keys.rb
116
79
  - lib/get_github_pub_keys/client.rb
117
80
  - lib/get_github_pub_keys/connection.rb
118
81
  - lib/get_github_pub_keys/error.rb
119
- - lib/get_github_pub_keys/files.rb
120
- - lib/get_github_pub_keys/response/raise_error.rb
82
+ - lib/get_github_pub_keys/file.rb
121
83
  - lib/get_github_pub_keys/response.rb
84
+ - lib/get_github_pub_keys/response/raise_error.rb
122
85
  - lib/get_github_pub_keys/version.rb
123
- - lib/get_github_pub_keys.rb
124
86
  - lib/tasks/get_github_pub_keys_tasks.rake
125
- - MIT-LICENSE
126
- - Rakefile
127
- - test/dummy/5493704_20140505
128
- - test/dummy/5493704_20140505.pub
129
- - test/dummy/5493704_20140505210112.pub
130
- - test/dummy/5971290_20140505
131
- - test/dummy/5971290_20140505.pub
132
- - test/dummy/5971290_20140505210112.pub
133
- - test/dummy/7825422_20140505
134
- - test/dummy/7825422_20140505.pub
135
- - test/dummy/7825422_20140505210112.pub
136
- - test/dummy/app/assets/javascripts/application.js
137
- - test/dummy/app/assets/javascripts/index.js
138
- - test/dummy/app/assets/stylesheets/application.css
139
- - test/dummy/app/assets/stylesheets/index.css
140
- - test/dummy/app/controllers/application_controller.rb
141
- - test/dummy/app/controllers/index_controller.rb
142
- - test/dummy/app/helpers/application_helper.rb
143
- - test/dummy/app/helpers/index_helper.rb
144
- - test/dummy/app/views/layouts/application.html.erb
145
- - test/dummy/bin/bundle
146
- - test/dummy/bin/rails
147
- - test/dummy/bin/rake
148
- - test/dummy/config/application.rb
149
- - test/dummy/config/boot.rb
150
- - test/dummy/config/database.yml
151
- - test/dummy/config/environment.rb
152
- - test/dummy/config/environments/development.rb
153
- - test/dummy/config/environments/production.rb
154
- - test/dummy/config/environments/test.rb
155
- - test/dummy/config/initializers/backtrace_silencers.rb
156
- - test/dummy/config/initializers/cookies_serializer.rb
157
- - test/dummy/config/initializers/filter_parameter_logging.rb
158
- - test/dummy/config/initializers/inflections.rb
159
- - test/dummy/config/initializers/mime_types.rb
160
- - test/dummy/config/initializers/session_store.rb
161
- - test/dummy/config/initializers/wrap_parameters.rb
162
- - test/dummy/config/locales/en.yml
163
- - test/dummy/config/routes.rb
164
- - test/dummy/config/secrets.yml
165
- - test/dummy/config.ru
166
- - test/dummy/log/development.log
167
- - test/dummy/public/404.html
168
- - test/dummy/public/422.html
169
- - test/dummy/public/500.html
170
- - test/dummy/public/favicon.ico
171
- - test/dummy/Rakefile
172
- - test/dummy/README.rdoc
173
- - test/dummy/test/controllers/index_controller_test.rb
174
- - test/dummy/test/helpers/index_helper_test.rb
87
+ - spec/get_github_pub_keys/connection_spec.rb
88
+ - spec/get_github_pub_keys/request_spec.rb
89
+ - spec/spec_helper.rb
175
90
  homepage: https://github.com/kikeda1104/get_github_pub_keys
176
91
  licenses:
177
92
  - MIT
@@ -192,56 +107,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
107
  version: '0'
193
108
  requirements: []
194
109
  rubyforge_project:
195
- rubygems_version: 2.1.3
110
+ rubygems_version: 2.6.8
196
111
  signing_key:
197
112
  specification_version: 4
198
113
  summary: The gem get public_keys from github
199
114
  test_files:
200
- - test/dummy/5493704_20140505
201
- - test/dummy/5493704_20140505.pub
202
- - test/dummy/5493704_20140505210112.pub
203
- - test/dummy/5971290_20140505
204
- - test/dummy/5971290_20140505.pub
205
- - test/dummy/5971290_20140505210112.pub
206
- - test/dummy/7825422_20140505
207
- - test/dummy/7825422_20140505.pub
208
- - test/dummy/7825422_20140505210112.pub
209
- - test/dummy/app/assets/javascripts/application.js
210
- - test/dummy/app/assets/javascripts/index.js
211
- - test/dummy/app/assets/stylesheets/application.css
212
- - test/dummy/app/assets/stylesheets/index.css
213
- - test/dummy/app/controllers/application_controller.rb
214
- - test/dummy/app/controllers/index_controller.rb
215
- - test/dummy/app/helpers/application_helper.rb
216
- - test/dummy/app/helpers/index_helper.rb
217
- - test/dummy/app/views/layouts/application.html.erb
218
- - test/dummy/bin/bundle
219
- - test/dummy/bin/rails
220
- - test/dummy/bin/rake
221
- - test/dummy/config/application.rb
222
- - test/dummy/config/boot.rb
223
- - test/dummy/config/database.yml
224
- - test/dummy/config/environment.rb
225
- - test/dummy/config/environments/development.rb
226
- - test/dummy/config/environments/production.rb
227
- - test/dummy/config/environments/test.rb
228
- - test/dummy/config/initializers/backtrace_silencers.rb
229
- - test/dummy/config/initializers/cookies_serializer.rb
230
- - test/dummy/config/initializers/filter_parameter_logging.rb
231
- - test/dummy/config/initializers/inflections.rb
232
- - test/dummy/config/initializers/mime_types.rb
233
- - test/dummy/config/initializers/session_store.rb
234
- - test/dummy/config/initializers/wrap_parameters.rb
235
- - test/dummy/config/locales/en.yml
236
- - test/dummy/config/routes.rb
237
- - test/dummy/config/secrets.yml
238
- - test/dummy/config.ru
239
- - test/dummy/log/development.log
240
- - test/dummy/public/404.html
241
- - test/dummy/public/422.html
242
- - test/dummy/public/500.html
243
- - test/dummy/public/favicon.ico
244
- - test/dummy/Rakefile
245
- - test/dummy/README.rdoc
246
- - test/dummy/test/controllers/index_controller_test.rb
247
- - test/dummy/test/helpers/index_helper_test.rb
115
+ - spec/get_github_pub_keys/connection_spec.rb
116
+ - spec/get_github_pub_keys/request_spec.rb
117
+ - spec/spec_helper.rb
@@ -1,25 +0,0 @@
1
- # coding: utf-8
2
- # FIXME: 定数値を別のファイルにまとめたい
3
-
4
- module GetGithubPubKeys
5
- module Files
6
- DEFAULT_SSH_DIRECTORY = "/#{ENV["HOME"]}/.ssh".freeze
7
- DEFAULT_IDENTIFY = '.pub'.freeze
8
- # public_keys file create to .ssh directory.
9
- def self.create(file_name, body)
10
- file_name = file_name.to_s
11
- file_name = File.basename(file_name)
12
- file_name = file_name + "_" + Time.now.strftime("%Y%0m%0d%0H%0M%0S") + DEFAULT_IDENTIFY
13
- body = body.gsub("\n","") # TODO: Windows動作未確認
14
- File.open(DEFAULT_SSH_DIRECTORY + "/" + file_name, "w") do |file|
15
- file.puts body
16
- end
17
- puts "Create public_key file: #{file_name}."
18
- rescue => e
19
- # FIXME: 例外処理
20
- puts e.message
21
- nil
22
- end
23
- end
24
- end
25
-