sniff 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,6 @@
1
1
  require 'data_miner'
2
+ require 'create_table'
3
+ require 'logger'
2
4
 
3
5
  module Sniff
4
6
  extend self
@@ -1,6 +1,4 @@
1
1
  require 'active_support'
2
- require 'fileutils'
3
- require 'logger'
4
2
  require 'sqlite3'
5
3
 
6
4
  module Sniff
@@ -12,7 +10,7 @@ module Sniff
12
10
  # options:
13
11
  # * :earth is the list of domains Earth.init should load (default: none)
14
12
  # * :load_data determines whether fixture data is loaded (default: true)
15
- # * :fixtures_path is the path to your gem's fixtures (default: local_root/lib/db/fixtures)
13
+ # * :fixtures_path is the path to your gem's fixtures (default: local_root/features/support/db/fixtures)
16
14
  def init(local_root, options = {})
17
15
  db_init options
18
16
  earth_init(options[:earth])
@@ -55,12 +53,12 @@ module Sniff
55
53
  end
56
54
  end
57
55
 
58
- attr_accessor :root, :lib_path, :fixtures_path,
56
+ attr_accessor :root, :test_support_path, :fixtures_path,
59
57
  :load_data, :fixtures, :logger
60
58
 
61
59
  def initialize(root, options)
62
60
  self.root = root
63
- self.lib_path = File.join(root, 'lib', 'test_support')
61
+ self.test_support_path = File.join(root, 'features', 'support')
64
62
  self.load_data = options[:load_data]
65
63
  self.fixtures_path = options[:fixtures_path]
66
64
  self.logger = Sniff.logger
@@ -76,7 +74,7 @@ module Sniff
76
74
  end
77
75
 
78
76
  def fixtures_path
79
- @fixtures_path ||= File.join(lib_path, 'db', 'fixtures')
77
+ @fixtures_path ||= File.join(test_support_path, 'db', 'fixtures')
80
78
  end
81
79
 
82
80
  def fixtures
@@ -91,16 +89,17 @@ module Sniff
91
89
 
92
90
  def emitter_class
93
91
  return @emitter_class unless @emitter_class.nil?
94
- record_class_file = Dir.glob(File.join(root, 'lib', 'test_support', '*_record.rb')).first
95
- if record_class_file
96
- record_class = File.read(record_class_file)
92
+ record_class_path = Dir.glob(File.join(test_support_path, '*_record.rb')).first
93
+ if record_class_path
94
+ require record_class_path
95
+ record_class = File.read(record_class_path)
97
96
  klass = record_class.scan(/class ([^\s]*Record)/).flatten.first
98
97
  @emitter_class = klass.constantize
99
98
  end
100
99
  end
101
100
 
102
101
  def create_emitter_table
103
- emitter_class.execute_schema if emitter_class
102
+ emitter_class.create_table! if emitter_class
104
103
  end
105
104
 
106
105
  def read_fixtures
@@ -114,15 +113,15 @@ module Sniff
114
113
 
115
114
  def populate_fixtures
116
115
  Encoding.default_external = 'UTF-8' if Object.const_defined?('Encoding')
117
- Earth.resource_names.each do |klass|
118
- klass = klass.pluralize unless Object.const_defined?(klass)
119
- if Object.const_defined?(klass) and klass.constantize.table_exists?
120
- object = klass.constantize
121
- table_name = object.table_name
116
+ Earth.resources.each do |resource|
117
+ next unless Object.const_defined?(resource)
118
+ resource_model = resource.constantize
119
+ if resource_model.table_exists?
120
+ table_name = resource_model.table_name
122
121
  fixture_file = File.join(fixtures_path, table_name + '.csv')
123
122
  if File.exist? fixture_file
124
123
  log "Loading fixture #{fixture_file}"
125
- Fixtures.create_fixtures(fixtures_path, table_name, klass => table_name)
124
+ Fixtures.create_fixtures(fixtures_path, table_name, resource => table_name)
126
125
  end
127
126
  end
128
127
  end
@@ -54,18 +54,42 @@ module Sniff
54
54
  desc 'Set up and build rocco docs'
55
55
  task :docs_init => :rocco
56
56
 
57
+ task :google_analyzed_rocco => :rocco do
58
+ source = File.read "docs/lib/#{gemname}/carbon_model.html"
59
+ unless source =~ /_gaq/
60
+ source.sub! '</head>', <<-HTML
61
+ <script type="text/javascript">
62
+ var _gaq = _gaq || [];
63
+ _gaq.push(['_setAccount', 'UA-1667526-20']);
64
+ _gaq.push(['_trackPageview']);
65
+
66
+ (function() {
67
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
68
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
69
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
70
+ })();
71
+ </script>
72
+ </head>
73
+ HTML
74
+ File.open "docs/lib/#{gemname}/carbon_model.html", 'w' do |f|
75
+ f.puts source
76
+ end
77
+ end
78
+ end
79
+
57
80
  desc 'Rebuild rocco docs'
58
- task :docs => ['pages:sync', :rocco]
81
+ task :docs => ['pages:sync', :google_analyzed_rocco]
59
82
  directory 'docs/'
60
83
 
61
- desc 'Update gh-pages branch'
84
+ desc 'Update rocco docs on gh-pages branch'
62
85
  task :pages => :docs do
63
86
  rev = `git rev-parse --short HEAD`.strip
64
87
  sh "mv docs/lib/#{gemname}/carbon_model.html docs/carbon_model.html"
65
88
  git 'add *.html', 'docs'
66
- git "commit -m 'rebuild pages from #{rev}'", 'docs' do |ok,res|
89
+ puts "Commiting with message 'Rebuild pages from #{rev}'"
90
+ git "commit -m 'Rebuild pages from #{rev}'", 'docs' do |ok,res|
67
91
  if ok
68
- verbose { puts "gh-pages updated" }
92
+ puts "Pushing to HEAD"
69
93
  git 'push -q o HEAD:gh-pages', 'docs' unless ENV['NO_PUSH']
70
94
  end
71
95
  end
@@ -1,3 +1,3 @@
1
1
  module Sniff
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
@@ -55,7 +55,7 @@ When /^the "(.*)" committee is calculated$/ do |committee_name|
55
55
  # if @report.nil?
56
56
  # raise "The committee #{@committee.name} did not come to a conclusion. Characteristics: #{@characteristics.inspect}"
57
57
  # else
58
- @characteristics[committee_name.to_sym] = @report.andand.conclusion
58
+ @characteristics[committee_name.to_sym] = @report.try(:conclusion)
59
59
  # end
60
60
  end
61
61
 
@@ -85,16 +85,16 @@ Then /^the conclusion should not comply with standards? "(.*)"$/ do |standard_li
85
85
  end
86
86
 
87
87
  Then /^the conclusion of the committee should be "(.*)"$/ do |conclusion|
88
- compare_values(@report.andand.conclusion, conclusion)
88
+ compare_values(@report.try(:conclusion), conclusion)
89
89
  end
90
90
 
91
91
  Then /^the conclusion of the committee should be timeframe "(.*)"$/ do |conclusion|
92
92
  timeframe = Timeframe.interval(conclusion)
93
- compare_values(@report.andand.conclusion, timeframe)
93
+ compare_values(@report.try(:conclusion), timeframe)
94
94
  end
95
95
 
96
96
  Then /^the conclusion of the committee should be nil$/ do
97
- compare_values(@report.andand.conclusion, nil)
97
+ compare_values(@report.try(:conclusion), nil)
98
98
  end
99
99
 
100
100
  Then /^the conclusion of the committee should include a key of "(.*)" and value "(.*)"$/ do |key, value|
@@ -2,13 +2,9 @@ module BrighterPlanet
2
2
  module Dirigible
3
3
  module Data
4
4
  def self.included(base)
5
- base.data_miner do
6
- schema do
7
- float 'fuel_efficiency'
8
- float 'annual_distance_estimate'
9
- end
10
-
11
- process :run_data_miner_on_belongs_to_associations
5
+ base.create_table do
6
+ float 'fuel_efficiency'
7
+ float 'annual_distance_estimate'
12
8
  end
13
9
  end
14
10
  end
@@ -1,7 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'fileutils'
3
- require 'data_miner'
4
- require 'logger'
5
2
 
6
3
  describe Sniff::Database do
7
4
  describe '#connect' do
@@ -10,18 +7,18 @@ describe Sniff::Database do
10
7
  before :all do
11
8
  $:.unshift File.join(dirigible_path, 'lib')
12
9
  require File.join('dirigible')
13
- DataMiner.logger = Logger.new nil
10
+ DataMiner.logger = Logger.new $stdout
14
11
  end
15
12
 
16
13
  it 'should load the air domain' do
17
14
  Sniff.init(dirigible_path, :earth => :air, :apply_schemas => true)
18
15
  Airport.count.should == 0 # we don't have fixtures for this here
19
- ZipCode.count.should > 0
20
- expect { AutomobileFuelType }.should raise_error
16
+ expect { ZipCode.count }.should raise_error
17
+ expect { AutomobileFuelType.count }.should raise_error
21
18
  end
22
19
  it 'should load data for all domains' do
23
20
  Sniff.init(dirigible_path, :earth => :all, :apply_schemas => true)
24
- PetroleumAdministrationForDefenseDistrict.all.count.should == 7
21
+ PetroleumAdministrationForDefenseDistrict.count.should == 7
25
22
  ZipCode.count.should > 0
26
23
  end
27
24
  it 'should load a schema for the emitter record' do
metadata CHANGED
@@ -1,191 +1,200 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sniff
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.2
4
5
  prerelease:
5
- version: 0.8.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Derek Kastner
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-02 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-06-13 00:00:00.000000000 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2155180580 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 3.0.0
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
24
23
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: aaronh-chronic
28
24
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2155180580
26
+ - !ruby/object:Gem::Dependency
27
+ name: aaronh-chronic
28
+ requirement: &2155180060 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ~>
33
- - !ruby/object:Gem::Version
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
34
33
  version: 0.3.9
35
34
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: bueller
39
35
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2155180060
37
+ - !ruby/object:Gem::Dependency
38
+ name: bueller
39
+ requirement: &2155179540 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
45
44
  version: 0.0.5
46
45
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: cucumber
50
46
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2155179540
48
+ - !ruby/object:Gem::Dependency
49
+ name: create_table
50
+ requirement: &2155179080 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
57
56
  type: :runtime
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: earth
61
57
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *2155179080
59
+ - !ruby/object:Gem::Dependency
60
+ name: cucumber
61
+ requirement: &2155178440 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :runtime
68
+ prerelease: false
69
+ version_requirements: *2155178440
70
+ - !ruby/object:Gem::Dependency
71
+ name: earth
72
+ requirement: &2155177840 !ruby/object:Gem::Requirement
63
73
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
67
77
  version: 0.4.5
68
78
  type: :runtime
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: rake
72
79
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
80
+ version_requirements: *2155177840
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: &2155177220 !ruby/object:Gem::Requirement
74
84
  none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
78
88
  version: 0.9.0
79
89
  type: :runtime
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: rcov
83
90
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
91
+ version_requirements: *2155177220
92
+ - !ruby/object:Gem::Dependency
93
+ name: rcov
94
+ requirement: &2155176820 !ruby/object:Gem::Requirement
85
95
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
90
100
  type: :runtime
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: rdoc
94
101
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
102
+ version_requirements: *2155176820
103
+ - !ruby/object:Gem::Dependency
104
+ name: rdoc
105
+ requirement: &2155176300 !ruby/object:Gem::Requirement
96
106
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "0"
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
101
111
  type: :runtime
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
104
- name: dkastner-rocco
105
112
  prerelease: false
106
- requirement: &id009 !ruby/object:Gem::Requirement
113
+ version_requirements: *2155176300
114
+ - !ruby/object:Gem::Dependency
115
+ name: dkastner-rocco
116
+ requirement: &2155175420 !ruby/object:Gem::Requirement
107
117
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: "0"
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
112
122
  type: :runtime
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
115
- name: rspec
116
123
  prerelease: false
117
- requirement: &id010 !ruby/object:Gem::Requirement
124
+ version_requirements: *2155175420
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: &2155174780 !ruby/object:Gem::Requirement
118
128
  none: false
119
- requirements:
129
+ requirements:
120
130
  - - ~>
121
- - !ruby/object:Gem::Version
122
- version: "2"
131
+ - !ruby/object:Gem::Version
132
+ version: '2'
123
133
  type: :runtime
124
- version_requirements: *id010
125
- - !ruby/object:Gem::Dependency
126
- name: sqlite3-ruby
127
134
  prerelease: false
128
- requirement: &id011 !ruby/object:Gem::Requirement
135
+ version_requirements: *2155174780
136
+ - !ruby/object:Gem::Dependency
137
+ name: sqlite3-ruby
138
+ requirement: &2155174140 !ruby/object:Gem::Requirement
129
139
  none: false
130
- requirements:
131
- - - ~>
132
- - !ruby/object:Gem::Version
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
133
143
  version: 1.3.0
134
144
  type: :runtime
135
- version_requirements: *id011
136
- - !ruby/object:Gem::Dependency
137
- name: timecop
138
145
  prerelease: false
139
- requirement: &id012 !ruby/object:Gem::Requirement
146
+ version_requirements: *2155174140
147
+ - !ruby/object:Gem::Dependency
148
+ name: timecop
149
+ requirement: &2155173660 !ruby/object:Gem::Requirement
140
150
  none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: "0"
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
145
155
  type: :runtime
146
- version_requirements: *id012
147
- - !ruby/object:Gem::Dependency
148
- name: timeframe
149
156
  prerelease: false
150
- requirement: &id013 !ruby/object:Gem::Requirement
157
+ version_requirements: *2155173660
158
+ - !ruby/object:Gem::Dependency
159
+ name: timeframe
160
+ requirement: &2155172900 !ruby/object:Gem::Requirement
151
161
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
155
165
  version: 0.0.8
156
166
  type: :runtime
157
- version_requirements: *id013
158
- - !ruby/object:Gem::Dependency
159
- name: sandbox
160
167
  prerelease: false
161
- requirement: &id014 !ruby/object:Gem::Requirement
168
+ version_requirements: *2155172900
169
+ - !ruby/object:Gem::Dependency
170
+ name: sandbox
171
+ requirement: &2155172460 !ruby/object:Gem::Requirement
162
172
  none: false
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: "0"
173
+ requirements:
174
+ - - ! '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
167
177
  type: :development
168
- version_requirements: *id014
169
- - !ruby/object:Gem::Dependency
170
- name: emitter
171
178
  prerelease: false
172
- requirement: &id015 !ruby/object:Gem::Requirement
179
+ version_requirements: *2155172460
180
+ - !ruby/object:Gem::Dependency
181
+ name: emitter
182
+ requirement: &2155171900 !ruby/object:Gem::Requirement
173
183
  none: false
174
- requirements:
175
- - - ">="
176
- - !ruby/object:Gem::Version
184
+ requirements:
185
+ - - ! '>='
186
+ - !ruby/object:Gem::Version
177
187
  version: 0.5.0
178
188
  type: :development
179
- version_requirements: *id015
189
+ prerelease: false
190
+ version_requirements: *2155171900
180
191
  description: Provides development and test environment for emitter gems
181
192
  email: derek.kastner@brighterplanet.com
182
193
  executables: []
183
-
184
194
  extensions: []
185
-
186
- extra_rdoc_files:
195
+ extra_rdoc_files:
187
196
  - README.markdown
188
- files:
197
+ files:
189
198
  - lib/sniff/database.rb
190
199
  - lib/sniff/emitter.rb
191
200
  - lib/sniff/rake_tasks.rb
@@ -229,34 +238,36 @@ files:
229
238
  - spec/lib/sniff/rake_tasks_spec.rb
230
239
  - spec/lib/test_support/cucumber/support/values_spec.rb
231
240
  - spec/spec_helper.rb
241
+ has_rdoc: true
232
242
  homepage: https://github.com/brighterplanet/sniff
233
243
  licenses: []
234
-
235
244
  post_install_message:
236
- rdoc_options:
245
+ rdoc_options:
237
246
  - --charset=UTF-8
238
- require_paths:
247
+ require_paths:
239
248
  - lib
240
- required_ruby_version: !ruby/object:Gem::Requirement
249
+ required_ruby_version: !ruby/object:Gem::Requirement
241
250
  none: false
242
- requirements:
243
- - - ">="
244
- - !ruby/object:Gem::Version
245
- version: "0"
246
- required_rubygems_version: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - ! '>='
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ segments:
256
+ - 0
257
+ hash: 3830723489194360646
258
+ required_rubygems_version: !ruby/object:Gem::Requirement
247
259
  none: false
248
- requirements:
249
- - - ">="
250
- - !ruby/object:Gem::Version
251
- version: "0"
260
+ requirements:
261
+ - - ! '>='
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
252
264
  requirements: []
253
-
254
265
  rubyforge_project:
255
- rubygems_version: 1.8.3
266
+ rubygems_version: 1.6.2
256
267
  signing_key:
257
268
  specification_version: 3
258
269
  summary: Test support for Brighter Planet carbon gems
259
- test_files:
270
+ test_files:
260
271
  - spec/db/emitter_data.sqlite3
261
272
  - spec/db/schema_output
262
273
  - spec/fixtures/dirigible/lib/dirigible/carbon_model.rb