to-arff 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +25 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/README.md +16 -11
- data/Rakefile +3 -3
- data/bin/console +4 -4
- data/lib/to-arff/sqlitedb.rb +59 -56
- data/lib/to-arff/version.rb +1 -1
- data/to-arff.gemspec +12 -13
- metadata +7 -21
- data/Guardfile +0 -70
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2807e6f50d44f2e2400cd22a5132a6c3bf95c4db
|
|
4
|
+
data.tar.gz: '08daa8eaa3b12dd7f7fe29e51521ee3b6ff94a04'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b83a006c201a16cba035212e055ff544815ef36c33151f6fd4d77c398cf4cf29f0e17efa4a732a6aa1066b973228fb6772bb4e12ad2f0cf662c7d25e17999ab
|
|
7
|
+
data.tar.gz: fca7298c1c756154f5f8d6f2d7470a1e3a40adc2734a63c858b96c2bf7ec472f35bd7b14027d71528eaa81d942fd62fa0f709bac4866d1c2ebd1ef242f35821b
|
data/.codeclimate.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
engines:
|
|
3
|
+
duplication:
|
|
4
|
+
enabled: true
|
|
5
|
+
config:
|
|
6
|
+
languages:
|
|
7
|
+
- ruby
|
|
8
|
+
- javascript
|
|
9
|
+
- python
|
|
10
|
+
- php
|
|
11
|
+
fixme:
|
|
12
|
+
enabled: true
|
|
13
|
+
rubocop:
|
|
14
|
+
enabled: true
|
|
15
|
+
ratings:
|
|
16
|
+
paths:
|
|
17
|
+
- "**.inc"
|
|
18
|
+
- "**.js"
|
|
19
|
+
- "**.jsx"
|
|
20
|
+
- "**.module"
|
|
21
|
+
- "**.php"
|
|
22
|
+
- "**.py"
|
|
23
|
+
- "**.rb"
|
|
24
|
+
exclude_paths:
|
|
25
|
+
- spec/
|
data/.coveralls.yml
CHANGED
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -3,4 +3,7 @@ source 'https://rubygems.org'
|
|
|
3
3
|
# Specify your gem's dependencies in to-arff.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
+
gem 'rspec', '~> 3.0', :require => false, :group => :test
|
|
6
7
|
gem 'coveralls', require: false
|
|
8
|
+
gem 'rubocop', '~> 0.42.0', require: false
|
|
9
|
+
gem 'simplecov', :require => false, :group => :test
|
data/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
# ToARFF
|
|
2
|
+
[](https://travis-ci.org/dhrubomoy/to-arff)
|
|
3
|
+
[](https://coveralls.io/github/dhrubomoy/to-arff)
|
|
4
|
+
[](https://badge.fury.io/rb/to-arff)
|
|
5
|
+
[](https://gemnasium.com/github.com/dhrubomoy/to-arff)
|
|
6
|
+
[](https://codeclimate.com/github/dhrubomoy/to-arff)
|
|
2
7
|
##Table of Content
|
|
3
8
|
- [About](#about)
|
|
4
9
|
- [What is an ARFF File](#what-is-an-arff-file)
|
|
@@ -50,14 +55,14 @@ sample = ToARFF::SQLiteDB.new "/path/to/sample_sqlite.db"
|
|
|
50
55
|
# "column22"=>"DATE \"yyyy-MM-dd HH:mm:ss\""
|
|
51
56
|
# }
|
|
52
57
|
sample_column_types_param = { "employees" => {"EmployeeId"=>"NUMERIC",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
"LastName"=>"STRING",
|
|
59
|
+
"City"=>"STRING",
|
|
60
|
+
"HireDate"=>"DATE \"yyyy-MM-dd HH:mm:ss\""
|
|
61
|
+
},
|
|
62
|
+
"albums" => { "Albumid"=>"NUMERIC",
|
|
63
|
+
"Title"=>"STRING"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
61
66
|
puts sample.convert column_types: sample_column_types_param
|
|
62
67
|
```
|
|
63
68
|
We will get something similar to following:
|
|
@@ -91,9 +96,9 @@ We will get something similar to following:
|
|
|
91
96
|
```ruby
|
|
92
97
|
require 'to-arff'
|
|
93
98
|
sample = ToARFF::SQLiteDB.new "/path/to/sample_sqlite.db"
|
|
94
|
-
sample_columns =
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
sample_columns = { "albums" => ["AlbumId", "Title", "ArtistId"],
|
|
100
|
+
"employees" => ["EmployeeId", "LastName", "FirstName", "Title"]
|
|
101
|
+
}
|
|
97
102
|
puts sample.convert columns: sample_columns
|
|
98
103
|
```
|
|
99
104
|
We will get something similar:
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'to-arff'
|
|
5
5
|
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
|
8
8
|
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require
|
|
10
|
+
# require 'pry'
|
|
11
11
|
# Pry.start
|
|
12
12
|
|
|
13
|
-
require
|
|
13
|
+
require 'irb'
|
|
14
14
|
IRB.start
|
data/lib/to-arff/sqlitedb.rb
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'to-arff/version'
|
|
2
2
|
require 'sqlite3'
|
|
3
3
|
|
|
4
4
|
module ToARFF
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ATTRIBUTE_TYPE_NUMERIC = 'NUMERIC'
|
|
11
|
-
ATTRIBUTE_TYPE_STRING = 'STRING'
|
|
12
|
-
|
|
5
|
+
RELATION_MARKER = '@RELATION'.freeze
|
|
6
|
+
ATTRIBUTE_MARKER = '@ATTRIBUTE'.freeze
|
|
7
|
+
DATA_MARKER = '@DATA'.freeze
|
|
8
|
+
ATTRIBUTE_TYPE_NUMERIC = 'NUMERIC'.freeze
|
|
9
|
+
ATTRIBUTE_TYPE_STRING = 'STRING'.freeze
|
|
13
10
|
|
|
14
11
|
class SQLiteDB
|
|
15
|
-
|
|
16
12
|
attr_accessor :db_file_path, :db, :tables, :columns, :column_type
|
|
17
13
|
|
|
18
14
|
def initialize(path)
|
|
19
15
|
@db_file_path = path
|
|
20
|
-
@tables =
|
|
21
|
-
@columns =
|
|
22
|
-
@column_type =
|
|
16
|
+
@tables = []
|
|
17
|
+
@columns = {}
|
|
18
|
+
@column_type = {}
|
|
23
19
|
process_db_file
|
|
24
20
|
set_all_tables
|
|
25
21
|
set_all_columns
|
|
@@ -28,11 +24,7 @@ module ToARFF
|
|
|
28
24
|
def process_db_file
|
|
29
25
|
if @db_file_path != ''
|
|
30
26
|
if File.exist? "#{@db_file_path}"
|
|
31
|
-
|
|
32
|
-
@db = SQLite3::Database.open "#{@db_file_path}"
|
|
33
|
-
rescue SQLite3::Exception => e
|
|
34
|
-
puts "#{e}"
|
|
35
|
-
end
|
|
27
|
+
@db = SQLite3::Database.open "#{@db_file_path}"
|
|
36
28
|
else
|
|
37
29
|
raise "#{@db_file_path} doesn't exist. Enter a valid file path."
|
|
38
30
|
end
|
|
@@ -43,28 +35,20 @@ module ToARFF
|
|
|
43
35
|
|
|
44
36
|
# Get all the tables' name and store them in an array (@tables).
|
|
45
37
|
def set_all_tables
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@tables.push(elem.first)
|
|
50
|
-
end
|
|
51
|
-
rescue SQLite3::Exception => e
|
|
52
|
-
puts "#{e}"
|
|
38
|
+
tables_arr = @db.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
|
39
|
+
tables_arr.each do |elem|
|
|
40
|
+
@tables.push(elem.first)
|
|
53
41
|
end
|
|
54
42
|
end
|
|
55
43
|
|
|
56
44
|
# Get all colums for a given table.
|
|
57
45
|
def get_columns(table_name)
|
|
58
|
-
columns_arr =
|
|
59
|
-
begin
|
|
46
|
+
columns_arr = []
|
|
60
47
|
pst = @db.prepare "SELECT * FROM #{table_name} LIMIT 6"
|
|
61
48
|
pst.columns.each do |c|
|
|
62
49
|
columns_arr.push(c)
|
|
63
50
|
end
|
|
64
51
|
columns_arr
|
|
65
|
-
rescue SQLite3::Exception => e
|
|
66
|
-
puts e
|
|
67
|
-
end
|
|
68
52
|
end
|
|
69
53
|
|
|
70
54
|
def set_all_columns
|
|
@@ -75,14 +59,10 @@ module ToARFF
|
|
|
75
59
|
|
|
76
60
|
# If the column type is nominal return true.
|
|
77
61
|
def is_numeric(table_name, column_name)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return false
|
|
83
|
-
end
|
|
84
|
-
rescue SQLite3::Exception => e
|
|
85
|
-
puts e
|
|
62
|
+
if @db.execute("SELECT #{column_name} from #{table_name} LIMIT 1").first.first.is_a? Numeric
|
|
63
|
+
return true
|
|
64
|
+
else
|
|
65
|
+
return false
|
|
86
66
|
end
|
|
87
67
|
end
|
|
88
68
|
|
|
@@ -91,8 +71,12 @@ module ToARFF
|
|
|
91
71
|
convert_table_with_columns(table_name, get_columns(table_name))
|
|
92
72
|
end
|
|
93
73
|
|
|
94
|
-
def
|
|
95
|
-
|
|
74
|
+
def write_relation(table_name)
|
|
75
|
+
"#{RELATION_MARKER} #{table_name}\n\n"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def write_attributes(table_name, columns, column_types)
|
|
79
|
+
rel = ""
|
|
96
80
|
if column_types.nil?
|
|
97
81
|
columns.each do |col|
|
|
98
82
|
if is_numeric(table_name, col)
|
|
@@ -106,6 +90,11 @@ module ToARFF
|
|
|
106
90
|
rel << "#{ATTRIBUTE_MARKER} #{col} #{column_types[table_name][col]}\n"
|
|
107
91
|
end
|
|
108
92
|
end
|
|
93
|
+
rel
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def write_data(table_name, columns)
|
|
97
|
+
rel = ""
|
|
109
98
|
columns_str = ""
|
|
110
99
|
columns.each do |col|
|
|
111
100
|
columns_str += col + ", "
|
|
@@ -129,6 +118,13 @@ module ToARFF
|
|
|
129
118
|
rel
|
|
130
119
|
end
|
|
131
120
|
|
|
121
|
+
def convert_table_with_columns(table_name, columns, column_types=nil)
|
|
122
|
+
rel = write_relation(table_name)
|
|
123
|
+
rel << write_attributes(table_name, columns, column_types)
|
|
124
|
+
rel << write_data(table_name, columns)
|
|
125
|
+
rel
|
|
126
|
+
end
|
|
127
|
+
|
|
132
128
|
def convert_from_columns_hash(cols_hash)
|
|
133
129
|
rel = ""
|
|
134
130
|
cols_hash.keys.each do |table|
|
|
@@ -175,6 +171,26 @@ module ToARFF
|
|
|
175
171
|
downcased_array
|
|
176
172
|
end
|
|
177
173
|
|
|
174
|
+
def valid_option_given(options)
|
|
175
|
+
return options.keys.first.to_s != "tables" && options.keys.first.to_s != "columns" && options.keys.first.to_s != "column_types"
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# If valid option was provided in convert method
|
|
179
|
+
def deal_with_valid_option(temp_tables, temp_columns, temp_column_types, res)
|
|
180
|
+
if !temp_tables.empty?
|
|
181
|
+
check_given_tables_validity(temp_tables)
|
|
182
|
+
temp_tables.each do |t|
|
|
183
|
+
res << convert_table(t)
|
|
184
|
+
end
|
|
185
|
+
elsif !temp_columns.keys.empty?
|
|
186
|
+
check_given_columns_validity(temp_columns)
|
|
187
|
+
res << convert_from_columns_hash(temp_columns)
|
|
188
|
+
elsif !temp_column_types.empty?
|
|
189
|
+
check_given_columns_validity(temp_column_types)
|
|
190
|
+
res << convert_from_column_types_hash(temp_column_types)
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
178
194
|
def convert(options={})
|
|
179
195
|
temp_tables = options.fetch(:tables, Array.new)
|
|
180
196
|
temp_columns = options.fetch(:columns, Hash.new)
|
|
@@ -186,23 +202,10 @@ module ToARFF
|
|
|
186
202
|
res << convert_table(t)
|
|
187
203
|
end
|
|
188
204
|
elsif param_count == 1
|
|
189
|
-
if options
|
|
190
|
-
raise ArgumentError.new("Wrong parameter name \":#{options.keys.first
|
|
205
|
+
if valid_option_given(options)
|
|
206
|
+
raise ArgumentError.new("Wrong parameter name \":#{options.keys.first}\"")
|
|
191
207
|
else
|
|
192
|
-
|
|
193
|
-
check_given_tables_validity(temp_tables)
|
|
194
|
-
temp_tables.each do |t|
|
|
195
|
-
res << convert_table(t)
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
if !temp_columns.keys.empty?
|
|
199
|
-
check_given_columns_validity(temp_columns)
|
|
200
|
-
res << convert_from_columns_hash(temp_columns)
|
|
201
|
-
end
|
|
202
|
-
if !temp_column_types.empty?
|
|
203
|
-
check_given_columns_validity(temp_column_types)
|
|
204
|
-
res << convert_from_column_types_hash(temp_column_types)
|
|
205
|
-
end
|
|
208
|
+
deal_with_valid_option(temp_tables, temp_columns, temp_column_types, res)
|
|
206
209
|
end
|
|
207
210
|
elsif param_count > 1
|
|
208
211
|
raise ArgumentError.new("You can specify only one out of the three parameters: table, columns, column_types.")
|
data/lib/to-arff/version.rb
CHANGED
data/to-arff.gemspec
CHANGED
|
@@ -5,23 +5,22 @@ require 'to-arff/version'
|
|
|
5
5
|
require 'to-arff'
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name =
|
|
8
|
+
spec.name = 'to-arff'
|
|
9
9
|
spec.version = ToARFF::VERSION
|
|
10
|
-
spec.authors = [
|
|
11
|
-
spec.email = [
|
|
10
|
+
spec.authors = ['dhrubo_moy']
|
|
11
|
+
spec.email = ['dhrubo_moy@yahoo.com']
|
|
12
12
|
|
|
13
|
-
spec.summary = %q{ ToARFF is a ruby gem to convert sqlite database file
|
|
14
|
-
#spec.description = %q{
|
|
15
|
-
spec.homepage =
|
|
16
|
-
spec.license =
|
|
13
|
+
spec.summary = %q{ ToARFF is a ruby gem to convert sqlite database file to ARFF (Attribute-Relation File Format) file. }
|
|
14
|
+
# spec.description = %q{ }
|
|
15
|
+
spec.homepage = 'https://github.com/dhrubomoy/to-arff'
|
|
16
|
+
spec.license = 'MIT'
|
|
17
17
|
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
19
|
-
spec.bindir =
|
|
19
|
+
spec.bindir = 'exe'
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
21
|
-
spec.require_paths = [
|
|
21
|
+
spec.require_paths = ['lib']
|
|
22
22
|
|
|
23
|
-
spec.add_development_dependency
|
|
24
|
-
spec.add_development_dependency
|
|
25
|
-
spec.add_development_dependency
|
|
26
|
-
spec.add_development_dependency "sqlite3", "~> 1.3"
|
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
|
24
|
+
spec.add_development_dependency 'rake', '~> 11.2'
|
|
25
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
|
27
26
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: to-arff
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dhrubo_moy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-08-
|
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -30,28 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '11.2'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.0'
|
|
40
|
+
version: '11.2'
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
42
|
name: sqlite3
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -73,13 +59,13 @@ executables: []
|
|
|
73
59
|
extensions: []
|
|
74
60
|
extra_rdoc_files: []
|
|
75
61
|
files:
|
|
62
|
+
- ".codeclimate.yml"
|
|
76
63
|
- ".coveralls.yml"
|
|
77
64
|
- ".gitignore"
|
|
78
65
|
- ".rspec"
|
|
79
66
|
- ".travis.yml"
|
|
80
67
|
- CODE_OF_CONDUCT.md
|
|
81
68
|
- Gemfile
|
|
82
|
-
- Guardfile
|
|
83
69
|
- LICENSE.txt
|
|
84
70
|
- README.md
|
|
85
71
|
- Rakefile
|
|
@@ -112,6 +98,6 @@ rubyforge_project:
|
|
|
112
98
|
rubygems_version: 2.5.1
|
|
113
99
|
signing_key:
|
|
114
100
|
specification_version: 4
|
|
115
|
-
summary: ToARFF is a ruby gem to convert sqlite database file
|
|
116
|
-
|
|
101
|
+
summary: ToARFF is a ruby gem to convert sqlite database file to ARFF (Attribute-Relation
|
|
102
|
+
File Format) file.
|
|
117
103
|
test_files: []
|
data/Guardfile
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# A sample Guardfile
|
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
|
3
|
-
|
|
4
|
-
## Uncomment and set this to only include directories you want to watch
|
|
5
|
-
# directories %w(app lib config test spec features) \
|
|
6
|
-
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
|
7
|
-
|
|
8
|
-
## Note: if you are using the `directories` clause above and you are not
|
|
9
|
-
## watching the project directory ('.'), then you will want to move
|
|
10
|
-
## the Guardfile to a watched dir and symlink it back, e.g.
|
|
11
|
-
#
|
|
12
|
-
# $ mkdir config
|
|
13
|
-
# $ mv Guardfile config/
|
|
14
|
-
# $ ln -s config/Guardfile .
|
|
15
|
-
#
|
|
16
|
-
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
|
17
|
-
|
|
18
|
-
# Note: The cmd option is now required due to the increasing number of ways
|
|
19
|
-
# rspec may be run, below are examples of the most common uses.
|
|
20
|
-
# * bundler: 'bundle exec rspec'
|
|
21
|
-
# * bundler binstubs: 'bin/rspec'
|
|
22
|
-
# * spring: 'bin/rspec' (This will use spring if running and you have
|
|
23
|
-
# installed the spring binstubs per the docs)
|
|
24
|
-
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
|
25
|
-
# * 'just' rspec: 'rspec'
|
|
26
|
-
|
|
27
|
-
guard :rspec, cmd: "bundle exec rspec" do
|
|
28
|
-
require "guard/rspec/dsl"
|
|
29
|
-
dsl = Guard::RSpec::Dsl.new(self)
|
|
30
|
-
|
|
31
|
-
# Feel free to open issues for suggestions and improvements
|
|
32
|
-
|
|
33
|
-
# RSpec files
|
|
34
|
-
rspec = dsl.rspec
|
|
35
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
36
|
-
watch(rspec.spec_support) { rspec.spec_dir }
|
|
37
|
-
watch(rspec.spec_files)
|
|
38
|
-
|
|
39
|
-
# Ruby files
|
|
40
|
-
ruby = dsl.ruby
|
|
41
|
-
dsl.watch_spec_files_for(ruby.lib_files)
|
|
42
|
-
|
|
43
|
-
# Rails files
|
|
44
|
-
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
|
45
|
-
dsl.watch_spec_files_for(rails.app_files)
|
|
46
|
-
dsl.watch_spec_files_for(rails.views)
|
|
47
|
-
|
|
48
|
-
watch(rails.controllers) do |m|
|
|
49
|
-
[
|
|
50
|
-
rspec.spec.call("routing/#{m[1]}_routing"),
|
|
51
|
-
rspec.spec.call("controllers/#{m[1]}_controller"),
|
|
52
|
-
rspec.spec.call("acceptance/#{m[1]}")
|
|
53
|
-
]
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Rails config changes
|
|
57
|
-
watch(rails.spec_helper) { rspec.spec_dir }
|
|
58
|
-
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
|
59
|
-
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
|
60
|
-
|
|
61
|
-
# Capybara features specs
|
|
62
|
-
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
|
63
|
-
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
|
64
|
-
|
|
65
|
-
# Turnip features and steps
|
|
66
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
67
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
|
68
|
-
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
|
69
|
-
end
|
|
70
|
-
end
|