bigquery_migration 0.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ require 'tzinfo'
2
+
3
+ class BigqueryMigration
4
+ class TimeWithZone
5
+ # [+-]HH:MM, [+-]HHMM, [+-]HH
6
+ NUMERIC_PATTERN = %r{\A[+-]\d\d(:?\d\d)?\z}
7
+
8
+ # Region/Zone, Region/Zone/Zone
9
+ NAME_PATTERN = %r{\A[^/]+/[^/]+(/[^/]+)?\z}
10
+
11
+ class << self
12
+ def time_with_zone(time, timezone)
13
+ time.localtime(zone_offset(timezone))
14
+ end
15
+
16
+ def strptime_with_zone(date, format, timezone)
17
+ time = Time.strptime(date, format)
18
+ _utc_offset = time.utc_offset
19
+ _zone_offset = zone_offset(timezone)
20
+ time.localtime(_zone_offset) + _utc_offset - _zone_offset
21
+ end
22
+
23
+ private
24
+ def zone_offset(timezone)
25
+ if NUMERIC_PATTERN === timezone
26
+ Time.zone_offset(timezone)
27
+ elsif NAME_PATTERN === timezone
28
+ tz = TZInfo::Timezone.get(timezone)
29
+ tz.current_period.utc_total_offset
30
+ elsif "UTC" == timezone # special treatment
31
+ 0
32
+ else
33
+ raise ArgumentError, "timezone format is invalid: #{timezone}"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ class BigqueryMigration
2
+ VERSION = "0.1.0.pre1"
3
+ end
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bigquery_migration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre1
5
+ platform: ruby
6
+ authors:
7
+ - Naotoshi Seo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-api-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tzinfo
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-unit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: test-unit-rr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: test-unit-power_assert
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Migrate BigQuery table schema.
126
+ email:
127
+ - sonots@gmail.com
128
+ executables:
129
+ - bq_migrate
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - CODE_OF_CONDUCT.md
137
+ - Gemfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - bigquery_migration.gemspec
142
+ - bin/console
143
+ - bin/setup
144
+ - example/example.yml
145
+ - example/schema.json
146
+ - exe/bq_migrate
147
+ - lib/bigquery_migration.rb
148
+ - lib/bigquery_migration/action.rb
149
+ - lib/bigquery_migration/action_runner.rb
150
+ - lib/bigquery_migration/bigquery_wrapper.rb
151
+ - lib/bigquery_migration/cli.rb
152
+ - lib/bigquery_migration/config_loader.rb
153
+ - lib/bigquery_migration/error.rb
154
+ - lib/bigquery_migration/hash_util.rb
155
+ - lib/bigquery_migration/logger.rb
156
+ - lib/bigquery_migration/schema.rb
157
+ - lib/bigquery_migration/time_with_zone.rb
158
+ - lib/bigquery_migration/version.rb
159
+ homepage: https://github.com/sonots/bigquery_migration
160
+ licenses:
161
+ - MIT
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">"
175
+ - !ruby/object:Gem::Version
176
+ version: 1.3.1
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.5.1
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: Migrate BigQuery table schema
183
+ test_files: []