megam_gogs 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0635014329d6e08b07821acdd1a671c1305c8fae
4
- data.tar.gz: ff70d41ae2b7f4381783ceb38640f90a5f9bd186
3
+ metadata.gz: e5d9cbbef21aa3502f4a3cdeb9214e2bef525fb1
4
+ data.tar.gz: 8680ce39fc66b2cf7c38d1ab6418a3bc3b8c4666
5
5
  SHA512:
6
- metadata.gz: c5b70ac0f3394c27ceef4fd693a3a5a756788f85ab1b2b05367a6755828b20d4fcc055b54188ec0862f0392ac22aa2f2a263fefc2cab4b2869a87e866efdf36a
7
- data.tar.gz: dcf39bb29feeec94253ea66df97496f890e67b31ff98cc2a3c0541094dd80e610aac7dd6c68c872f6eff359f569fa9a07f7d5bd076e75ed2b7f4e30072ec424e
6
+ metadata.gz: 88c8335639ad6b338d32e576df00eba9505028a172fcd31d801e84b0ee4a73ebd0a13ee292f9032ac68537ad422d4c904e66c67c5995f8105d1e41c0c329baf5
7
+ data.tar.gz: 7e833e8f0a7c16e51775e4a185b19ed8ce5e06f85a30c57e7d321f5d5858f6ffb8c3e9c22df8080dd25eca7b311105ef354dc790a7665a66aa3396dcd0670573
@@ -1,185 +1,136 @@
1
- require "time"
2
- require "uri"
3
- require "zlib"
1
+ require 'time'
2
+ require 'uri'
3
+ require 'zlib'
4
4
  require 'openssl'
5
5
  require 'net/http'
6
6
  require 'excon'
7
7
  require 'base64'
8
8
  require 'yaml'
9
9
 
10
- __LIB_DIR__ = File.expand_path(File.join(File.dirname(__FILE__), ".."))
11
- unless $LOAD_PATH.include?(__LIB_DIR__)
12
- $LOAD_PATH.unshift(__LIB_DIR__)
13
- end
14
-
15
- require "megam/gogs/version"
16
- require "megam/gogs/accounts"
17
- require "megam/gogs/dumpout"
18
- require "megam/gogs/errors"
19
- require "megam/gogs/repos"
20
- require "megam/gogs/tokens"
10
+ __LIB_DIR__ = File.expand_path(File.join(File.dirname(__FILE__), '..'))
11
+ $LOAD_PATH.unshift(__LIB_DIR__) unless $LOAD_PATH.include?(__LIB_DIR__)
21
12
 
22
- require "megam/core/gogs_repo"
23
- require "megam/core/gogs_account"
24
- require "megam/core/gogs_tokens"
13
+ require 'megam/gogs/version'
14
+ require 'megam/gogs/accounts'
15
+ require 'megam/gogs/dumpout'
16
+ require 'megam/gogs/errors'
17
+ require 'megam/gogs/repos'
18
+ require 'megam/gogs/tokens'
25
19
 
20
+ require 'megam/core/gogs_repo'
21
+ require 'megam/core/gogs_account'
22
+ require 'megam/core/gogs_tokens'
26
23
 
27
24
  module Megam
28
25
  class Gogs
29
-
30
- AUTH_PREFIX = 'Authorization'
26
+ AUTH_PREFIX = 'Authorization'
31
27
  HEADERS = {
32
28
  'Accept' => 'application/json',
33
29
  'Accept-Encoding' => 'gzip',
34
30
  'User-Agent' => "megam-gogs/#{Megam::Gogs::VERSION}",
35
31
  'X-Ruby-Version' => RUBY_VERSION,
36
32
  'X-Ruby-Platform' => RUBY_PLATFORM
37
-
38
33
  }
39
-
40
- if File.exist?("#{ENV['MEGAM_HOME']}/nilavu.yml")
41
- common = YAML.load_file("#{ENV['MEGAM_HOME']}/nilavu.yml") #COMMON YML
42
- puts "=> Loaded #{ENV['MEGAM_HOME']}/nilavu.yml"
43
- else
44
- puts "=> Warning ! MEGAM_HOME environment variable not set."
45
- common={"api" => {}, "storage" => {}, "varai" => {}, "auth" => {}, "monitor" => {}, "gogs" => {'host' => "", 'port' => ""}}
46
- end
47
-
48
- gogs_host = "#{common['gogs']['host']}" || ENV['GOGS_HOST']
49
- gogs_port = "#{common['gogs']['port']}" || ENV['GOGS_PORT']
50
34
 
51
35
  OPTIONS = {
52
- :headers => {},
53
- :host => gogs_host,
54
- :port => gogs_port,
55
- :nonblock => false,
56
- :scheme => 'http'
36
+ headers: {},
37
+ host: "localhost",
38
+ port: "6001",
39
+ nonblock: false,
40
+ scheme: 'http'
57
41
  }
58
42
 
59
- API_REST = "/api/v1"
60
-
43
+ API_REST = '/api/v1'
61
44
 
62
45
  def text
63
46
  @text ||= Megam::Dumpout.new(STDOUT, STDERR, STDIN)
64
47
  end
65
48
 
66
- def last_response
67
- @last_response
68
- end
49
+ attr_reader :last_response
69
50
 
70
51
  # It is assumed that every API call will NOT use an API_KEY/email.
71
- def initialize(options={})
52
+ def initialize(options = {})
72
53
  @options = OPTIONS.merge(options)
73
54
  end
74
55
 
75
- def request(params,&block)
76
- #just_color_debug("#{@options[:path]}")
77
- start = Time.now
78
-
79
- dummy_params = {
80
- :expects => params[:expects],
81
- :method => params[:method],
82
- :body => params[:body]
83
- }
84
-
85
-
86
- text.msg "#{text.color("START", :cyan, :bold)}"
87
- params.each do |pkey, pvalue|
88
- text.msg("> #{pkey}: #{pvalue}")
89
- end
90
-
91
- if params[:token].nil?
92
-
93
-
94
- @uname = params[:username]
95
- @pass = params[:password]
96
- @cred = "#{@uname}:#{@pass}"
97
- @final_cred64 = Base64.encode64(@cred)
98
-
99
- @final_hash = { :creds => "Basic #{@final_cred64}" }
100
-
101
- response = connection_repo.request(dummy_params, &block)
102
-
103
- puts response.inspect
104
- text.msg("END(#{(Time.now - start).to_s}s)")
105
- # reset (non-persistent) connection
106
- #@connection_repo.reset
107
-
108
- else
56
+ def request(params, &block)
57
+ start = Time.now
109
58
 
110
- @tokens = params[:token]
111
- @final_token = { :token => "token #{@tokens}"}
112
- response = connection_token.request(dummy_params, &block)
59
+ dummy_params = {
60
+ expects: params[:expects],
61
+ method: params[:method],
62
+ body: params[:body]
63
+ }
113
64
 
114
- puts response.inspect
115
- text.msg("END(#{(Time.now - start).to_s}s)")
116
- # reset (non-persistent) connection
117
- #@connection_token.reset
118
- end
119
-
120
- response
121
-
122
- end
123
-
124
- private
125
-
126
- #Make a lazy connection.
127
- def connection_repo
128
- @options[:path] =API_REST + @options[:path]
129
- #headers_hash = encode_header(@options)
130
-
131
- @options[:headers] = HEADERS.merge({
132
- AUTH_PREFIX => @final_hash[:creds],
65
+ text.msg "#{text.color('START', :cyan, :bold)}"
66
+ params.each do |pkey, pvalue|
67
+ text.msg("> #{pkey}: #{pvalue}")
68
+ end
133
69
 
134
- }).merge(@options[:headers])
70
+ if params[:token].nil?
71
+ @uname = params[:username]
72
+ @pass = params[:password]
73
+ @cred = "#{@uname}:#{@pass}"
74
+ @final_cred64 = Base64.encode64(@cred)
135
75
 
76
+ @final_hash = { creds: "Basic #{@final_cred64}" }
136
77
 
78
+ response = connection_repo.request(dummy_params, &block)
79
+ text.msg("END(#{(Time.now - start)}s)")
80
+ else
137
81
 
138
- puts @options[:headers]
82
+ @tokens = params[:token]
83
+ @final_token = { token: "token #{@tokens}" }
84
+ response = connection_token.request(dummy_params, &block)
139
85
 
86
+ puts response.inspect
87
+ text.msg("END(#{(Time.now - start)}s)")
88
+ # reset (non-persistent) connection
89
+ # @connection_token.reset
90
+ end
140
91
 
141
- text.msg("HTTP Request Data:")
142
- text.msg("> HTTP #{@options[:scheme]}://#{@options[:host]}")
143
- @options.each do |key, value|
144
- text.msg("> #{key}: #{value}")
145
- end
146
- text.msg("End HTTP Request Data.")
147
- if @options[:scheme] == "https"
148
- @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}",@options)
149
- else
150
- Excon.defaults[:ssl_verify_peer] = false
151
- @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}:6001",@options)
92
+ response
152
93
  end
153
- @connection
154
- end
155
-
156
-
157
- def connection_token
158
- @options[:path] =API_REST + @options[:path]
159
- #headers_hash = encode_header(@options)
160
94
 
161
- @options[:headers] = HEADERS.merge({
162
- AUTH_PREFIX => @final_token[:token],
95
+ private
163
96
 
164
- }).merge(@options[:headers])
97
+ # Make a lazy connection.
98
+ def connection_repo
99
+ @options[:path] = API_REST + @options[:path]
165
100
 
166
- puts @options[:headers]
101
+ @options[:headers] = HEADERS.merge(AUTH_PREFIX => @final_hash[:creds]).merge(@options[:headers])
167
102
 
168
-
169
- text.msg("HTTP Request Data:")
170
- text.msg("> HTTP #{@options[:scheme]}://#{@options[:host]}")
171
- @options.each do |key, value|
172
- text.msg("> #{key}: #{value}")
173
- end
174
- text.msg("End HTTP Request Data.")
175
- if @options[:scheme] == "https"
176
- @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}",@options)
177
- else
178
- Excon.defaults[:ssl_verify_peer] = false
179
- @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}:6001",@options)
180
- end
181
- @connection
103
+ text.msg('HTTP Request Data:')
104
+ text.msg("> HTTP #{@options[:scheme]}://#{@options[:host]}")
105
+ @options.each do |key, value|
106
+ text.msg("> #{key}: #{value}")
107
+ end
108
+ text.msg('End HTTP Request Data.')
109
+ if @options[:scheme] == 'https'
110
+ @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}", @options)
111
+ else
112
+ Excon.defaults[:ssl_verify_peer] = false
113
+ @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}:6001", @options)
114
+ end
115
+ @connection
182
116
  end
183
117
 
118
+ def connection_token
119
+ @options[:path] = API_REST + @options[:path]
120
+ @options[:headers] = HEADERS.merge(AUTH_PREFIX => @final_token[:token]).merge(@options[:headers])
121
+ text.msg('HTTP Request Data:')
122
+ text.msg("> HTTP #{@options[:scheme]}://#{@options[:host]}")
123
+ @options.each do |key, value|
124
+ text.msg("> #{key}: #{value}")
125
+ end
126
+ text.msg('End HTTP Request Data.')
127
+ if @options[:scheme] == 'https'
128
+ @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}", @options)
129
+ else
130
+ Excon.defaults[:ssl_verify_peer] = false
131
+ @connection = Excon.new("#{@options[:scheme]}://#{@options[:host]}:6001", @options)
132
+ end
133
+ @connection
134
+ end
184
135
  end
185
136
  end
@@ -1,5 +1,5 @@
1
1
  module Megam
2
2
  class Gogs
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.name = "megam_gogs"
7
7
  s.version = Megam::Gogs::VERSION
8
8
  s.authors = ["Raj Thilak,Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar"]
9
- s.email = ["rajthilak@megam.co.in","nkishore@megam.co.in","alrin@megam.co.in, getyesh@megam.co.in"]
9
+ s.email = ["rajthilak@megam.io","nkishore@megam.io","alrin@megam.io, getyesh@megam.io"]
10
10
  s.homepage = "http://github.com/megamsys/megam_gogs.rb"
11
11
  s.license = "Apache V2"
12
12
  sextra_rdoc_files = ["README.md", "LICENSE" ]
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
16
16
  s.test_files = `git ls-files -- {test,spec,fea,tures}/*`.split("\n")
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
- s.add_runtime_dependency 'highline', '~> 1.6'
19
+ s.add_runtime_dependency 'highline', '~> 1.7'
20
20
  s.add_runtime_dependency 'nokogiri', '~> 1.6'
21
- s.add_development_dependency 'minitest', '~> 5.2'
22
- s.add_development_dependency 'rake', '~> 10.1'
21
+ s.add_development_dependency 'minitest', '~> 5.6'
22
+ s.add_development_dependency 'rake', '~> 10.4'
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megam_gogs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raj Thilak,Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-06 00:00:00.000000000 Z
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,34 +44,34 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.2'
47
+ version: '5.6'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.2'
54
+ version: '5.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.1'
61
+ version: '10.4'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.1'
68
+ version: '10.4'
69
69
  description: Ruby Client for the Gogs (gogs.io). Performs REST based HTTP call to
70
70
  gogs.io server
71
71
  email:
72
- - rajthilak@megam.co.in
73
- - nkishore@megam.co.in
74
- - alrin@megam.co.in, getyesh@megam.co.in
72
+ - rajthilak@megam.io
73
+ - nkishore@megam.io
74
+ - alrin@megam.io, getyesh@megam.io
75
75
  executables: []
76
76
  extensions: []
77
77
  extra_rdoc_files: []
@@ -118,8 +118,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.4.3
121
+ rubygems_version: 2.4.6
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Ruby Client for the Gogs (gogs.io)
125
- test_files: []
125
+ test_files:
126
+ - test/test_helper.rb
127
+ - test/test_repo.rb
128
+ - test/test_tokens.rb