hotdog 0.13.0 → 0.14.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: edea5108e33e32670a80a206e1dbde6fa4810d00
4
- data.tar.gz: 56538e388dd9a43a987ade29b48c241ec3c17c2e
3
+ metadata.gz: 4f3141bb4b97ec0c63dc50eae72bd1cf5d44c148
4
+ data.tar.gz: 548009a66b40670fa5d2a0c3d81616fe1f4c759f
5
5
  SHA512:
6
- metadata.gz: 4646c09bac8ae0384e2fdf239776628724a34cfce6e42c734886d7c19f490285e5c850e064f3c31e0157ec4ad0f7ef09c9beaac7c402f7b85f64bb8436ac8331
7
- data.tar.gz: 071de235c649f8bb57800d0ad5621588c58db07595456e51664d8ef1eac8c0bd669327d4886af6869e79cb592e1fcffd5444ceaf8cfba7230d3c1eaffc855fb7
6
+ metadata.gz: 6e6d38e556cbfcb953e9affa5890ecd34fc9dc91dd5eb5bba48f1ed661d5fbe8b15c87157257f428cf9ddb26aa434f9bea91cdb9f3bf39bb8a4658929af285ad
7
+ data.tar.gz: 52b4f24c92001e3ebf55f6a527af9d0f2454476ceba4f46edc307dc72dc30a9787f0cad71a7a23b783c7dab4eee420998f05c7ed1b89faa489369ce42d78c05a
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1.6
4
- - 2.2.3
5
- - 2.3.0
4
+ - 2.2.5
5
+ - 2.3.1
6
6
  script:
7
7
  - rspec spec
8
8
  sudo: false
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "fileutils"
4
+
5
+ module Hotdog
6
+ module Commands
7
+ class Tag < BaseCommand
8
+ def define_options(optparse, options={})
9
+ default_option(options, :tags, [])
10
+ optparse.on("--tag TAG") do |v|
11
+ options[:tags] << v
12
+ end
13
+ end
14
+
15
+ def run(args=[], options={})
16
+ args.each do |host_name|
17
+ host_name = host_name.sub(/\Ahost:/, "")
18
+
19
+ if options[:tags].empty?
20
+ # nop
21
+ else
22
+ # add all as user tags
23
+ code, add_tags = dog.add_tags(host_name, options[:tags], source="user")
24
+ if code.to_i / 100 != 2
25
+ raise("dog.add_tags(#{host_name.inspect}, #{options[:tags].inspect}, source=\"user\") returns [#{code.inspect}, #{add_tags.inspect}]")
26
+ end
27
+ end
28
+ end
29
+
30
+ # Remove persistent.db to schedule update on next invocation
31
+ if @db
32
+ close_db(@db)
33
+ end
34
+ FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ # vim:set ft=ruby :
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "fileutils"
4
+
5
+ module Hotdog
6
+ module Commands
7
+ class Untag < BaseCommand
8
+ def define_options(optparse, options={})
9
+ default_option(options, :tags, [])
10
+ optparse.on("--tag TAG") do |v|
11
+ options[:tags] << v
12
+ end
13
+ end
14
+
15
+ def run(args=[], options={})
16
+ args.each do |host_name|
17
+ host_name = host_name.sub(/\Ahost:/, "")
18
+
19
+ if options[:tags].empty?
20
+ # delete all user tags
21
+ code, detach_tags = dog.detach_tags(host_name, source="user")
22
+ if code.to_i / 100 != 2
23
+ raise("dog.detach_tags(#{host_name.inspect}, source=\"user\") returns [#{code.inspect}, #{detach_tags.inspect}]")
24
+ end
25
+ else
26
+ code, host_tags = dog.host_tags(host_name, source="user")
27
+ if code.to_i / 100 != 2
28
+ raise("dog.host_tags(#{host_name.inspect}, source=\"user\") returns [#{code.inspect}, #{host_tags.inspect}]")
29
+ end
30
+ old_tags = host_tags["tags"]
31
+ new_tags = old_tags - options[:tags]
32
+ if old_tags == new_tags
33
+ # nop
34
+ else
35
+ code, update_tags = dog.update_tags(host_name, new_tags, source="user")
36
+ if code.to_i / 100 != 2
37
+ raise("dog.update_tags(#{host_name.inspect}, #{new_tags.inspect}, source=\"user\") returns [#{code.inspect}, #{update_tags.inspect}]")
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ # Remove persistent.db to schedule update on next invocation
44
+ if @db
45
+ close_db(@db)
46
+ end
47
+ FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ # vim:set ft=ruby :
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.13.0"
2
+ VERSION = "0.14.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamashita Yuu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-26 00:00:00.000000000 Z
11
+ date: 2016-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -179,7 +179,9 @@ files:
179
179
  - lib/hotdog/commands/search.rb
180
180
  - lib/hotdog/commands/sftp.rb
181
181
  - lib/hotdog/commands/ssh.rb
182
+ - lib/hotdog/commands/tag.rb
182
183
  - lib/hotdog/commands/tags.rb
184
+ - lib/hotdog/commands/untag.rb
183
185
  - lib/hotdog/commands/up.rb
184
186
  - lib/hotdog/commands/version.rb
185
187
  - lib/hotdog/expression.rb