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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2dcda2f7cec36bc799f4466617aa072385174ae4f885edf95e9a50a02530632a
4
- data.tar.gz: c6c9a4ce3fbec5327135bbe35b0aa97f26f973530be11f42c78de4268158b6c6
3
+ metadata.gz: 02c5281dd09e464d68681430caea397956f858166be440d8be33bc81aec5b005
4
+ data.tar.gz: f33e48fe1f0b47e50056f75a05c75435e12578c9a3bd5f0ca7112ce8c398606f
5
5
  SHA512:
6
- metadata.gz: d6dcad5f039427aadde4e2bfd66f1c87157b5f2e11ae7c24f62e65b095846c87d2c5863f0700dd1063f3c2f74ada78cf0ab2a07d95e881a91c52bd1d00b256c3
7
- data.tar.gz: 8b87b2008ca0ef4512d329979ed56f82c162846d16415ab72a2fa216f536f6a24e0765afa79e34529c4996f273a174a8e5ca1d732d2e5dbca7d20489dc2dd7f0
6
+ metadata.gz: 51d44306d32646a0b0e157b0f679f74e06a11a4c76983ad59f16349bb02446cebfc4d54178af97be072afa15de5188dd6bd92c7344811945463dbafb39740235
7
+ data.tar.gz: accaf7346d6dca6676ac966cfc47477a47f27b198f71b6daccbe77459c6deed1441bfe02f89b79e3b7699cf9ca7fbfda8d4f4694c6f972ede0746ab08efe089e
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,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
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: 2020-12-13 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,14 @@ 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
+ - 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.0.8
45
+ rubygems_version: 3.1.2
39
46
  signing_key:
40
47
  specification_version: 4
41
- summary: Scrumship client
48
+ summary: Scrumship Client
42
49
  test_files: []
@@ -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