data_miner 1.3.4 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/data_miner/attribute.rb +9 -2
- data/lib/data_miner/tap.rb +29 -6
- data/lib/data_miner/version.rb +1 -1
- metadata +30 -29
data/lib/data_miner/attribute.rb
CHANGED
@@ -105,8 +105,15 @@ class DataMiner
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def do_convert(row, value)
|
108
|
-
|
109
|
-
|
108
|
+
unless wants_units?
|
109
|
+
raise ::RuntimeError, "[data_miner] If you use 'from_units', you need to set 'to_units' (#{inspect})"
|
110
|
+
end
|
111
|
+
final_from_units = (from_units || unit_from_source(row))
|
112
|
+
final_to_units = (to_units || unit_from_source(row))
|
113
|
+
if final_from_units.blank? or final_to_units.blank?
|
114
|
+
raise ::RuntimeError, "[data_miner] Missing units (from=#{final_from_units.inspect}, to=#{final_to_units.inspect}"
|
115
|
+
end
|
116
|
+
value.to_f.convert final_from_units, final_to_units
|
110
117
|
end
|
111
118
|
|
112
119
|
def do_sprintf(value)
|
data/lib/data_miner/tap.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'posix/spawn'
|
2
|
+
require 'uri'
|
2
3
|
class DataMiner
|
4
|
+
# Note that you probably shouldn't put taps into your Gemfile, because it depends on sequel and other gems that may not compile on Heroku (etc.)
|
5
|
+
#
|
6
|
+
# This class automatically detects if you have Bundler installed, and if so, executes the `taps` binary with a "clean" environment (i.e. one that will not pay attention to the fact that taps is not in your Gemfile)
|
3
7
|
class Tap
|
4
8
|
attr_reader :config
|
5
9
|
attr_reader :description
|
@@ -97,12 +101,21 @@ class DataMiner
|
|
97
101
|
}
|
98
102
|
end
|
99
103
|
|
100
|
-
|
104
|
+
# "user:pass"
|
105
|
+
# "user"
|
106
|
+
# nil
|
107
|
+
def userinfo
|
108
|
+
if username.present?
|
109
|
+
[username, password].select(&:present?).join(':')
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def db_url
|
101
114
|
case adapter
|
102
115
|
when 'sqlite'
|
103
|
-
database
|
116
|
+
"sqlite://#{database}"
|
104
117
|
else
|
105
|
-
|
118
|
+
::URI::Generic.new(adapter, userinfo, host, port, nil, "/#{database}", nil, nil, nil).to_s
|
106
119
|
end
|
107
120
|
end
|
108
121
|
|
@@ -110,15 +123,25 @@ class DataMiner
|
|
110
123
|
args = [
|
111
124
|
'taps',
|
112
125
|
'pull',
|
113
|
-
|
126
|
+
db_url,
|
114
127
|
source,
|
115
128
|
'--indexes-first',
|
116
129
|
'--tables',
|
117
130
|
source_table_name
|
118
131
|
]
|
119
|
-
child =
|
132
|
+
child = nil
|
133
|
+
|
134
|
+
# https://github.com/carlhuda/bundler/issues/1579
|
135
|
+
if defined?(::Bundler)
|
136
|
+
::Bundler.with_clean_env do
|
137
|
+
child = ::POSIX::Spawn::Child.new(*args)
|
138
|
+
end
|
139
|
+
else
|
140
|
+
child = ::POSIX::Spawn::Child.new(*args)
|
141
|
+
end
|
142
|
+
|
120
143
|
unless child.success?
|
121
|
-
raise %{[data_miner gem] Got "#{child.err}"
|
144
|
+
raise %{[data_miner gem] Got "#{child.err}" when tried "#{args.join(' ')}". You need to have the taps binary in your PATH. Putting it in your Gemfile, however, is not recommended.}
|
122
145
|
end
|
123
146
|
end
|
124
147
|
end
|
data/lib/data_miner/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_miner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2012-02-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: remote_table
|
18
|
-
requirement: &
|
18
|
+
requirement: &2164579240 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: 1.2.2
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *2164579240
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
|
-
requirement: &
|
29
|
+
requirement: &2164578480 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: 2.3.4
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *2164578480
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: activesupport
|
40
|
-
requirement: &
|
40
|
+
requirement: &2164577700 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: 2.3.4
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *2164577700
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: conversions
|
51
|
-
requirement: &
|
51
|
+
requirement: &2164577080 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: 1.4.4
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *2164577080
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: blockenspiel
|
62
|
-
requirement: &
|
62
|
+
requirement: &2164576420 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,10 +67,10 @@ dependencies:
|
|
67
67
|
version: 0.3.2
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *2164576420
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: errata
|
73
|
-
requirement: &
|
73
|
+
requirement: &2164575740 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - ! '>='
|
@@ -78,10 +78,10 @@ dependencies:
|
|
78
78
|
version: 1.0.1
|
79
79
|
type: :runtime
|
80
80
|
prerelease: false
|
81
|
-
version_requirements: *
|
81
|
+
version_requirements: *2164575740
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: posix-spawn
|
84
|
-
requirement: &
|
84
|
+
requirement: &2164575260 !ruby/object:Gem::Requirement
|
85
85
|
none: false
|
86
86
|
requirements:
|
87
87
|
- - ! '>='
|
@@ -89,10 +89,10 @@ dependencies:
|
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
|
-
version_requirements: *
|
92
|
+
version_requirements: *2164575260
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: mini_record-compat
|
95
|
-
requirement: &
|
95
|
+
requirement: &2164574580 !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
98
98
|
- - ! '>='
|
@@ -100,10 +100,10 @@ dependencies:
|
|
100
100
|
version: '0'
|
101
101
|
type: :development
|
102
102
|
prerelease: false
|
103
|
-
version_requirements: *
|
103
|
+
version_requirements: *2164574580
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: loose_tight_dictionary
|
106
|
-
requirement: &
|
106
|
+
requirement: &2164573940 !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
109
109
|
- - ! '>='
|
@@ -111,10 +111,10 @@ dependencies:
|
|
111
111
|
version: 0.0.5
|
112
112
|
type: :development
|
113
113
|
prerelease: false
|
114
|
-
version_requirements: *
|
114
|
+
version_requirements: *2164573940
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: test-unit
|
117
|
-
requirement: &
|
117
|
+
requirement: &2164573360 !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|
120
120
|
- - ! '>='
|
@@ -122,10 +122,10 @@ dependencies:
|
|
122
122
|
version: '0'
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
|
-
version_requirements: *
|
125
|
+
version_requirements: *2164573360
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: shoulda
|
128
|
-
requirement: &
|
128
|
+
requirement: &2164572800 !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
131
|
- - ! '>='
|
@@ -133,10 +133,10 @@ dependencies:
|
|
133
133
|
version: '0'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
|
-
version_requirements: *
|
136
|
+
version_requirements: *2164572800
|
137
137
|
- !ruby/object:Gem::Dependency
|
138
138
|
name: mysql
|
139
|
-
requirement: &
|
139
|
+
requirement: &2164572140 !ruby/object:Gem::Requirement
|
140
140
|
none: false
|
141
141
|
requirements:
|
142
142
|
- - ! '>='
|
@@ -144,10 +144,10 @@ dependencies:
|
|
144
144
|
version: '0'
|
145
145
|
type: :development
|
146
146
|
prerelease: false
|
147
|
-
version_requirements: *
|
147
|
+
version_requirements: *2164572140
|
148
148
|
- !ruby/object:Gem::Dependency
|
149
149
|
name: rake
|
150
|
-
requirement: &
|
150
|
+
requirement: &2164571480 !ruby/object:Gem::Requirement
|
151
151
|
none: false
|
152
152
|
requirements:
|
153
153
|
- - ! '>='
|
@@ -155,7 +155,7 @@ dependencies:
|
|
155
155
|
version: '0'
|
156
156
|
type: :development
|
157
157
|
prerelease: false
|
158
|
-
version_requirements: *
|
158
|
+
version_requirements: *2164571480
|
159
159
|
description: Mine remote data into your ActiveRecord models. You can also convert
|
160
160
|
units.
|
161
161
|
email:
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: '0'
|
214
214
|
requirements: []
|
215
215
|
rubyforge_project: data_miner
|
216
|
-
rubygems_version: 1.8.
|
216
|
+
rubygems_version: 1.8.15
|
217
217
|
signing_key:
|
218
218
|
specification_version: 3
|
219
219
|
summary: Mine remote data into your ActiveRecord models.
|
@@ -229,3 +229,4 @@ test_files:
|
|
229
229
|
- test/test_data_miner_process.rb
|
230
230
|
- test/test_old_syntax.rb
|
231
231
|
- test/test_tap.rb
|
232
|
+
has_rdoc:
|