lita-digitalocean 1.0.0 → 2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ceb867fa1a82a608494d9af9340cc2a9f2ccff2f
4
- data.tar.gz: 79c78fd54b3ba4fb044e71c2d3687909c594af7f
3
+ metadata.gz: 897834e48fba0df1715fc70d3b6ae15a5fea915e
4
+ data.tar.gz: 9c478b4e84b69afd2d306fae75d079ddefea192c
5
5
  SHA512:
6
- metadata.gz: 28c176473b7afe92034be4a40e66855264a7d6f2281b8760a1e8dd99eca7566c1997aa3daf58caf3b97a821ff74a802c8843d80166825c8e890fe6c47a9867fb
7
- data.tar.gz: 6d9cda0c6800bee0cec9c2a015dbfd71eb7ec9b8c6d9d7c1573d2550f81a51c9bc9a0c99ef12c6fd542c082650c30fad628a41a0090436070e126a0ed48eafd0
6
+ metadata.gz: aac5a9f7feccc0bccce84bc9449686b394386b357d826f46cb6dde08622b75a67068a4c39a4d600d4f280972f3851efc03e21f40a57e0e6d62929f9e5c4ab376
7
+ data.tar.gz: e2240a4b0be9966fb88f0abe68e408553e48c35d8963b2dcb47756280bfd5bf5b3c869f6303235579e55b4976641725ce3a5f6da57034ead7b4c26b9a433ee5a
@@ -1,10 +1,8 @@
1
1
  module Lita
2
2
  module Handlers
3
3
  class Digitalocean < Handler
4
- def self.default_config(config)
5
- config.client_id = nil
6
- config.api_key = nil
7
- end
4
+ config :client_id, type: String, required: true
5
+ config :api_key, type: String, required: true
8
6
  end
9
7
 
10
8
  Lita.register_handler(Digitalocean)
@@ -6,10 +6,7 @@ module Lita
6
6
  module Handlers
7
7
  class Digitalocean < Handler
8
8
  class Base < Handler
9
- # Override key for locale namespace.
10
- def self.name
11
- "Digitalocean"
12
- end
9
+ namespace "digitalocean"
13
10
 
14
11
  private
15
12
 
@@ -2,6 +2,8 @@ module Lita
2
2
  module Handlers
3
3
  class Digitalocean < Handler
4
4
  class Domain < Base
5
+ namespace "digitalocean"
6
+
5
7
  do_route /^do\s+domains?\s+create\s+[^\s]+\s+[^\s]+$/i, :create, {
6
8
  t("help.domains.create_key") => t("help.domains.create_value")
7
9
  }
@@ -2,6 +2,8 @@ module Lita
2
2
  module Handlers
3
3
  class Digitalocean < Handler
4
4
  class DomainRecord < Base
5
+ namespace "digitalocean"
6
+
5
7
  do_route /^do\s+domain\s+records?\s+create\s(?:[^\s]+\s+){2}[^\s]/i, :create, {
6
8
  t("help.domain_records.create_key") => t("help.domain_records.create_value")
7
9
  }, {
@@ -2,6 +2,8 @@ module Lita
2
2
  module Handlers
3
3
  class Digitalocean < Handler
4
4
  class Droplet < Base
5
+ namespace "digitalocean"
6
+
5
7
  do_route /^do\s+droplets?\s+create(?:\s+[^\s]+){4}/i, :create, {
6
8
  t("help.droplets.create_key") => t("help.droplets.create_value")
7
9
  }, {
@@ -2,6 +2,8 @@ module Lita
2
2
  module Handlers
3
3
  class Digitalocean < Handler
4
4
  class Image < Base
5
+ namespace "digitalocean"
6
+
5
7
  do_route /^do\s+images?\s+delete\s+([^\s]+)$/i, :delete, {
6
8
  t("help.images.delete_key") => t("help.images.delete_value")
7
9
  }
@@ -2,6 +2,8 @@ module Lita
2
2
  module Handlers
3
3
  class Digitalocean < Handler
4
4
  class Region < Base
5
+ namespace "digitalocean"
6
+
5
7
  do_route /^do\s+regions?\s+list$/i, :list, {
6
8
  t("help.regions.list_key") => t("help.regions.list_value")
7
9
  }
@@ -2,6 +2,8 @@ module Lita
2
2
  module Handlers
3
3
  class Digitalocean < Handler
4
4
  class Size < Base
5
+ namespace "digitalocean"
6
+
5
7
  do_route /^do\s+sizes\s+list$/, :list, {
6
8
  t("help.sizes.list_key") => t("help.sizes.list_value")
7
9
  }
@@ -2,6 +2,8 @@ module Lita
2
2
  module Handlers
3
3
  class Digitalocean < Handler
4
4
  class SSHKey < Base
5
+ namespace "digitalocean"
6
+
5
7
  do_route /^do\s+ssh\s+keys?\s+add\s+.+$/i, :add, {
6
8
  t("help.ssh_keys.add_key") => t("help.ssh_keys.add_value")
7
9
  }
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-digitalocean"
3
- spec.version = "1.0.0"
3
+ spec.version = "2.0.0"
4
4
  spec.authors = ["Jimmy Cuadra"]
5
5
  spec.email = ["jimmy@jimmycuadra.com"]
6
6
  spec.description = %q{A Lita handler for managing DigitalOcean services.}
@@ -14,13 +14,13 @@ Gem::Specification.new do |spec|
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
15
  spec.require_paths = ["lib"]
16
16
 
17
- spec.add_runtime_dependency "lita", ">= 3.2"
17
+ spec.add_runtime_dependency "lita", ">= 4.0"
18
18
  spec.add_runtime_dependency "lita-keyword-arguments"
19
19
  spec.add_runtime_dependency "digital_ocean", ">= 1.5.0"
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
23
+ spec.add_development_dependency "rspec", ">= 3.0.0"
24
24
  spec.add_development_dependency "simplecov"
25
25
  spec.add_development_dependency "coveralls"
26
26
  end
@@ -1,10 +1,9 @@
1
1
  require "spec_helper"
2
2
 
3
3
  handler_class = Class.new(Lita::Handlers::Digitalocean::Base) do
4
- route /do droplets list/, :list, command: true
4
+ namespace "digitalocean"
5
5
 
6
- def self.default_config(config)
7
- end
6
+ route /do droplets list/, :list, command: true
8
7
 
9
8
  def list(response)
10
9
  do_call(response) do |client|
@@ -15,19 +14,8 @@ end
15
14
 
16
15
  describe handler_class, lita_handler: true do
17
16
  describe "#do_call" do
18
- it "responds with an error if the DigitalOcean API key is not set" do
19
- send_command("do droplets list")
20
- expect(replies.last).to include("client_id and api_key must be set")
21
- end
22
-
23
- it "responds with an error if the DigitalOcean client ID is not set" do
24
- Lita.config.handlers.digitalocean.api_key = "secret"
25
- send_command("do droplets list")
26
- expect(replies.last).to include("client_id and api_key must be set")
27
- end
28
-
29
17
  it "responds with an error if the DigitalOcean API responds with an error" do
30
- Lita.config.handlers.digitalocean.tap do |config|
18
+ registry.config.handlers.digitalocean.tap do |config|
31
19
  config.api_key = "secret"
32
20
  config.client_id = "secret"
33
21
  end
@@ -2,33 +2,29 @@ require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Digitalocean::DomainRecord, lita_handler: true do
4
4
  it do
5
- routes_command(
5
+ is_expected.to route_command(
6
6
  "do domain records create example.com txt 'some value' --name example.com"
7
7
  ).to(:create)
8
8
  end
9
- it { routes_command("do domain records delete example.com 123").to(:delete) }
9
+ it { is_expected.to route_command("do domain records delete example.com 123").to(:delete) }
10
10
  it do
11
- routes_command(
11
+ is_expected.to route_command(
12
12
  "do domain records edit example.com 123 txt 'some value' name=example.com"
13
13
  ).to(:edit)
14
14
  end
15
- it { routes_command("do domain records list example.com").to(:list) }
16
- it { routes_command("do domain records show example.com 123").to(:show) }
15
+ it { is_expected.to route_command("do domain records list example.com").to(:list) }
16
+ it { is_expected.to route_command("do domain records show example.com 123").to(:show) }
17
17
 
18
18
  let(:client) { instance_double("::DigitalOcean::API", domains: client_domains) }
19
19
  let(:client_domains) { instance_double("::DigitalOcean::Resource::Domain") }
20
20
 
21
21
  before do
22
- Lita.config.handlers.digitalocean = Lita::Config.new
23
- Lita.config.handlers.digitalocean.tap do |config|
22
+ registry.config.handlers.digitalocean.tap do |config|
24
23
  config.client_id = "CLIENT_ID"
25
24
  config.api_key = "API_KEY"
26
25
  end
27
26
 
28
- allow(Lita::Authorization).to receive(:user_in_group?).with(
29
- user,
30
- :digitalocean_admins
31
- ).and_return(true)
27
+ robot.auth.add_user_to_group!(user, :digitalocean_admins)
32
28
 
33
29
  allow(::DigitalOcean::API).to receive(:new).and_return(client)
34
30
  end
@@ -1,25 +1,21 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Digitalocean::Domain, lita_handler: true do
4
- it { routes_command("do domains create example.com 10.10.10.10").to(:create) }
5
- it { routes_command("do domains delete example.com").to(:delete) }
6
- it { routes_command("do domains list").to(:list) }
7
- it { routes_command("do domains show example.com").to(:show) }
4
+ it { is_expected.to route_command("do domains create example.com 10.10.10.10").to(:create) }
5
+ it { is_expected.to route_command("do domains delete example.com").to(:delete) }
6
+ it { is_expected.to route_command("do domains list").to(:list) }
7
+ it { is_expected.to route_command("do domains show example.com").to(:show) }
8
8
 
9
9
  let(:client) { instance_double("::DigitalOcean::API", domains: client_domains) }
10
10
  let(:client_domains) { instance_double("::DigitalOcean::Resource::Domain") }
11
11
 
12
12
  before do
13
- Lita.config.handlers.digitalocean = Lita::Config.new
14
- Lita.config.handlers.digitalocean.tap do |config|
13
+ registry.config.handlers.digitalocean.tap do |config|
15
14
  config.client_id = "CLIENT_ID"
16
15
  config.api_key = "API_KEY"
17
16
  end
18
17
 
19
- allow(Lita::Authorization).to receive(:user_in_group?).with(
20
- user,
21
- :digitalocean_admins
22
- ).and_return(true)
18
+ robot.auth.add_user_to_group!(user, :digitalocean_admins)
23
19
 
24
20
  allow(::DigitalOcean::API).to receive(:new).and_return(client)
25
21
  end
@@ -2,24 +2,24 @@ require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Digitalocean::Droplet, lita_handler: true do
4
4
  it do
5
- routes_command(
5
+ is_expected.to route_command(
6
6
  "do droplets create example.com 512mb centos-5-8-x64 nyc1"
7
7
  ).to(:create)
8
8
  end
9
- it { routes_command("do droplets delete 123").to(:delete) }
10
- it { routes_command("do droplets delete 123 --scrub").to(:delete) }
11
- it { routes_command("do droplets list").to(:list) }
12
- it { routes_command("do droplets password reset 123").to(:password_reset) }
13
- it { routes_command("do droplets power cycle 123").to(:power_cycle) }
14
- it { routes_command("do droplets power off 123").to(:power_off) }
15
- it { routes_command("do droplets power on 123").to(:power_on) }
16
- it { routes_command("do droplets reboot 123").to(:reboot) }
17
- it { routes_command("do droplets rebuild 123 456").to(:rebuild) }
18
- it { routes_command("do droplets resize 123 1gb").to(:resize) }
19
- it { routes_command("do droplets restore 123 456").to(:restore) }
20
- it { routes_command("do droplets show 123").to(:show) }
21
- it { routes_command("do droplets shutdown 123").to(:shutdown) }
22
- it { routes_command("do droplets snapshot 123 'My Snapshot'").to(:snapshot) }
9
+ it { is_expected.to route_command("do droplets delete 123").to(:delete) }
10
+ it { is_expected.to route_command("do droplets delete 123 --scrub").to(:delete) }
11
+ it { is_expected.to route_command("do droplets list").to(:list) }
12
+ it { is_expected.to route_command("do droplets password reset 123").to(:password_reset) }
13
+ it { is_expected.to route_command("do droplets power cycle 123").to(:power_cycle) }
14
+ it { is_expected.to route_command("do droplets power off 123").to(:power_off) }
15
+ it { is_expected.to route_command("do droplets power on 123").to(:power_on) }
16
+ it { is_expected.to route_command("do droplets reboot 123").to(:reboot) }
17
+ it { is_expected.to route_command("do droplets rebuild 123 456").to(:rebuild) }
18
+ it { is_expected.to route_command("do droplets resize 123 1gb").to(:resize) }
19
+ it { is_expected.to route_command("do droplets restore 123 456").to(:restore) }
20
+ it { is_expected.to route_command("do droplets show 123").to(:show) }
21
+ it { is_expected.to route_command("do droplets shutdown 123").to(:shutdown) }
22
+ it { is_expected.to route_command("do droplets snapshot 123 'My Snapshot'").to(:snapshot) }
23
23
 
24
24
  let(:client) { instance_double("::DigitalOcean::API", droplets: client_droplets) }
25
25
  let(:client_droplets) { instance_double("::DigitalOcean::Resource::Droplet") }
@@ -27,16 +27,12 @@ describe Lita::Handlers::Digitalocean::Droplet, lita_handler: true do
27
27
  let(:do_ok) { { status: "OK" } }
28
28
 
29
29
  before do
30
- Lita.config.handlers.digitalocean = Lita::Config.new
31
- Lita.config.handlers.digitalocean.tap do |config|
30
+ registry.config.handlers.digitalocean.tap do |config|
32
31
  config.client_id = "CLIENT_ID"
33
32
  config.api_key = "API_KEY"
34
33
  end
35
34
 
36
- allow(Lita::Authorization).to receive(:user_in_group?).with(
37
- user,
38
- :digitalocean_admins
39
- ).and_return(true)
35
+ robot.auth.add_user_to_group!(user, :digitalocean_admins)
40
36
 
41
37
  allow(::DigitalOcean::API).to receive(:new).and_return(client)
42
38
  end
@@ -1,25 +1,21 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Digitalocean::Image, lita_handler: true do
4
- it { routes_command("do images delete 123").to(:delete) }
5
- it { routes_command("do images list").to(:list) }
6
- it { routes_command("do images list filter").to(:list) }
7
- it { routes_command("do images show 123").to(:show) }
4
+ it { is_expected.to route_command("do images delete 123").to(:delete) }
5
+ it { is_expected.to route_command("do images list").to(:list) }
6
+ it { is_expected.to route_command("do images list filter").to(:list) }
7
+ it { is_expected.to route_command("do images show 123").to(:show) }
8
8
 
9
9
  let(:client) { instance_double("::DigitalOcean::API", images: client_images) }
10
10
  let(:client_images) { instance_double("::DigitalOcean::Resource::Image") }
11
11
 
12
12
  before do
13
- Lita.config.handlers.digitalocean = Lita::Config.new
14
- Lita.config.handlers.digitalocean.tap do |config|
13
+ registry.config.handlers.digitalocean.tap do |config|
15
14
  config.client_id = "CLIENT_ID"
16
15
  config.api_key = "API_KEY"
17
16
  end
18
17
 
19
- allow(Lita::Authorization).to receive(:user_in_group?).with(
20
- user,
21
- :digitalocean_admins
22
- ).and_return(true)
18
+ robot.auth.add_user_to_group!(user, :digitalocean_admins)
23
19
 
24
20
  allow(::DigitalOcean::API).to receive(:new).and_return(client)
25
21
  end
@@ -1,22 +1,18 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Digitalocean::Region, lita_handler: true do
4
- it { routes_command("do regions list").to(:list) }
4
+ it { is_expected.to route_command("do regions list").to(:list) }
5
5
 
6
6
  let(:client) { instance_double("::DigitalOcean::API", regions: client_regions) }
7
7
  let(:client_regions) { instance_double("::DigitalOcean::Resource::Region") }
8
8
 
9
9
  before do
10
- Lita.config.handlers.digitalocean = Lita::Config.new
11
- Lita.config.handlers.digitalocean.tap do |config|
10
+ registry.config.handlers.digitalocean.tap do |config|
12
11
  config.client_id = "CLIENT_ID"
13
12
  config.api_key = "API_KEY"
14
13
  end
15
14
 
16
- allow(Lita::Authorization).to receive(:user_in_group?).with(
17
- user,
18
- :digitalocean_admins
19
- ).and_return(true)
15
+ robot.auth.add_user_to_group!(user, :digitalocean_admins)
20
16
 
21
17
  allow(::DigitalOcean::API).to receive(:new).and_return(client)
22
18
  end
@@ -1,22 +1,18 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Digitalocean::Size, lita_handler: true do
4
- it { routes_command("do sizes list").to(:list) }
4
+ it { is_expected.to route_command("do sizes list").to(:list) }
5
5
 
6
6
  let(:client) { instance_double( "::DigitalOcean::API", sizes: client_sizes) }
7
7
  let(:client_sizes) { instance_double("::DigitalOcean::Resource::Size") }
8
8
 
9
9
  before do
10
- Lita.config.handlers.digitalocean = Lita::Config.new
11
- Lita.config.handlers.digitalocean.tap do |config|
10
+ registry.config.handlers.digitalocean.tap do |config|
12
11
  config.client_id = "CLIENT_ID"
13
12
  config.api_key = "API_KEY"
14
13
  end
15
14
 
16
- allow(Lita::Authorization).to receive(:user_in_group?).with(
17
- user,
18
- :digitalocean_admins
19
- ).and_return(true)
15
+ robot.auth.add_user_to_group!(user, :digitalocean_admins)
20
16
 
21
17
  allow(::DigitalOcean::API).to receive(:new).and_return(client)
22
18
  end
@@ -1,30 +1,26 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Handlers::Digitalocean::SSHKey, lita_handler: true do
4
- it { routes_command("do ssh keys add 'foo bar' 'ssh-rsa abcdefg'").to(:add) }
5
- it { routes_command("do ssh keys delete 123").to(:delete) }
4
+ it { is_expected.to route_command("do ssh keys add 'foo bar' 'ssh-rsa abcdefg'").to(:add) }
5
+ it { is_expected.to route_command("do ssh keys delete 123").to(:delete) }
6
6
  it do
7
- routes_command(
7
+ is_expected.to route_command(
8
8
  "do ssh keys edit 123 --name foo --public-key 'ssh-rsa changed'"
9
9
  ).to(:edit)
10
10
  end
11
- it { routes_command("do ssh keys list").to(:list) }
12
- it { routes_command("do ssh keys show 123").to(:show) }
11
+ it { is_expected.to route_command("do ssh keys list").to(:list) }
12
+ it { is_expected.to route_command("do ssh keys show 123").to(:show) }
13
13
 
14
14
  let(:client) { instance_double("::DigitalOcean::API", ssh_keys: client_ssh_keys) }
15
15
  let(:client_ssh_keys) { instance_double("::DigitalOcean::Resource::SSHKey") }
16
16
 
17
17
  before do
18
- Lita.config.handlers.digitalocean = Lita::Config.new
19
- Lita.config.handlers.digitalocean.tap do |config|
18
+ registry.config.handlers.digitalocean.tap do |config|
20
19
  config.client_id = "CLIENT_ID"
21
20
  config.api_key = "API_KEY"
22
21
  end
23
22
 
24
- allow(Lita::Authorization).to receive(:user_in_group?).with(
25
- user,
26
- :digitalocean_admins
27
- ).and_return(true)
23
+ robot.auth.add_user_to_group!(user, :digitalocean_admins)
28
24
 
29
25
  allow(::DigitalOcean::API).to receive(:new).and_return(client)
30
26
  end
data/spec/spec_helper.rb CHANGED
@@ -8,3 +8,11 @@ SimpleCov.start { add_filter "/spec/" }
8
8
 
9
9
  require "lita-digitalocean"
10
10
  require "lita/rspec"
11
+
12
+ Lita.version_3_compatibility_mode = false
13
+
14
+ RSpec.configure do |config|
15
+ config.before do
16
+ registry.register_hook(:trigger_route, Lita::Extensions::KeywordArguments)
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-digitalocean
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Cuadra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: lita-keyword-arguments
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 3.0.0.beta2
89
+ version: 3.0.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 3.0.0.beta2
96
+ version: 3.0.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement