vagrant-timezone 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f5e50694d3d8b0660f8948191821fbe71f9467d
4
- data.tar.gz: 3cf304ddc2e8acef5a127dac46ebd91f70ca1654
3
+ metadata.gz: 3dc9ef7975ca29976ae085bd1c28252c4313af33
4
+ data.tar.gz: da79dd0f54ab3c13b1d5b92e104d13dcc8936b6a
5
5
  SHA512:
6
- metadata.gz: 19d1dc0c714ae91508fa2019ff37675365978d5eea4a9f84ef026529f2ff8e7e62cbb16b929fc54b7c4b98ce1962c75d2bff3b44d2b1d079dcca3c900225fd96
7
- data.tar.gz: 825960e499203d008277a5c1ec1fa5622c8691d833577c97fb156a4a1b0b07b9ff9d618563ee701559c118238430252a069c1f180e9d4f81c809286ac54e4f26
6
+ metadata.gz: 2b4b013626bb6dd6464dfbc092af93cfedbd5742af68cfb0c6b5a350e49e8904de2a2ddd7e8fbca0c34247a7605b0fd3c43c4d5944d386e749d2bcf853649da8
7
+ data.tar.gz: a4763abc1213a5d355fe3161e76036aeab4255483266a721f67d53bbe33dd3937ded25e32539fdcd0c6f809a084e179f0303a3e00015c2151da93613a0c8ac8a
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ sudo: false
2
4
 
3
5
  before_install:
4
6
  - rvm @global do gem uninstall bundler --all --executables
@@ -7,8 +9,8 @@ before_install:
7
9
  - bundle --version
8
10
  bundler_args: --without=development
9
11
 
10
- rvm: 2.0.0
11
- env: VAGRANT_VERSION=v1.7.4
12
+ rvm: 2.2.5
13
+ env: VAGRANT_VERSION=v1.9.1
12
14
  matrix:
13
15
  include:
14
16
  - env: VAGRANT_VERSION=v1.2.7
@@ -1,10 +1,18 @@
1
+ # 1.2.0 / 2017-02-25
2
+
3
+ Features:
4
+
5
+ - Support Windows guests ([GH-4][])
6
+
7
+ [GH-4]: https://github.com/tmatilai/vagrant-timezone/issues/4 "Issue 4"
8
+
1
9
  # 1.1.0 / 2015-10-01
2
10
 
3
11
  Features:
4
12
 
5
13
  - Add option (`config.timezone.value = :host`) to synchronize the guest timezone with the host ([GH-2][])
6
14
 
7
- [GH-2]: https://github.com/tmatilai/vagrant-proxyconf/issues/2 "Issue 2"
15
+ [GH-2]: https://github.com/tmatilai/vagrant-timezone/issues/2 "Issue 2"
8
16
 
9
17
  # 1.0.0 / 2014-10-27
10
18
 
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'vagrant',
4
4
  git: 'https://github.com/mitchellh/vagrant.git',
5
- ref: ENV.fetch('VAGRANT_VERSION', 'v1.7.4')
5
+ tag: ENV.fetch('VAGRANT_VERSION', 'v1.9.1')
6
6
 
7
7
  gem 'rake'
8
8
  gem 'rspec', '~> 3.1'
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2014 Teemu Matilainen <teemu.matilainen@iki.fi>
3
+ Copyright (c) 2014-2017 Teemu Matilainen <teemu.matilainen@iki.fi>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -31,6 +31,8 @@ end
31
31
 
32
32
  The value can be anything that the [tz database supports](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones) (the "TZ" column). For example "UTC" or "Europe/Helsinki".
33
33
 
34
+ For Windows guests the value can be a name in [this table](https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx), or "Etc/GMT`<offset>`" (like with the `:host` value, see the next chapter).
35
+
34
36
  ### Matching the Host Timezone
35
37
 
36
38
  If the special symbol `:host` is passed at the parameter (`config.timezone.value = :host`), the plugin will attempt to set the guest timezone offset to match the current offset of the host. Because of limitations in Ruby's ability to get the named timezone from the host, it will instead convert the host's timezone offset to a calculated offset from UTC. So for example, on the west coast of the USA the calculated timezone might be `Etc/GMT+8`. After a change in the host's timezone (including a change due to Daylight Savings Time taking effect), the next time the Vagrantfile is run the guest clock will be updated to match. Note that this functionality has only been tested with an OS X host and Linux guest.
@@ -55,3 +57,9 @@ At the moment the supported platforms include:
55
57
  * NetBSD
56
58
  * OpenBSD
57
59
  * OS X
60
+
61
+ - Windows
62
+
63
+ ## Development
64
+
65
+ As Vagrant bundles Ruby, the same version should be used when developing this plugin. For example Vagrant 1.9 comes with Ruby 2.2.
@@ -0,0 +1,53 @@
1
+ module VagrantPlugins
2
+ module TimeZone
3
+ module Cap
4
+ # Generic Windows capabilities for changing time zone
5
+ class Windows
6
+ # Set the time zone
7
+ def self.change_timezone(machine, timezone)
8
+ machine.communicate.sudo(
9
+ "tzutil /s \"#{timezone_name(timezone)}\"",
10
+ shell: 'powershell'
11
+ )
12
+ end
13
+
14
+ # If the specified timezone is in format like "Etc/GMT+8", returns the
15
+ # matching timezone name. Otherwise just returns the passed timezone.
16
+ def self.timezone_name(timezone)
17
+ if %r{^Etc/GMT(?<offset>[+-]\d+)$} =~ timezone
18
+ TIMEZONE_NAMES.fetch(offset)
19
+ else
20
+ timezone
21
+ end
22
+ end
23
+
24
+ TIMEZONE_NAMES = {
25
+ '-12' => 'Dateline Standard Time',
26
+ '-11' => 'UTC-11',
27
+ '-10' => 'Hawaiian Standard Time',
28
+ '-9' => 'Alaskan Standard Time',
29
+ '-8' => 'Pacific Standard Time',
30
+ '-7' => 'Mountain Standard Time',
31
+ '-6' => 'Central Standard Time',
32
+ '-5' => 'Eastern Standard Time',
33
+ '-4' => 'Atlantic Standard Time',
34
+ '-3' => 'Greenland Standard Time',
35
+ '-2' => 'UTC-02',
36
+ '-1' => 'Azores Standard Time',
37
+ '+0' => 'UTC',
38
+ '+1' => 'Central Europe Standard Time',
39
+ '+2' => 'E. Europe Standard Time',
40
+ '+3' => 'Russian Standard Time',
41
+ '+4' => 'Arabian Standard Time',
42
+ '+5' => 'Pakistan Standard Time',
43
+ '+6' => 'Central Asia Standard Time',
44
+ '+7' => 'SE Asia Standard Time',
45
+ '+8' => 'China Standard Time',
46
+ '+9' => 'Tokyo Standard Time',
47
+ '+10' => 'E. Australia Standard Time',
48
+ '+11' => 'Central Pacific Standard Time'
49
+ }.freeze
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,5 +1,4 @@
1
1
  require 'vagrant'
2
- require 'time'
3
2
 
4
3
  module VagrantPlugins
5
4
  module TimeZone
@@ -7,7 +6,7 @@ module VagrantPlugins
7
6
  #
8
7
  # @!parse class Config < Vagrant::Plugin::V2::Config; end
9
8
  class Config < Vagrant.plugin('2', :config)
10
- attr_reader :value
9
+ attr_accessor :value
11
10
 
12
11
  def initialize
13
12
  super
@@ -15,25 +14,21 @@ module VagrantPlugins
15
14
  @value = UNSET_VALUE
16
15
  end
17
16
 
18
- def value= value
19
- if value == :host
17
+ def finalize!
18
+ super
19
+
20
+ if @value == UNSET_VALUE
21
+ @value = nil
22
+ elsif @value == :host
20
23
  # Get the offset of the current timezone of the host. Ruby doesn't reliably
21
24
  # detect the named timezone, so we have to use the hour offset. Note that when
22
25
  # DST changes, etc, this offset will change.
23
26
 
24
27
  # We set timezone offset negative to match POSIX standards
25
28
  # https://github.com/eggert/tz/blob/master/etcetera
26
- @value = sprintf("Etc/GMT%+d", -((Time.zone_offset(Time.now.zone)/60)/60))
27
- else
28
- @value = value
29
+ @value = sprintf('Etc/GMT%+d', -(Time.now.utc_offset/3600))
29
30
  end
30
31
  end
31
-
32
- def finalize!
33
- super
34
-
35
- @value = nil if @value == UNSET_VALUE
36
- end
37
32
  end
38
33
  end
39
34
  end
@@ -103,6 +103,11 @@ module VagrantPlugins
103
103
  require_relative 'cap/redhat'
104
104
  Cap::RedHat
105
105
  end
106
+
107
+ guest_capability 'windows', 'change_timezone' do
108
+ require_relative 'cap/windows'
109
+ Cap::Windows
110
+ end
106
111
  end
107
112
  end
108
113
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module TimeZone
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
@@ -1,14 +1,3 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
- SimpleCov::Formatter::HTMLFormatter,
5
- Coveralls::SimpleCov::Formatter
6
- ]
7
- SimpleCov.start do
8
- coverage_dir('tmp/coverage')
9
- add_filter '/spec/'
10
- end
11
-
12
1
  RSpec.configure do |config|
13
2
  config.expect_with :rspec do |c|
14
3
  c.syntax = :expect
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-timezone/cap/windows'
3
+
4
+ describe VagrantPlugins::TimeZone::Cap::Windows do
5
+ subject { described_class }
6
+
7
+ describe '.timezone_name' do
8
+ context 'with Etc/GMT format' do
9
+ it 'returns the timezone name for negative offset' do
10
+ expect(subject.timezone_name('Etc/GMT-10')).to eq 'Hawaiian Standard Time'
11
+ end
12
+
13
+ it 'returns the timezone name for positive offset' do
14
+ expect(subject.timezone_name('Etc/GMT+10')).to eq 'E. Australia Standard Time'
15
+ end
16
+ end
17
+
18
+ context 'with unknown format' do
19
+ it 'returns the specied timezone unchanged' do
20
+ expect(subject.timezone_name('UTC')).to eq 'UTC'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-timezone/config'
3
+
4
+ describe VagrantPlugins::TimeZone::Config do
5
+ subject { described_class.new }
6
+
7
+ describe '#value' do
8
+ it 'defaults to nil' do
9
+ subject.finalize!
10
+ expect(subject.value).to be(nil)
11
+ end
12
+
13
+ it 'can be set' do
14
+ subject.value = 'FOO'
15
+ subject.finalize!
16
+ expect(subject.value).to eq('FOO')
17
+ end
18
+
19
+ it 'can be set' do
20
+ subject.value = 'FOO'
21
+ subject.finalize!
22
+ expect(subject.value).to eq('FOO')
23
+ end
24
+
25
+ it 'converts `:host` to the zone of the host' do
26
+ allow(Time).to receive(:now).and_return(Time.new(2016,7,10,2,12,0, '+03:00'))
27
+ subject.value = :host
28
+ subject.finalize!
29
+ expect(subject.value).to eq('Etc/GMT-3')
30
+ end
31
+ end
32
+ end
@@ -6,13 +6,22 @@ require 'vagrant-timezone/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'vagrant-timezone'
8
8
  spec.version = VagrantPlugins::TimeZone::VERSION
9
- spec.authors = ['Teemu Matilainen']
10
- spec.email = ['teemu.matilainen@iki.fi']
11
9
  spec.description = 'A Vagrant plugin that configures the time zone of a virtual machine'
12
10
  spec.summary = spec.description
13
11
  spec.homepage = 'http://github.com/tmatilai/vagrant-timezone'
14
12
  spec.license = 'MIT'
15
13
 
14
+ spec.authors = [
15
+ 'Teemu Matilainen',
16
+ 'Kyle Corbitt',
17
+ 'Robert R. Meyer'
18
+ ]
19
+ spec.email = [
20
+ 'teemu.matilainen@iki.fi',
21
+ 'kyle@corbt.com',
22
+ 'Blue.Dog.Archolite@gmail.com'
23
+ ]
24
+
16
25
  spec.files = `git ls-files`.split($/)
17
26
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
27
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
metadata CHANGED
@@ -1,18 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-timezone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Teemu Matilainen
8
+ - Kyle Corbitt
9
+ - Robert R. Meyer
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
13
+ date: 2017-02-25 00:00:00.000000000 Z
12
14
  dependencies: []
13
15
  description: A Vagrant plugin that configures the time zone of a virtual machine
14
16
  email:
15
17
  - teemu.matilainen@iki.fi
18
+ - kyle@corbt.com
19
+ - Blue.Dog.Archolite@gmail.com
16
20
  executables: []
17
21
  extensions: []
18
22
  extra_rdoc_files: []
@@ -32,12 +36,15 @@ files:
32
36
  - lib/vagrant-timezone/cap/gentoo.rb
33
37
  - lib/vagrant-timezone/cap/redhat.rb
34
38
  - lib/vagrant-timezone/cap/unix.rb
39
+ - lib/vagrant-timezone/cap/windows.rb
35
40
  - lib/vagrant-timezone/config.rb
36
41
  - lib/vagrant-timezone/logger.rb
37
42
  - lib/vagrant-timezone/plugin.rb
38
43
  - lib/vagrant-timezone/version.rb
39
44
  - locales/en.yml
40
45
  - spec/spec_helper.rb
46
+ - spec/unit/vagrant-timezone/cap/windows_spec.rb
47
+ - spec/unit/vagrant-timezone/config_spec.rb
41
48
  - vagrant-timezone.gemspec
42
49
  homepage: http://github.com/tmatilai/vagrant-timezone
43
50
  licenses:
@@ -59,9 +66,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
66
  version: '0'
60
67
  requirements: []
61
68
  rubyforge_project:
62
- rubygems_version: 2.4.5.1
69
+ rubygems_version: 2.6.10
63
70
  signing_key:
64
71
  specification_version: 4
65
72
  summary: A Vagrant plugin that configures the time zone of a virtual machine
66
73
  test_files:
67
74
  - spec/spec_helper.rb
75
+ - spec/unit/vagrant-timezone/cap/windows_spec.rb
76
+ - spec/unit/vagrant-timezone/config_spec.rb