slacker 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +0 -1
- data/LICENSE +1 -1
- data/bin/slacker +29 -29
- data/lib/slacker/version.rb +1 -1
- data/slacker.gemspec +2 -0
- data/spec/rspec_ext_spec.rb +126 -126
- data/spec/test_files/matcher/test_1.csv +3 -3
- data/spec/test_files/test_slacker_project/data/test_1.csv +3 -3
- data/spec/test_files/test_slacker_project/sql/no_params.sql.erb +2 -2
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
data/bin/slacker
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'bundler/setup'
|
3
|
-
require 'slacker'
|
4
|
-
require 'yaml'
|
5
|
-
require 'slacker/command_line_formatter'
|
6
|
-
|
7
|
-
def db_config_from_file(file_path)
|
8
|
-
dbconfig = nil
|
9
|
-
File.open(file_path) do |dbconfig_file|
|
10
|
-
dbconfig = YAML::load(dbconfig_file)
|
11
|
-
end
|
12
|
-
dbconfig
|
13
|
-
end
|
14
|
-
|
15
|
-
# Preset the application to run on the console
|
16
|
-
Slacker.configure do |config|
|
17
|
-
config.console_enabled = true
|
18
|
-
config.formatter = Slacker::CommandLineFormatter.new($stdout)
|
19
|
-
|
20
|
-
# Setup the target connection based on the contents in database.yml
|
21
|
-
db_config = db_config_from_file(config.expand_path('database.yml'))
|
22
|
-
|
23
|
-
config.db_server = db_config["server"]
|
24
|
-
config.db_name = db_config["database"]
|
25
|
-
config.db_user = db_config["user"]
|
26
|
-
config.db_password = db_config["password"]
|
27
|
-
end
|
28
|
-
|
29
|
-
Slacker.application.run
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'slacker'
|
4
|
+
require 'yaml'
|
5
|
+
require 'slacker/command_line_formatter'
|
6
|
+
|
7
|
+
def db_config_from_file(file_path)
|
8
|
+
dbconfig = nil
|
9
|
+
File.open(file_path) do |dbconfig_file|
|
10
|
+
dbconfig = YAML::load(dbconfig_file)
|
11
|
+
end
|
12
|
+
dbconfig
|
13
|
+
end
|
14
|
+
|
15
|
+
# Preset the application to run on the console
|
16
|
+
Slacker.configure do |config|
|
17
|
+
config.console_enabled = true
|
18
|
+
config.formatter = Slacker::CommandLineFormatter.new($stdout)
|
19
|
+
|
20
|
+
# Setup the target connection based on the contents in database.yml
|
21
|
+
db_config = db_config_from_file(config.expand_path('database.yml'))
|
22
|
+
|
23
|
+
config.db_server = db_config["server"]
|
24
|
+
config.db_name = db_config["database"]
|
25
|
+
config.db_user = db_config["user"]
|
26
|
+
config.db_password = db_config["password"]
|
27
|
+
end
|
28
|
+
|
29
|
+
Slacker.application.run
|
data/lib/slacker/version.rb
CHANGED
data/slacker.gemspec
CHANGED
data/spec/rspec_ext_spec.rb
CHANGED
@@ -1,127 +1,127 @@
|
|
1
|
-
require 'slacker'
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
|
-
class RSpecSlackerHost
|
6
|
-
include Slacker::RSpecExt
|
7
|
-
end
|
8
|
-
|
9
|
-
describe Slacker::RSpecExt do
|
10
|
-
before(:each) do
|
11
|
-
Slacker::configure do |config|
|
12
|
-
config.base_dir = SpecHelper.expand_test_files_path('test_slacker_project')
|
13
|
-
end
|
14
|
-
|
15
|
-
example = OpenStruct.new
|
16
|
-
example.metadata = {:sql => '', :example_group => {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_xyz.rb')}}
|
17
|
-
|
18
|
-
@instance = RSpecSlackerHost.new
|
19
|
-
@instance.stub(:example).and_return(example)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'responds to query' do
|
23
|
-
@instance.should respond_to(:query)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'responds to match' do
|
27
|
-
@instance.should respond_to(:match)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'responds to csv' do
|
31
|
-
@instance.should respond_to(:csv)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'responds to load_csv' do
|
35
|
-
@instance.should respond_to(:load_csv)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'responds to result' do
|
39
|
-
@instance.should respond_to(:result)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'responds to sql' do
|
43
|
-
@instance.should respond_to(:sql)
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'responds to ghost methods' do
|
47
|
-
before(:each) do
|
48
|
-
Slacker.application.stub(:query_script) {|sql| sql}
|
49
|
-
end
|
50
|
-
|
51
|
-
specify 'described as SQL files found in the sql/helpers folder' do
|
52
|
-
@instance.sql.respond_to?(:helpers).should be_true
|
53
|
-
@instance.sql.helpers.respond_to?(:helper_1).should be_true
|
54
|
-
@instance.sql.helpers.helper_1.should == 'helpers/helper_1.sql called'
|
55
|
-
end
|
56
|
-
|
57
|
-
specify 'described as SQL.ERB files found in the sql/helpers folder' do
|
58
|
-
@instance.sql.helpers.respond_to?(:helper_2).should be_true
|
59
|
-
@instance.sql.helpers.helper_2.should == 'helpers/helper_2.sql.erb called'
|
60
|
-
end
|
61
|
-
|
62
|
-
specify 'with SQL files taking priority over SQL.ERB files' do
|
63
|
-
@instance.sql.helpers.respond_to?(:helper_3).should be_true
|
64
|
-
@instance.sql.helpers.helper_3.should == 'helpers/helper_3.sql called'
|
65
|
-
end
|
66
|
-
|
67
|
-
specify 'but ignores non-existing methods' do
|
68
|
-
@instance.sql.helpers.respond_to?(:some_bogus_method).should be_false
|
69
|
-
end
|
70
|
-
|
71
|
-
specify 'but ignores files which are not with SQL or SQL.ERB extension' do
|
72
|
-
@instance.sql.helpers.respond_to?(:text_file_1).should be_false
|
73
|
-
end
|
74
|
-
|
75
|
-
specify 'and is case insensitive' do
|
76
|
-
@instance.sql.helpers.respond_to?(:helper_4).should be_true
|
77
|
-
@instance.sql.helpers.respond_to?(:hElpEr_4).should be_true
|
78
|
-
@instance.sql.helpers.helper_4.should == 'helpers/HELPER_4.SQL called'
|
79
|
-
@instance.sql.helpers.heLpEr_4.should == 'helpers/HELPER_4.SQL called'
|
80
|
-
end
|
81
|
-
|
82
|
-
specify 'from folders other than helpers' do
|
83
|
-
@instance.sql.respond_to?(:example_1).should be_true
|
84
|
-
@instance.sql.example_1.respond_to?(:helper_1).should be_true
|
85
|
-
@instance.sql.example_1.helper_1.should == 'example_1/helper_1.sql called'
|
86
|
-
end
|
87
|
-
|
88
|
-
specify "works with deeply nested example files reflecting their location in the lookup of SQL files in the SQL folder" do
|
89
|
-
@instance.sql.respond_to?(:nest).should be_true
|
90
|
-
@instance.sql.nest.respond_to?(:example_1).should be_true
|
91
|
-
@instance.sql.nest.example_1.respond_to?(:helper_1).should be_true
|
92
|
-
@instance.sql.nest.example_1.helper_1.should == 'nest/example_1/helper_1.sql.erb called'
|
93
|
-
end
|
94
|
-
|
95
|
-
# context do
|
96
|
-
# before(:each) do
|
97
|
-
# # Fake the current example in the RSpec ext
|
98
|
-
# @example = OpenStruct.new :metadata => {:sql => ''}
|
99
|
-
# @instance.stub(:example).and_return(@example)
|
100
|
-
# end
|
101
|
-
#
|
102
|
-
# specify "with files from the current example's file folder taking priority over the helpers folder" do
|
103
|
-
# @example.metadata[:example_group] = {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_1.rb')}
|
104
|
-
# @instance.sql.respond_to?(:helper_1).should be_true
|
105
|
-
# @instance.sql.helper_1.should == 'example_1/helper_1.sql called'
|
106
|
-
# end
|
107
|
-
#
|
108
|
-
# specify "in example group giving priority to SQL files over SQL.ERB files" do
|
109
|
-
# @example.metadata[:example_group] = {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_1.rb')}
|
110
|
-
# @instance.sql.respond_to?(:helper_2).should be_true
|
111
|
-
# @instance.sql.helper_2.should == 'example_1/helper_2.sql called'
|
112
|
-
# end
|
113
|
-
#
|
114
|
-
# specify "works with deeply nested example files reflecting their location in the lookup of SQL files in the SQL folder" do
|
115
|
-
# @example.metadata[:example_group] = {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/nest/example_1.rb')}
|
116
|
-
# @instance.sql.respond_to?(:helper_1).should be_true
|
117
|
-
# @instance.sql.helper_1.should == 'nest/example_1/helper_1.sql.erb called'
|
118
|
-
# end
|
119
|
-
#
|
120
|
-
# specify "falls back to the global helper when there is no matching file in the example folder" do
|
121
|
-
# @example.metadata[:example_group] = {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_1.rb')}
|
122
|
-
# @instance.sql.respond_to?(:helper_3).should be_true
|
123
|
-
# @instance.sql.helper_3.should == 'helpers/helper_3.sql called'
|
124
|
-
# end
|
125
|
-
# end
|
126
|
-
end
|
1
|
+
require 'slacker'
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
class RSpecSlackerHost
|
6
|
+
include Slacker::RSpecExt
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Slacker::RSpecExt do
|
10
|
+
before(:each) do
|
11
|
+
Slacker::configure do |config|
|
12
|
+
config.base_dir = SpecHelper.expand_test_files_path('test_slacker_project')
|
13
|
+
end
|
14
|
+
|
15
|
+
example = OpenStruct.new
|
16
|
+
example.metadata = {:sql => '', :example_group => {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_xyz.rb')}}
|
17
|
+
|
18
|
+
@instance = RSpecSlackerHost.new
|
19
|
+
@instance.stub(:example).and_return(example)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'responds to query' do
|
23
|
+
@instance.should respond_to(:query)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'responds to match' do
|
27
|
+
@instance.should respond_to(:match)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'responds to csv' do
|
31
|
+
@instance.should respond_to(:csv)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'responds to load_csv' do
|
35
|
+
@instance.should respond_to(:load_csv)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'responds to result' do
|
39
|
+
@instance.should respond_to(:result)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'responds to sql' do
|
43
|
+
@instance.should respond_to(:sql)
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'responds to ghost methods' do
|
47
|
+
before(:each) do
|
48
|
+
Slacker.application.stub(:query_script) {|sql| sql}
|
49
|
+
end
|
50
|
+
|
51
|
+
specify 'described as SQL files found in the sql/helpers folder' do
|
52
|
+
@instance.sql.respond_to?(:helpers).should be_true
|
53
|
+
@instance.sql.helpers.respond_to?(:helper_1).should be_true
|
54
|
+
@instance.sql.helpers.helper_1.should == 'helpers/helper_1.sql called'
|
55
|
+
end
|
56
|
+
|
57
|
+
specify 'described as SQL.ERB files found in the sql/helpers folder' do
|
58
|
+
@instance.sql.helpers.respond_to?(:helper_2).should be_true
|
59
|
+
@instance.sql.helpers.helper_2.should == 'helpers/helper_2.sql.erb called'
|
60
|
+
end
|
61
|
+
|
62
|
+
specify 'with SQL files taking priority over SQL.ERB files' do
|
63
|
+
@instance.sql.helpers.respond_to?(:helper_3).should be_true
|
64
|
+
@instance.sql.helpers.helper_3.should == 'helpers/helper_3.sql called'
|
65
|
+
end
|
66
|
+
|
67
|
+
specify 'but ignores non-existing methods' do
|
68
|
+
@instance.sql.helpers.respond_to?(:some_bogus_method).should be_false
|
69
|
+
end
|
70
|
+
|
71
|
+
specify 'but ignores files which are not with SQL or SQL.ERB extension' do
|
72
|
+
@instance.sql.helpers.respond_to?(:text_file_1).should be_false
|
73
|
+
end
|
74
|
+
|
75
|
+
specify 'and is case insensitive' do
|
76
|
+
@instance.sql.helpers.respond_to?(:helper_4).should be_true
|
77
|
+
@instance.sql.helpers.respond_to?(:hElpEr_4).should be_true
|
78
|
+
@instance.sql.helpers.helper_4.should == 'helpers/HELPER_4.SQL called'
|
79
|
+
@instance.sql.helpers.heLpEr_4.should == 'helpers/HELPER_4.SQL called'
|
80
|
+
end
|
81
|
+
|
82
|
+
specify 'from folders other than helpers' do
|
83
|
+
@instance.sql.respond_to?(:example_1).should be_true
|
84
|
+
@instance.sql.example_1.respond_to?(:helper_1).should be_true
|
85
|
+
@instance.sql.example_1.helper_1.should == 'example_1/helper_1.sql called'
|
86
|
+
end
|
87
|
+
|
88
|
+
specify "works with deeply nested example files reflecting their location in the lookup of SQL files in the SQL folder" do
|
89
|
+
@instance.sql.respond_to?(:nest).should be_true
|
90
|
+
@instance.sql.nest.respond_to?(:example_1).should be_true
|
91
|
+
@instance.sql.nest.example_1.respond_to?(:helper_1).should be_true
|
92
|
+
@instance.sql.nest.example_1.helper_1.should == 'nest/example_1/helper_1.sql.erb called'
|
93
|
+
end
|
94
|
+
|
95
|
+
# context do
|
96
|
+
# before(:each) do
|
97
|
+
# # Fake the current example in the RSpec ext
|
98
|
+
# @example = OpenStruct.new :metadata => {:sql => ''}
|
99
|
+
# @instance.stub(:example).and_return(@example)
|
100
|
+
# end
|
101
|
+
#
|
102
|
+
# specify "with files from the current example's file folder taking priority over the helpers folder" do
|
103
|
+
# @example.metadata[:example_group] = {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_1.rb')}
|
104
|
+
# @instance.sql.respond_to?(:helper_1).should be_true
|
105
|
+
# @instance.sql.helper_1.should == 'example_1/helper_1.sql called'
|
106
|
+
# end
|
107
|
+
#
|
108
|
+
# specify "in example group giving priority to SQL files over SQL.ERB files" do
|
109
|
+
# @example.metadata[:example_group] = {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_1.rb')}
|
110
|
+
# @instance.sql.respond_to?(:helper_2).should be_true
|
111
|
+
# @instance.sql.helper_2.should == 'example_1/helper_2.sql called'
|
112
|
+
# end
|
113
|
+
#
|
114
|
+
# specify "works with deeply nested example files reflecting their location in the lookup of SQL files in the SQL folder" do
|
115
|
+
# @example.metadata[:example_group] = {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/nest/example_1.rb')}
|
116
|
+
# @instance.sql.respond_to?(:helper_1).should be_true
|
117
|
+
# @instance.sql.helper_1.should == 'nest/example_1/helper_1.sql.erb called'
|
118
|
+
# end
|
119
|
+
#
|
120
|
+
# specify "falls back to the global helper when there is no matching file in the example folder" do
|
121
|
+
# @example.metadata[:example_group] = {:file_path => SpecHelper.expand_test_files_path('test_slacker_project/spec/example_1.rb')}
|
122
|
+
# @instance.sql.respond_to?(:helper_3).should be_true
|
123
|
+
# @instance.sql.helper_3.should == 'helpers/helper_3.sql called'
|
124
|
+
# end
|
125
|
+
# end
|
126
|
+
end
|
127
127
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
"Field 1","Field_2","b"
|
2
|
-
12,,""
|
3
|
-
"test string",01/01/2011,8.9
|
1
|
+
"Field 1","Field_2","b"
|
2
|
+
12,,""
|
3
|
+
"test string",01/01/2011,8.9
|
@@ -1,3 +1,3 @@
|
|
1
|
-
"Field 1","Field_2","b"
|
2
|
-
12,10,11
|
3
|
-
"test string",01/01/2011,8.9
|
1
|
+
"Field 1","Field_2","b"
|
2
|
+
12,10,11
|
3
|
+
"test string",01/01/2011,8.9
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%2.times do |i|%>
|
2
|
-
select <%=i+1%>;
|
1
|
+
<%2.times do |i|%>
|
2
|
+
select <%=i+1%>;
|
3
3
|
<%end%>
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: slacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Vassil Kovatchev
|
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
requirements:
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
116
|
+
version: 1.9.2
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|