scrumship-client 1.0.0

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 (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/scrumship-client.rb +64 -0
  3. metadata +42 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7c4eddcce7055fc5c962833ca56c3475d390dec105b4665e6124b936bdb7b3e2
4
+ data.tar.gz: 35bedebbb0f6fdf781f98836c245eb0cd7494416a79195e77c7137644b7dd516
5
+ SHA512:
6
+ metadata.gz: a7bf3caf170068fc67b300cdbbe033c7dcf09a31d1d44c614dddfef3aca17d24fee1cbb86771284445e5b68fc9067e79cf5e2d585215a35203455a71253487b6
7
+ data.tar.gz: 9e610f5752c8ed7ec396eb0c9876f9e737601e73b8c377ed04997b265003d6ced00dca4636b8e45d353528877ad13d267e8b21ac632379fbd891d1b194417682
@@ -0,0 +1,64 @@
1
+ module ScrumshipClient
2
+ class Configuration
3
+ attr_accessor :config_file
4
+ attr_accessor :activity_log_url
5
+ attr_accessor :project_token
6
+ attr_accessor :activity_token
7
+
8
+ def initialize
9
+ @activity_log_url = 'https://scrumship.com/api/ac'
10
+ end
11
+ end
12
+
13
+ class Client
14
+
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.configure
20
+ yield(configuration)
21
+ end
22
+
23
+ def self.setup
24
+ begin
25
+ unless File.file?(configuration.config_file)
26
+ username = `git config user.name`
27
+ username = username.gsub('\n', '').strip!
28
+ url = "#{configuration.activity_log_url}/e/#{configuration.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}.to_json
33
+ res = http.request(req)
34
+ encoded = CGI.escape(res.body)
35
+ config = {u: encoded, url: configuration.activity_log_url, pt: configuration.project_token}
36
+ File.open(configuration.config_file, 'w') { |file| file.write(config.to_json) }
37
+ res.body
38
+ end
39
+ rescue
40
+ # Ignored
41
+ end
42
+ end
43
+
44
+ def self.log
45
+ begin
46
+ token = JSON.parse(File.read(configuration.config_file)).symbolize_keys[:u]
47
+ url = "#{configuration.activity_log_url}/#{configuration.project_token}/#{configuration.activity_token}/#{token}"
48
+ http = client(url)
49
+ http.get(url)
50
+ rescue
51
+ # Ignored
52
+ end
53
+ end
54
+
55
+ def self.client(url)
56
+ uri = URI.parse(url)
57
+ http = Net::HTTP.new(uri.host, uri.port)
58
+ http.use_ssl = url.include?('https')
59
+ http.read_timeout = 5
60
+ http
61
+ end
62
+
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,42 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrumship-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Greg Dymek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-11-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/scrumship-client.rb
20
+ homepage:
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubygems_version: 3.0.8
39
+ signing_key:
40
+ specification_version: 4
41
+ summary: Scrumship client
42
+ test_files: []