sc2cli 0.1.1

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 (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.gitlab-ci.yml +37 -0
  4. data/Gemfile +13 -0
  5. data/LICENSE.txt +21 -0
  6. data/Rakefile +13 -0
  7. data/bin/console +16 -0
  8. data/bin/setup +18 -0
  9. data/exe/sc2 +44 -0
  10. data/lib/sc2cli.rb +7 -0
  11. data/lib/sc2cli/shared.rb +15 -0
  12. data/lib/sc2cli/shared/api.rb +79 -0
  13. data/lib/sc2cli/shared/cache.rb +112 -0
  14. data/lib/sc2cli/shared/configuration.rb +119 -0
  15. data/lib/sc2cli/shared/console.rb +69 -0
  16. data/lib/sc2cli/shared/names.rb +101 -0
  17. data/lib/sc2cli/shared/region.rb +112 -0
  18. data/lib/sc2cli/shared/season.rb +123 -0
  19. data/lib/sc2cli/shared/token.rb +139 -0
  20. data/lib/sc2cli/subcommands.rb +9 -0
  21. data/lib/sc2cli/subcommands/history.rb +114 -0
  22. data/lib/sc2cli/subcommands/history/historymatch.rb +118 -0
  23. data/lib/sc2cli/subcommands/history/historymatches.rb +72 -0
  24. data/lib/sc2cli/subcommands/ladder.rb +120 -0
  25. data/lib/sc2cli/subcommands/ladder/ladderdetails.rb +110 -0
  26. data/lib/sc2cli/subcommands/ladder/ladderdetailsmembership.rb +64 -0
  27. data/lib/sc2cli/subcommands/ladder/ladderdetailsrank.rb +101 -0
  28. data/lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb +114 -0
  29. data/lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb +110 -0
  30. data/lib/sc2cli/subcommands/ladder/ladderdetailsteammembers.rb +85 -0
  31. data/lib/sc2cli/subcommands/ladder/ladderdetailsteams.rb +85 -0
  32. data/lib/sc2cli/subcommands/ladder/laddersummary.rb +82 -0
  33. data/lib/sc2cli/subcommands/league.rb +190 -0
  34. data/lib/sc2cli/subcommands/league/leaguetier.rb +112 -0
  35. data/lib/sc2cli/subcommands/league/leaguetiers.rb +79 -0
  36. data/lib/sc2cli/subcommands/raw.rb +89 -0
  37. data/lib/sc2cli/subcommands/season.rb +74 -0
  38. data/lib/sc2cli/version.rb +13 -0
  39. data/sc2cli.gemspec +36 -0
  40. metadata +85 -0
@@ -0,0 +1,79 @@
1
+ ###############################################################################
2
+
3
+ module SC2Cli
4
+
5
+ ###############################################################################
6
+
7
+ module Subcommands
8
+
9
+ ###############################################################################
10
+
11
+ module LeagueShared
12
+
13
+ ###############################################################################
14
+
15
+ class LeagueTiers
16
+
17
+ ###############################################################################
18
+
19
+ @tiers
20
+
21
+ ###############################################################################
22
+
23
+ attr_reader :colour
24
+ attr_reader :name
25
+
26
+ ###############################################################################
27
+
28
+ def initialize(name:, colour:, json:)
29
+ @name = name
30
+ @colour = colour
31
+ @tiers = Array.new
32
+
33
+ if json.key?("tier") then
34
+ tiers = json["tier"]
35
+ @@console.fatal("Returned league information for: #{name} tiers is not an array!") unless tiers.kind_of?(Array)
36
+
37
+ tiers.each do |tier|
38
+ tier = LeagueTier.new(league: @name, colour: @colour, json: tier)
39
+ add(tier: tier)
40
+ end
41
+ end
42
+ end
43
+
44
+ ###############################################################################
45
+
46
+ def add(tier:)
47
+ @tiers << tier if tier.kind_of?(LeagueTier)
48
+ @tiers.sort_by!{ |tier| tier.id }
49
+ end
50
+
51
+ ###############################################################################
52
+
53
+ def to_s
54
+ result = String.new
55
+
56
+ @tiers.each do |tier|
57
+ result += tier.to_s
58
+ end
59
+
60
+ return result
61
+ end
62
+
63
+ ###############################################################################
64
+
65
+ end
66
+
67
+ ###############################################################################
68
+
69
+ end
70
+
71
+ ###############################################################################
72
+
73
+ end
74
+
75
+ ###############################################################################
76
+
77
+ end
78
+
79
+ ###############################################################################
@@ -0,0 +1,89 @@
1
+ ###############################################################################
2
+
3
+ require 'json'
4
+ require 'optparse'
5
+
6
+ ###############################################################################
7
+
8
+ module SC2Cli
9
+
10
+ ###############################################################################
11
+
12
+ module Subcommands
13
+
14
+ ###############################################################################
15
+
16
+ class Raw
17
+
18
+ ###############################################################################
19
+
20
+ @@console = Shared::Console.instance
21
+
22
+ ###############################################################################
23
+
24
+ @configuration
25
+ @path
26
+ @region
27
+
28
+ ###############################################################################
29
+
30
+ def initialize(configuration:, options:)
31
+ @configuration = configuration
32
+
33
+ path = nil
34
+ region = nil
35
+
36
+ OptionParser.new do |opts|
37
+ opts.banner = "Usage: #{$0} #{self.class.name.split("::").last.downcase} [options]"
38
+
39
+ opts.on("-h", "--help", "Prints this help") do
40
+ @@console.info(opts)
41
+ exit
42
+ end
43
+
44
+ opts.on("-p", "--path PATH", String, "The API path to query.") do |value|
45
+ path = value
46
+ end
47
+
48
+ opts.on("-r", "--region REGION", String, "Region name, such as 'eu' or 'us'. Use configuration region by default.") do |value|
49
+ region = Shared::Region.new(name: value)
50
+ end
51
+ end.parse!
52
+
53
+ region ||= @configuration.region
54
+
55
+ @@console.fatal("Raw path must be specified!") unless path.kind_of?(String)
56
+ @@console.fatal("Raw path must not be blank!") if path.empty?
57
+ @@console.fatal("Raw path must begin with '/'!") unless path.chars.first == "/"
58
+
59
+ @path = path
60
+ @region = region
61
+ end
62
+
63
+ ###############################################################################
64
+
65
+ def run
66
+ @@console.info("Running raw API request:")
67
+ @@console.info(" - Path : #{@path}")
68
+ @@console.info(" - Region: #{@region.description}")
69
+
70
+ api = Shared::Api.new(configuration: @configuration, region: @region)
71
+
72
+ result = api.get(path: @path)
73
+
74
+ @@console.info(JSON.pretty_generate(result))
75
+ end
76
+
77
+ ###############################################################################
78
+
79
+ end
80
+
81
+ ###############################################################################
82
+
83
+ end
84
+
85
+ ###############################################################################
86
+
87
+ end
88
+
89
+ ###############################################################################
@@ -0,0 +1,74 @@
1
+ ###############################################################################
2
+
3
+ require 'optparse'
4
+
5
+ ###############################################################################
6
+
7
+ module SC2Cli
8
+
9
+ ###############################################################################
10
+
11
+ module Subcommands
12
+
13
+ ###############################################################################
14
+
15
+ class Season
16
+
17
+ ###############################################################################
18
+
19
+ @@console = Shared::Console.instance
20
+
21
+ ###############################################################################
22
+
23
+ @configuration
24
+ @region
25
+
26
+ ###############################################################################
27
+
28
+ def initialize(configuration:, options:)
29
+ @configuration = configuration
30
+
31
+ region = nil
32
+
33
+ OptionParser.new do |opts|
34
+ opts.banner = "Usage: #{$0} #{self.class.name.split("::").last.downcase} [options]"
35
+
36
+ opts.on("-h", "--help", "Prints this help") do
37
+ @@console.info(opts)
38
+ exit
39
+ end
40
+
41
+ opts.on("-r", "--region REGION", String, "Region name, such as 'eu' or 'us'. Use configuration region by default.") do |value|
42
+ region = Shared::Region.new(name: value)
43
+ end
44
+ end.parse!
45
+
46
+ region ||= @configuration.region
47
+
48
+ @region = region
49
+ end
50
+
51
+ ###############################################################################
52
+
53
+ def run
54
+ @@console.info("Running season API request:")
55
+ @@console.info(" - Region: #{@region.description}")
56
+
57
+ season = Shared::Season.new(configuration: @configuration, region: @region)
58
+
59
+ @@console.info(season.to_s)
60
+ end
61
+
62
+ ###############################################################################
63
+
64
+ end
65
+
66
+ ###############################################################################
67
+
68
+ end
69
+
70
+ ###############################################################################
71
+
72
+ end
73
+
74
+ ###############################################################################
@@ -0,0 +1,13 @@
1
+ ###############################################################################
2
+
3
+ module SC2Cli
4
+
5
+ ###############################################################################
6
+
7
+ VERSION = "0.1.1"
8
+
9
+ ###############################################################################
10
+
11
+ end
12
+
13
+ ###############################################################################
data/sc2cli.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ ###############################################################################
2
+
3
+ # frozen_string_literal: true
4
+
5
+ ###############################################################################
6
+
7
+ require_relative "lib/sc2cli/version"
8
+
9
+ ###############################################################################
10
+
11
+ Gem::Specification.new do |spec|
12
+ spec.name = "sc2cli"
13
+ spec.version = SC2Cli::VERSION
14
+ spec.authors = ["Richard Lees"]
15
+ spec.email = ["git0@bitservices.io"]
16
+
17
+ spec.summary = "A command line utility for accessing the StarCraft 2 API written in Ruby."
18
+ spec.description = "A command line utility for accessing the StarCraft 2 API written in Ruby. Supports league boundaries, player league details, player match history and more."
19
+ spec.homepage = "https://gitlab.com/rlees85-ruby/sc2cli/"
20
+ spec.license = "MIT"
21
+
22
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
23
+
24
+ spec.metadata["homepage_uri"] = spec.homepage
25
+ spec.metadata["source_code_uri"] = spec.homepage
26
+
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:archlinux|test|spec|features)/}) or f.match(%r{\Aavatar(?:_group)?\.png\z}) }
29
+ end
30
+
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+ end
35
+
36
+ ###############################################################################
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sc2cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Richard Lees
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A command line utility for accessing the StarCraft 2 API written in Ruby.
14
+ Supports league boundaries, player league details, player match history and more.
15
+ email:
16
+ - git0@bitservices.io
17
+ executables:
18
+ - sc2
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".gitignore"
23
+ - ".gitlab-ci.yml"
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - Rakefile
27
+ - bin/console
28
+ - bin/setup
29
+ - exe/sc2
30
+ - lib/sc2cli.rb
31
+ - lib/sc2cli/shared.rb
32
+ - lib/sc2cli/shared/api.rb
33
+ - lib/sc2cli/shared/cache.rb
34
+ - lib/sc2cli/shared/configuration.rb
35
+ - lib/sc2cli/shared/console.rb
36
+ - lib/sc2cli/shared/names.rb
37
+ - lib/sc2cli/shared/region.rb
38
+ - lib/sc2cli/shared/season.rb
39
+ - lib/sc2cli/shared/token.rb
40
+ - lib/sc2cli/subcommands.rb
41
+ - lib/sc2cli/subcommands/history.rb
42
+ - lib/sc2cli/subcommands/history/historymatch.rb
43
+ - lib/sc2cli/subcommands/history/historymatches.rb
44
+ - lib/sc2cli/subcommands/ladder.rb
45
+ - lib/sc2cli/subcommands/ladder/ladderdetails.rb
46
+ - lib/sc2cli/subcommands/ladder/ladderdetailsmembership.rb
47
+ - lib/sc2cli/subcommands/ladder/ladderdetailsrank.rb
48
+ - lib/sc2cli/subcommands/ladder/ladderdetailsteam.rb
49
+ - lib/sc2cli/subcommands/ladder/ladderdetailsteammember.rb
50
+ - lib/sc2cli/subcommands/ladder/ladderdetailsteammembers.rb
51
+ - lib/sc2cli/subcommands/ladder/ladderdetailsteams.rb
52
+ - lib/sc2cli/subcommands/ladder/laddersummary.rb
53
+ - lib/sc2cli/subcommands/league.rb
54
+ - lib/sc2cli/subcommands/league/leaguetier.rb
55
+ - lib/sc2cli/subcommands/league/leaguetiers.rb
56
+ - lib/sc2cli/subcommands/raw.rb
57
+ - lib/sc2cli/subcommands/season.rb
58
+ - lib/sc2cli/version.rb
59
+ - sc2cli.gemspec
60
+ homepage: https://gitlab.com/rlees85-ruby/sc2cli/
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ homepage_uri: https://gitlab.com/rlees85-ruby/sc2cli/
65
+ source_code_uri: https://gitlab.com/rlees85-ruby/sc2cli/
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.6.0
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubygems_version: 3.2.22
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: A command line utility for accessing the StarCraft 2 API written in Ruby.
85
+ test_files: []