td 0.10.74 → 0.10.75

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ == 2013-04-09 version 0.10.75
2
+
3
+ * Fix unparsed regexp pattern in Ruby 1.8
4
+ * Move gems directory into under vendor directory
5
+
6
+
1
7
  == 2013-03-29 version 0.10.74
2
8
 
3
9
  * Include zsh and bash completion
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/Rakefile CHANGED
@@ -33,11 +33,24 @@ def install_use_gems(target_dir)
33
33
  puts "** RVM surely breaks the package. Use rbenv instead."
34
34
  puts "**"
35
35
  end
36
+
37
+ require 'rubygems/gem_runner'
38
+
36
39
  # system(env, cmd) doesn't work with ruby 1.8
37
40
  ENV['GEM_HOME'] = target_dir
38
41
  ENV['GEM_PATH'] = ''
39
42
  USE_GEMS.each {|gem|
40
- system "gem install '#{gem}' --no-rdoc --no-ri" || (exit 1)
43
+ begin
44
+ Gem::GemRunner.new.run ["install", gem, "--no-rdoc", "--no-ri"]
45
+ rescue Gem::SystemExitException => e
46
+ unless e.exit_code.zero?
47
+ raise e
48
+ end
49
+ end
50
+ }
51
+ FileUtils.mv Dir.glob("#{target_dir}/gems/*"), target_dir
52
+ %W(bin cache doc gems specifications).each { |dir|
53
+ FileUtils.remove_dir("#{target_dir}/#{dir}", true)
41
54
  }
42
55
  end
43
56
 
data/dist/exe.rake CHANGED
@@ -15,7 +15,7 @@ task 'exe:build' => :build do
15
15
 
16
16
  # create ./td/
17
17
  mkchdir("td") do
18
- mkchdir('gems') do
18
+ mkchdir('vendor/gems') do
19
19
  install_use_gems(Dir.pwd)
20
20
  end
21
21
  install_resource 'exe/td', 'bin/td', 0755
data/dist/pkg.rake CHANGED
@@ -9,7 +9,7 @@ task 'pkg:build' => :build do
9
9
 
10
10
  # create ./bundle/td-client.pkg/Payload
11
11
  mkchdir('td-client.build') do
12
- mkchdir('gems') do
12
+ mkchdir('vendor/gems') do
13
13
  install_use_gems(Dir.pwd)
14
14
  end
15
15
  install_resource 'pkg/td', 'bin/td', 0755
@@ -16,7 +16,7 @@ require "pathname"
16
16
  here = File.dirname(Pathname.new(__FILE__).realpath)
17
17
 
18
18
  # add locally installed gems to libpath
19
- gem_dir = File.expand_path("../gems", here)
19
+ gem_dir = File.expand_path("../vendor/gems", here)
20
20
  Dir["#{gem_dir}/**/lib"].each do |libdir|
21
21
  $:.unshift libdir
22
22
  end
@@ -16,7 +16,7 @@ require "pathname"
16
16
  here = File.dirname(Pathname.new(__FILE__).realpath)
17
17
 
18
18
  # add locally installed gems to libpath
19
- gem_dir = File.expand_path("../gems", here)
19
+ gem_dir = File.expand_path("../vendor/gems", here)
20
20
  Dir["#{gem_dir}/**/lib"].each do |libdir|
21
21
  $:.unshift libdir
22
22
  end
@@ -126,13 +126,13 @@ module Command
126
126
 
127
127
  if wait && !job.finished?
128
128
  wait_job(job)
129
- if job.success? && job.type == :hive
129
+ if job.success? && [:hive, :pig].include?(job.type)
130
130
  puts "Result :"
131
131
  show_result(job, output, format, render_opts)
132
132
  end
133
133
 
134
134
  else
135
- if job.success? && job.type == :hive
135
+ if job.success? && [:hive, :pig].include?(job.type)
136
136
  puts "Result :"
137
137
  show_result(job, output, format, render_opts)
138
138
  end
@@ -16,6 +16,7 @@ module Command
16
16
  retry_limit = nil
17
17
  query = nil
18
18
  sampling_all = nil
19
+ type = nil
19
20
 
20
21
  op.on('-g', '--org ORGANIZATION', "issue the query under this organization") {|s|
21
22
  org = s
@@ -59,6 +60,9 @@ module Command
59
60
  op.on('-q', '--query PATH', 'use file instead of inline query') {|s|
60
61
  query = File.open(s) { |f| f.read.strip }
61
62
  }
63
+ op.on('-t', '--type TYPE', 'set query type (hive or pig)') {|s|
64
+ type = s.to_sym
65
+ }
62
66
  op.on('--sampling DENOMINATOR', 'enable random sampling to reduce records 1/DENOMINATOR', Integer) {|i|
63
67
  sampling_all = i
64
68
  }
@@ -94,6 +98,7 @@ module Command
94
98
  opts = {}
95
99
  opts['organization'] = org if org
96
100
  opts['sampling_all'] = sampling_all if sampling_all
101
+ opts['type'] = type if type
97
102
  job = client.query(db_name, sql, result_url, priority, retry_limit, opts)
98
103
 
99
104
  $stderr.puts "Job #{job.job_id} is queued."
@@ -1,3 +1,4 @@
1
+ require 'td/helpers'
1
2
 
2
3
  module TreasureData
3
4
  module Command
@@ -114,8 +115,8 @@ module Command
114
115
  "#{f.name}:#{f.type}"
115
116
  }.join(', ')
116
117
  rows << {
117
- :Database => db.name, :Table => table.name, :Type => table.type.to_s, :Count => table.count.to_s.gsub(/(?<=\d)(?=(?:\d{3})+(?!\d))/, ','),
118
- :Size => show_size_in_bytes ? table.estimated_storage_size.to_s.gsub(/(?<=\d)(?=(?:\d{3})+(?!\d))/, ',') : table.estimated_storage_size_string,
118
+ :Database => db.name, :Table => table.name, :Type => table.type.to_s, :Count => TreasureData::Helpers.format_with_delimiter(table.count),
119
+ :Size => show_size_in_bytes ? TreasureData::Helpers.format_with_delimiter(table.estimated_storage_size) : table.estimated_storage_size_string,
119
120
  'Last import' => table.last_import ? table.last_import.localtime : nil,
120
121
  :Schema => pschema
121
122
  }
data/lib/td/helpers.rb CHANGED
@@ -2,6 +2,15 @@ module TreasureData
2
2
  module Helpers
3
3
  module_function
4
4
 
5
+ def format_with_delimiter(number, delimiter = ',')
6
+ num = number.to_s
7
+ if formatted = num.gsub!(/(\d)(?=(?:\d{3})+(?!\d))/, "\\1#{delimiter}")
8
+ formatted
9
+ else
10
+ num
11
+ end
12
+ end
13
+
5
14
  def on_windows?
6
15
  RUBY_PLATFORM =~ /mswin32|mingw32/
7
16
  end
data/lib/td/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.10.74'
3
+ VERSION = '0.10.75'
4
4
 
5
5
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'td/helpers'
3
+
4
+ module TreasureData
5
+ describe 'format_with_delimiter' do
6
+ it "delimits the number with ',' by default" do
7
+ expect(Helpers.format_with_delimiter(0)).to eq("0")
8
+ expect(Helpers.format_with_delimiter(10)).to eq("10")
9
+ expect(Helpers.format_with_delimiter(100)).to eq("100")
10
+ expect(Helpers.format_with_delimiter(1000)).to eq("1,000")
11
+ expect(Helpers.format_with_delimiter(10000)).to eq("10,000")
12
+ expect(Helpers.format_with_delimiter(100000)).to eq("100,000")
13
+ expect(Helpers.format_with_delimiter(1000000)).to eq("1,000,000")
14
+ end
15
+ end
16
+ end
data/td.gemspec CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |gem|
23
23
  gem.add_dependency "td-client", "~> 0.8.46"
24
24
  gem.add_dependency "td-logger", "~> 0.3.16"
25
25
  gem.add_development_dependency "rake", "~> 0.9"
26
- gem.add_development_dependency "rspec", "~> 2.10.0"
26
+ gem.add_development_dependency "rspec", "~> 2.11.0"
27
27
  gem.add_development_dependency "simplecov", "~> 0.5.4"
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.74
4
+ version: 0.10.75
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-28 00:00:00.000000000 Z
12
+ date: 2013-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 2.10.0
133
+ version: 2.11.0
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 2.10.0
141
+ version: 2.11.0
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: simplecov
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -226,6 +226,7 @@ files:
226
226
  - spec/file_reader/shared_context.rb
227
227
  - spec/file_reader_spec.rb
228
228
  - spec/spec_helper.rb
229
+ - spec/td/helpers_spec.rb
229
230
  - spec/td/version_spec.rb
230
231
  - td.gemspec
231
232
  homepage: http://treasure-data.com/
@@ -242,7 +243,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
242
243
  version: '0'
243
244
  segments:
244
245
  - 0
245
- hash: 1161270452810499022
246
+ hash: 1038070565617120851
246
247
  required_rubygems_version: !ruby/object:Gem::Requirement
247
248
  none: false
248
249
  requirements:
@@ -251,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
252
  version: '0'
252
253
  segments:
253
254
  - 0
254
- hash: 1161270452810499022
255
+ hash: 1038070565617120851
255
256
  requirements: []
256
257
  rubyforge_project:
257
258
  rubygems_version: 1.8.23
@@ -266,4 +267,5 @@ test_files:
266
267
  - spec/file_reader/shared_context.rb
267
268
  - spec/file_reader_spec.rb
268
269
  - spec/spec_helper.rb
270
+ - spec/td/helpers_spec.rb
269
271
  - spec/td/version_spec.rb