scrumship-client 1.0.2 → 1.0.14

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: 6cbdf833c3bbe533a1f7dad8e63087f7fd177970cf4a17a26201767eedd56fc2
4
- data.tar.gz: 837ee821905a264e08d8eb560b5d925e1ca472709c2d8c505d0cf806524a285c
3
+ metadata.gz: e90d90da1b4c725e50d3bf12307b0aa7b61d7c2ac02d25a5b1ccafca5ff2e197
4
+ data.tar.gz: 83933ef49300f2a949a1305706771cf09db1b22d43d7e4154f5c317effd37b58
5
5
  SHA512:
6
- metadata.gz: 80e5db9468e7c50a9647e3dce441605ef57c6dd6056dd073e33de6f08feda576d9dc67fc4841cd3c3ee529e0926a1f9cc856e97d195f2714d70a4ad708a58e06
7
- data.tar.gz: 4bf8e24bb2c71efdd50c3cf6040b330d55a9687e9afae426fa319d85f603f63e3e464b0a79edb844777e1b0ab7f237a633466359e13ad1108832614eefe54486
6
+ metadata.gz: 710d9dd747086f611c19b6df3fdcfa55a5bb48de28d557250993174787d3fc9732663efb1b101493d0a8b8cde2184987aefe4460dc1e483b539378fd67f0143e
7
+ data.tar.gz: f20f7ae601cad09f3b2d9eb650ce83acd1e85ef3321d19bd2082a8f20b7a96eef8523aaf01b7012c1c818ab96d4aeb9ce9f096d0b3f7f5a408a6ee1e0e900e0c
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,3 @@
1
+ module Scrumship
2
+ VERSION = "1.0.14"
3
+ end
@@ -0,0 +1,81 @@
1
+ require "scrumship/client/version"
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ module Scrumship
6
+
7
+ module Client
8
+
9
+ def self.log(activity_token, config_file = 'scrumship.json')
10
+ if defined?(Rails) && Rails.configuration.cache_classes
11
+ Scrumship::Client.do_log(activity_token, config_file)
12
+ else
13
+ if defined?(ActiveSupport::Reloader)
14
+ ActiveSupport::Reloader.to_prepare do
15
+ Scrumship::Client.do_log(activity_token, config_file)
16
+ end
17
+ elsif defined?(ActionDispatch::Reloader)
18
+ ActionDispatch::Reloader.to_prepare do
19
+ Scrumship::Client.do_log(activity_token, config_file)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ def self.setup(project_token, activity_log_url = 'https://app.scrumship.com/api/ac', config_file = 'scrumship.json')
26
+ begin
27
+ username = git_command('git config user.name').gsub('\n', '').strip!
28
+ email = git_command('git config user.email').gsub('\n', '').strip!
29
+ url = "#{activity_log_url}/e/#{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, email: email }.to_json
34
+ res = http.request(req)
35
+
36
+ json_res = JSON.parse(res.body)
37
+ if json_res["status"] == 200
38
+ config = { u: json_res["token"], url: activity_log_url, pt: project_token }
39
+ File.open(config_file, 'w') { |file| file.write(config.to_json) }
40
+ end
41
+ rescue
42
+ # Ignored
43
+ end
44
+ end
45
+
46
+ def self.do_log(activity_token, config_file)
47
+ begin
48
+ config = JSON.parse(File.read(config_file)).symbolize_keys
49
+ url = "#{config[:activity_log_url]}/#{config[:pt]}/#{activity_token}/#{config[:u]}"
50
+ http = client(url)
51
+ http.get(url)
52
+ rescue
53
+ # Ignored
54
+ end
55
+ end
56
+
57
+ def self.client(url)
58
+ uri = URI.parse(url)
59
+ http = Net::HTTP.new(uri.host, uri.port)
60
+ http.use_ssl = url.include?('https')
61
+ http.read_timeout = 5
62
+ http
63
+ end
64
+
65
+ def self.git_command(command)
66
+ begin
67
+ result = `#{command}`
68
+ if result == ""
69
+ raise Exception
70
+ end
71
+ result
72
+ rescue
73
+ puts "Please set up your git user and git user email: " +
74
+ "\n git config --global user.name \"Your Username\"" +
75
+ "\n git config --global user.email \"email@example.com\""
76
+ exit 1
77
+ end
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,10 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'scrumship-client'
3
+ s.version = '1.0.14'
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.2
4
+ version: 1.0.14
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,68 +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://app.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
- if res.length > 128
36
- return
37
- end
38
- encoded = CGI.escape(res.body)
39
- config = {u: encoded, url: configuration.activity_log_url, pt: configuration.project_token}
40
- File.open(configuration.config_file, 'w') { |file| file.write(config.to_json) }
41
- res.body
42
- end
43
- rescue
44
- # Ignored
45
- end
46
- end
47
-
48
- def self.log
49
- begin
50
- token = JSON.parse(File.read(configuration.config_file)).symbolize_keys[:u]
51
- url = "#{configuration.activity_log_url}/#{configuration.project_token}/#{configuration.activity_token}/#{token}"
52
- http = client(url)
53
- http.get(url)
54
- rescue
55
- # Ignored
56
- end
57
- end
58
-
59
- def self.client(url)
60
- uri = URI.parse(url)
61
- http = Net::HTTP.new(uri.host, uri.port)
62
- http.use_ssl = url.include?('https')
63
- http.read_timeout = 5
64
- http
65
- end
66
-
67
- end
68
- end