scrumship-client 1.0.4 → 1.0.16
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/.gitignore +13 -0
- data/.rspec +3 -0
- data/Gemfile +7 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/scrumship/client.rb +79 -0
- data/scrumship-client.gemspec +10 -0
- metadata +12 -5
- data/lib/scrumship-client.rb +0 -84
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02c5281dd09e464d68681430caea397956f858166be440d8be33bc81aec5b005
|
|
4
|
+
data.tar.gz: f33e48fe1f0b47e50056f75a05c75435e12578c9a3bd5f0ca7112ce8c398606f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51d44306d32646a0b0e157b0f679f74e06a11a4c76983ad59f16349bb02446cebfc4d54178af97be072afa15de5188dd6bd92c7344811945463dbafb39740235
|
|
7
|
+
data.tar.gz: accaf7346d6dca6676ac966cfc47477a47f27b198f71b6daccbe77459c6deed1441bfe02f89b79e3b7699cf9ca7fbfda8d4f4694c6f972ede0746ab08efe089e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "scrumship/client"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
module Scrumship
|
|
5
|
+
|
|
6
|
+
module Client
|
|
7
|
+
|
|
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)
|
|
11
|
+
else
|
|
12
|
+
if defined?(ActiveSupport::Reloader)
|
|
13
|
+
ActiveSupport::Reloader.to_prepare do
|
|
14
|
+
Scrumship::Client.do_log(activity_token, config_file)
|
|
15
|
+
end
|
|
16
|
+
elsif defined?(ActionDispatch::Reloader)
|
|
17
|
+
ActionDispatch::Reloader.to_prepare do
|
|
18
|
+
Scrumship::Client.do_log(activity_token, config_file)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.setup(project_token, activity_log_url = 'https://app.scrumship.com/api/ac', config_file = 'scrumship.json')
|
|
25
|
+
begin
|
|
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}"
|
|
29
|
+
http = client(url)
|
|
30
|
+
uri = URI.parse(url)
|
|
31
|
+
req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
|
|
32
|
+
req.body = { username: username, email: email }.to_json
|
|
33
|
+
res = http.request(req)
|
|
34
|
+
|
|
35
|
+
json_res = JSON.parse(res.body)
|
|
36
|
+
if json_res["status"] == 200
|
|
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) }
|
|
39
|
+
end
|
|
40
|
+
rescue
|
|
41
|
+
# Ignored
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.do_log(activity_token, config_file)
|
|
46
|
+
begin
|
|
47
|
+
config = JSON.parse(File.read(config_file)).symbolize_keys
|
|
48
|
+
url = "#{config[:url]}/#{config[:pt]}/#{activity_token}/#{config[:u]}"
|
|
49
|
+
http = client(url)
|
|
50
|
+
http.get(url)
|
|
51
|
+
rescue
|
|
52
|
+
# Ignored
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.client(url)
|
|
57
|
+
uri = URI.parse(url)
|
|
58
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
59
|
+
http.use_ssl = url.include?('https')
|
|
60
|
+
http.read_timeout = 5
|
|
61
|
+
http
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.git_command(command)
|
|
65
|
+
begin
|
|
66
|
+
result = `#{command}`
|
|
67
|
+
if result == ""
|
|
68
|
+
raise Exception
|
|
69
|
+
end
|
|
70
|
+
result
|
|
71
|
+
rescue
|
|
72
|
+
abort "Please set up your git user and git user email: " +
|
|
73
|
+
"\n git config --global user.name \"Your Username\"" +
|
|
74
|
+
"\n git config --global user.email \"email@example.com\""
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = 'scrumship-client'
|
|
3
|
+
s.version = '1.0.16'
|
|
4
|
+
s.date = '2021-12-04'
|
|
5
|
+
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
6
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
7
|
+
end
|
|
8
|
+
s.summary = "Scrumship Client"
|
|
9
|
+
s.authors = ["Greg Dymek"]
|
|
10
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Dymek
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
@@ -16,7 +16,14 @@ executables: []
|
|
|
16
16
|
extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
|
18
18
|
files:
|
|
19
|
-
-
|
|
19
|
+
- ".gitignore"
|
|
20
|
+
- ".rspec"
|
|
21
|
+
- Gemfile
|
|
22
|
+
- Rakefile
|
|
23
|
+
- bin/console
|
|
24
|
+
- bin/setup
|
|
25
|
+
- lib/scrumship/client.rb
|
|
26
|
+
- scrumship-client.gemspec
|
|
20
27
|
homepage:
|
|
21
28
|
licenses: []
|
|
22
29
|
metadata: {}
|
|
@@ -35,8 +42,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
35
42
|
- !ruby/object:Gem::Version
|
|
36
43
|
version: '0'
|
|
37
44
|
requirements: []
|
|
38
|
-
rubygems_version: 3.
|
|
45
|
+
rubygems_version: 3.1.2
|
|
39
46
|
signing_key:
|
|
40
47
|
specification_version: 4
|
|
41
|
-
summary: Scrumship
|
|
48
|
+
summary: Scrumship Client
|
|
42
49
|
test_files: []
|
data/lib/scrumship-client.rb
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
require 'net/http'
|
|
2
|
-
|
|
3
|
-
module ScrumshipClient
|
|
4
|
-
class Configuration
|
|
5
|
-
attr_accessor :config_file
|
|
6
|
-
attr_accessor :activity_log_url
|
|
7
|
-
attr_accessor :project_token
|
|
8
|
-
attr_accessor :activity_token
|
|
9
|
-
|
|
10
|
-
def initialize
|
|
11
|
-
@activity_log_url = 'https://app.scrumship.com/api/ac'
|
|
12
|
-
@config_file = 'scrumship.json'
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
class Client
|
|
17
|
-
|
|
18
|
-
def self.configuration
|
|
19
|
-
@configuration ||= Configuration.new
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.configure
|
|
23
|
-
yield(configuration)
|
|
24
|
-
ScrumshipClient::Client.setup
|
|
25
|
-
if Rails.configuration.cache_classes
|
|
26
|
-
ScrumshipClient::Client.log
|
|
27
|
-
else
|
|
28
|
-
if defined?(ActiveSupport::Reloader)
|
|
29
|
-
ActiveSupport::Reloader.to_prepare do
|
|
30
|
-
ScrumshipClient::Client.log
|
|
31
|
-
end
|
|
32
|
-
elsif defined?(ActionDispatch::Reloader)
|
|
33
|
-
ActionDispatch::Reloader.to_prepare do
|
|
34
|
-
ScrumshipClient::Client.log
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def self.setup
|
|
41
|
-
begin
|
|
42
|
-
unless File.file?(configuration.config_file)
|
|
43
|
-
username = `git config user.name`
|
|
44
|
-
username = username.gsub('\n', '').strip!
|
|
45
|
-
url = "#{configuration.activity_log_url}/e/#{configuration.project_token}"
|
|
46
|
-
http = client(url)
|
|
47
|
-
uri = URI.parse(url)
|
|
48
|
-
req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
|
|
49
|
-
req.body = {username: username}.to_json
|
|
50
|
-
res = http.request(req)
|
|
51
|
-
if res.length > 128
|
|
52
|
-
return
|
|
53
|
-
end
|
|
54
|
-
encoded = CGI.escape(res.body)
|
|
55
|
-
config = {u: encoded, url: configuration.activity_log_url, pt: configuration.project_token}
|
|
56
|
-
File.open(configuration.config_file, 'w') { |file| file.write(config.to_json) }
|
|
57
|
-
res.body
|
|
58
|
-
end
|
|
59
|
-
rescue
|
|
60
|
-
# Ignored
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def self.log
|
|
65
|
-
begin
|
|
66
|
-
token = JSON.parse(File.read(configuration.config_file)).symbolize_keys[:u]
|
|
67
|
-
url = "#{configuration.activity_log_url}/#{configuration.project_token}/#{configuration.activity_token}/#{token}"
|
|
68
|
-
http = client(url)
|
|
69
|
-
http.get(url)
|
|
70
|
-
rescue
|
|
71
|
-
# Ignored
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def self.client(url)
|
|
76
|
-
uri = URI.parse(url)
|
|
77
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
78
|
-
http.use_ssl = url.include?('https')
|
|
79
|
-
http.read_timeout = 5
|
|
80
|
-
http
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
end
|