scrumship-client 1.0.13 → 1.0.17
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/lib/scrumship/client.rb +35 -29
- data/scrumship-client.gemspec +1 -1
- metadata +1 -2
- data/lib/scrumship/client/version.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf454577fbff0c008f9d83a68d519fda4883523e1c499cd1e44c46307a155dfb
|
|
4
|
+
data.tar.gz: d0c4c890e623b0a2e2c7bd1e79279db451db05f2eefe3a51bb70201208d68a94
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 546efe115f8fe52be52a39c475f10e89c85c0444247ee254bac5dec160483b63563d931a6184db78aeb8767be7d2a6ff2f22be91466597f9898a3a408ba7afdf
|
|
7
|
+
data.tar.gz: c60b847cde2a96c30de028c31e3f60518bd94a50c0032f22233bfba8dc92485562b7f8f0c6c162ccbb86b6c8e04f4bf81efc835d514fff78763355df215c1822
|
data/lib/scrumship/client.rb
CHANGED
|
@@ -1,65 +1,51 @@
|
|
|
1
|
-
require "scrumship/client/version"
|
|
2
1
|
require 'net/http'
|
|
3
2
|
require 'json'
|
|
4
3
|
|
|
5
4
|
module Scrumship
|
|
6
|
-
class Configuration
|
|
7
|
-
attr_accessor :config_file
|
|
8
|
-
attr_accessor :activity_log_url
|
|
9
|
-
attr_accessor :project_token
|
|
10
|
-
attr_accessor :activity_token
|
|
11
|
-
|
|
12
|
-
def initialize
|
|
13
|
-
@activity_log_url = 'https://app.scrumship.com/api/ac'
|
|
14
|
-
@config_file = 'scrumship.json'
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
5
|
|
|
18
6
|
module Client
|
|
19
7
|
|
|
20
|
-
def self.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if Rails.configuration.cache_classes
|
|
24
|
-
ScrumshipClient::Client.log
|
|
8
|
+
def self.log(activity_token, config_file = 'scrumship.json')
|
|
9
|
+
if defined?(Rails) && Rails.configuration.cache_classes
|
|
10
|
+
Scrumship::Client.do_log(activity_token, config_file)
|
|
25
11
|
else
|
|
26
12
|
if defined?(ActiveSupport::Reloader)
|
|
27
13
|
ActiveSupport::Reloader.to_prepare do
|
|
28
|
-
|
|
14
|
+
Scrumship::Client.do_log(activity_token, config_file)
|
|
29
15
|
end
|
|
30
16
|
elsif defined?(ActionDispatch::Reloader)
|
|
31
17
|
ActionDispatch::Reloader.to_prepare do
|
|
32
|
-
|
|
18
|
+
Scrumship::Client.do_log(activity_token, config_file)
|
|
33
19
|
end
|
|
34
20
|
end
|
|
35
21
|
end
|
|
36
22
|
end
|
|
37
23
|
|
|
38
|
-
def self.setup(
|
|
24
|
+
def self.setup(project_token, activity_log_url = 'https://app.scrumship.com/api/ac', config_file = 'scrumship.json')
|
|
39
25
|
begin
|
|
40
|
-
username =
|
|
41
|
-
|
|
42
|
-
url = "#{
|
|
26
|
+
username = git_command('git config user.name').gsub('\n', '').strip!
|
|
27
|
+
email = git_command('git config user.email').gsub('\n', '').strip!
|
|
28
|
+
url = "#{activity_log_url}/e/#{project_token}"
|
|
43
29
|
http = client(url)
|
|
44
30
|
uri = URI.parse(url)
|
|
45
31
|
req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
|
|
46
|
-
req.body = { username: username }.to_json
|
|
32
|
+
req.body = { username: username, email: email }.to_json
|
|
47
33
|
res = http.request(req)
|
|
48
34
|
|
|
49
35
|
json_res = JSON.parse(res.body)
|
|
50
36
|
if json_res["status"] == 200
|
|
51
|
-
config = { u: json_res["token"], url:
|
|
52
|
-
File.open(
|
|
37
|
+
config = { u: json_res["token"], url: activity_log_url, pt: project_token }
|
|
38
|
+
File.open(config_file, 'w') { |file| file.write(config.to_json) }
|
|
53
39
|
end
|
|
54
40
|
rescue
|
|
55
41
|
# Ignored
|
|
56
42
|
end
|
|
57
43
|
end
|
|
58
44
|
|
|
59
|
-
def self.
|
|
45
|
+
def self.do_log(activity_token, config_file)
|
|
60
46
|
begin
|
|
61
|
-
|
|
62
|
-
url = "#{
|
|
47
|
+
config = JSON.parse(File.read(config_file)).symbolize_keys
|
|
48
|
+
url = "#{config[:url]}/#{config[:pt]}/#{activity_token}/#{config[:u]}"
|
|
63
49
|
http = client(url)
|
|
64
50
|
http.get(url)
|
|
65
51
|
rescue
|
|
@@ -75,5 +61,25 @@ module Scrumship
|
|
|
75
61
|
http
|
|
76
62
|
end
|
|
77
63
|
|
|
64
|
+
def self.git_command(command)
|
|
65
|
+
begin
|
|
66
|
+
result = `#{command}`
|
|
67
|
+
if result == ""
|
|
68
|
+
do_abort
|
|
69
|
+
end
|
|
70
|
+
result
|
|
71
|
+
rescue
|
|
72
|
+
do_abort
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
private
|
|
77
|
+
|
|
78
|
+
def self.do_abort
|
|
79
|
+
abort "Please set up your git user and git user email: " +
|
|
80
|
+
"\n git config --global user.name \"Your Username\"" +
|
|
81
|
+
"\n git config --global user.email \"email@example.com\""
|
|
82
|
+
end
|
|
83
|
+
|
|
78
84
|
end
|
|
79
85
|
end
|
data/scrumship-client.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'scrumship-client'
|
|
3
|
-
s.version = '1.0.
|
|
3
|
+
s.version = '1.0.17'
|
|
4
4
|
s.date = '2021-12-04'
|
|
5
5
|
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
6
6
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scrumship-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.17
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Dymek
|
|
@@ -23,7 +23,6 @@ files:
|
|
|
23
23
|
- bin/console
|
|
24
24
|
- bin/setup
|
|
25
25
|
- lib/scrumship/client.rb
|
|
26
|
-
- lib/scrumship/client/version.rb
|
|
27
26
|
- scrumship-client.gemspec
|
|
28
27
|
homepage:
|
|
29
28
|
licenses: []
|