scrumship-client 1.0.1 → 1.0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc0e62e13ce9d9a59f96d44af297fffee579587d698d3443cd11573d7ca48921
4
- data.tar.gz: c31cd397f579aed1b6113c62d01187c7f47ffa6a81d226d7c443af8b33bf0d3a
3
+ metadata.gz: 593c0086c8c866117eb2db3586b29e5b215954a116ca9088dcf7a259eda147bd
4
+ data.tar.gz: 3c15452b285504bac9af84acf4f87bb5cf59ac26ff67622e1cf18dc2088518bb
5
5
  SHA512:
6
- metadata.gz: cce629a425d0269ccc42abd4b097b1ffc719e3c7938fe9da287dee65ce15d8079288d68054ab8ea7c958e4c80b7e47ce58bb7c54aa9cf69b57c9eb885dd4e88e
7
- data.tar.gz: 30e69bd95f6eea0bb76a63e48d371d51f0fb26e8b4c0554b2d2cb4f456842b9b8cd84d9e84f46d9fe345a6d3ba7c47a4de92b67093b21c10eb559b6a0101b9d1
6
+ metadata.gz: 30a4b9f9582687f67b5ceafbe4e0d9fd61ad5531c9bb47f5ae629f415feca9f7f05d49150d4d7ce39e0ec23e9a012ea6c804ad4b7326fbcf0633a9d64f21b933
7
+ data.tar.gz: 9641df33c38a520b5ee3de31359089d6798261657d6fa2d52210a95f5f215869bd153231ca5213f317dfd97cb1e67b225ba7978dd100d2695a0f797711cf3dc0
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ /Gemfile.lock
13
+ /scrumship.json
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in scrumship-client.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ module Scrumship
2
+ module Client
3
+ VERSION = "1.0.13"
4
+ end
5
+ end
@@ -0,0 +1,79 @@
1
+ require "scrumship/client/version"
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ 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
+
18
+ module Client
19
+
20
+ def self.configure
21
+ yield(configuration)
22
+ ScrumshipClient::Client.setup
23
+ if Rails.configuration.cache_classes
24
+ ScrumshipClient::Client.log
25
+ else
26
+ if defined?(ActiveSupport::Reloader)
27
+ ActiveSupport::Reloader.to_prepare do
28
+ ScrumshipClient::Client.log
29
+ end
30
+ elsif defined?(ActionDispatch::Reloader)
31
+ ActionDispatch::Reloader.to_prepare do
32
+ ScrumshipClient::Client.log
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ def self.setup(configuration = Configuration.new)
39
+ begin
40
+ username = `git config user.name`
41
+ username = username.gsub('\n', '').strip!
42
+ url = "#{configuration.activity_log_url}/e/#{configuration.project_token}"
43
+ http = client(url)
44
+ uri = URI.parse(url)
45
+ req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
46
+ req.body = { username: username }.to_json
47
+ res = http.request(req)
48
+
49
+ json_res = JSON.parse(res.body)
50
+ if json_res["status"] == 200
51
+ config = { u: json_res["token"], url: configuration.activity_log_url, pt: configuration.project_token }
52
+ File.open(configuration.config_file, 'w') { |file| file.write(config.to_json) }
53
+ end
54
+ rescue
55
+ # Ignored
56
+ end
57
+ end
58
+
59
+ def self.log
60
+ begin
61
+ token = JSON.parse(File.read(configuration.config_file)).symbolize_keys[:u]
62
+ url = "#{configuration.activity_log_url}/#{configuration.project_token}/#{configuration.activity_token}/#{token}"
63
+ http = client(url)
64
+ http.get(url)
65
+ rescue
66
+ # Ignored
67
+ end
68
+ end
69
+
70
+ def self.client(url)
71
+ uri = URI.parse(url)
72
+ http = Net::HTTP.new(uri.host, uri.port)
73
+ http.use_ssl = url.include?('https')
74
+ http.read_timeout = 5
75
+ http
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.13'
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.1
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Dymek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-15 00:00:00.000000000 Z
11
+ date: 2021-12-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -16,7 +16,15 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - lib/scrumship-client.rb
19
+ - ".gitignore"
20
+ - ".rspec"
21
+ - Gemfile
22
+ - Rakefile
23
+ - bin/console
24
+ - bin/setup
25
+ - lib/scrumship/client.rb
26
+ - lib/scrumship/client/version.rb
27
+ - scrumship-client.gemspec
20
28
  homepage:
21
29
  licenses: []
22
30
  metadata: {}
@@ -35,8 +43,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
35
43
  - !ruby/object:Gem::Version
36
44
  version: '0'
37
45
  requirements: []
38
- rubygems_version: 3.0.8
46
+ rubygems_version: 3.1.2
39
47
  signing_key:
40
48
  specification_version: 4
41
- summary: Scrumship client
49
+ summary: Scrumship Client
42
50
  test_files: []
@@ -1,65 +0,0 @@
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
- @config_file = 'scrumship.json'
11
- end
12
- end
13
-
14
- class Client
15
-
16
- def self.configuration
17
- @configuration ||= Configuration.new
18
- end
19
-
20
- def self.configure
21
- yield(configuration)
22
- end
23
-
24
- def self.setup
25
- begin
26
- unless File.file?(configuration.config_file)
27
- username = `git config user.name`
28
- username = username.gsub('\n', '').strip!
29
- url = "#{configuration.activity_log_url}/e/#{configuration.project_token}"
30
- http = client(url)
31
- uri = URI.parse(url)
32
- req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
33
- req.body = {username: username}.to_json
34
- res = http.request(req)
35
- encoded = CGI.escape(res.body)
36
- config = {u: encoded, url: configuration.activity_log_url, pt: configuration.project_token}
37
- File.open(configuration.config_file, 'w') { |file| file.write(config.to_json) }
38
- res.body
39
- end
40
- rescue
41
- # Ignored
42
- end
43
- end
44
-
45
- def self.log
46
- begin
47
- token = JSON.parse(File.read(configuration.config_file)).symbolize_keys[:u]
48
- url = "#{configuration.activity_log_url}/#{configuration.project_token}/#{configuration.activity_token}/#{token}"
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
- end
65
- end