sql-maker 0.0.2 → 0.0.3

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.
@@ -0,0 +1,41 @@
1
+ require 'tempfile'
2
+ require 'fileutils'
3
+
4
+ def pod2md(paths)
5
+ paths.each do |path|
6
+ code, md = '', ''
7
+ File.open(path, 'r') do |fp|
8
+ while line = fp.gets
9
+ break if line.chomp == "__END__"
10
+ code << line
11
+ end
12
+ while line = fp.gets
13
+ line.gsub!(/^=encoding.*/, '')
14
+ line.gsub!(/^=head1/, '#')
15
+ line.gsub!(/^=head2/, '##')
16
+ line.gsub!(/^=item/, '###')
17
+ line.gsub!(/^=over.*/, '')
18
+ line.gsub!(/^=cut.*/, '')
19
+ line.gsub!(/^=back.*/, '')
20
+ line.gsub!(/C<< (.+) >>/, '\1')
21
+ line.gsub!(/L<([^>]+)>/, '\1')
22
+ line.gsub!(/B<([^>]+)>/, '\1')
23
+ line.gsub!(/C<([^>]+)>/, '\1')
24
+ md << line
25
+ end
26
+ end
27
+ File.open(path, 'w') do |fp|
28
+ fp.puts code.strip
29
+ end
30
+ docpath = path.gsub('lib', 'doc').gsub(/.rb$/, '.md')
31
+ FileUtils.mkdir_p File.dirname(docpath)
32
+ File.open(docpath, 'w') do |fp|
33
+ fp.puts md.strip
34
+ end
35
+ end
36
+ end
37
+
38
+ paths = %w[lib/sql/maker.rb lib/sql/query_maker.rb]
39
+ paths += Dir.glob('lib/sql/maker/*.rb').to_a
40
+ pod2md(paths)
41
+
@@ -22,12 +22,12 @@ def test(input, expected_term, expected_bind)
22
22
  end
23
23
 
24
24
  begin
25
- file = File.open("#{ROOT}/lib/sql/maker/condition.rb")
25
+ file = File.open("#{ROOT}/doc/sql/maker/condition.md")
26
26
  while line = file.gets
27
- break if line =~ /=head1 CONDITION CHEAT SHEET/
27
+ break if line =~ /CONDITION CHEAT SHEET/
28
28
  end
29
29
  while line = file.gets
30
- next if line =~ /^#/
30
+ next if line =~ /^ *#/
31
31
  src = $1 if line =~ /IN:\s*(.+)\s*$/
32
32
  query = eval($1, binding) if line =~ /OUT QUERY:(.+)/
33
33
  if line =~ /OUT BIND:(.+)/
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require 'sql/maker/select'
3
3
 
4
4
  begin
5
- fname = "#{ROOT}/lib/sql/maker/select.rb"
5
+ fname = "#{ROOT}/doc/sql/maker/select.md"
6
6
  file = File.open(fname)
7
7
  lineno = 0
8
8
  while line = file.gets
@@ -14,7 +14,7 @@ begin
14
14
  it do
15
15
  while line = file.gets
16
16
  lineno += 1
17
- next if line =~ /^#/
17
+ next if line =~ /^ *#/
18
18
  if line =~ /^[ ]{4,}.*# => (.+)/
19
19
  # puts "----------------------"
20
20
  # puts code
@@ -23,7 +23,7 @@ begin
23
23
  got.gsub!(/\n/, ' ')
24
24
  got.gsub!(/ +$/, '')
25
25
  expect(got).to be == expected
26
- elsif (/^[ ]{4,}(.+)/)
26
+ elsif line =~ /^[ ]{4,}(.+)/
27
27
  code += "#{$1}\n"
28
28
  else
29
29
  code = '' # clear
@@ -17,9 +17,9 @@ def test(src, expected_term, expected_bind)
17
17
  end
18
18
 
19
19
  begin
20
- file = File.open("#{ROOT}/lib/sql/query_maker.rb")
20
+ file = File.open("#{ROOT}/doc/sql/query_maker.md")
21
21
  while line = file.gets
22
- break if line =~ /=head1 CHEAT SHEET/
22
+ break if line =~ /CHEAT SHEET/
23
23
  end
24
24
  while line = file.gets
25
25
  src = $1 if line =~ /IN:\s*(.+)\s*$/
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "sql-maker"
7
- spec.version = "0.0.2"
7
+ spec.version = "0.0.3"
8
8
  spec.authors = ["Naotoshi Seo"]
9
9
  spec.email = ["sonots@gmail.com"]
10
10
  spec.summary = %q{SQL Builder for Ruby}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sql-maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-18 00:00:00.000000000 Z
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,11 +88,22 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - ".gitignore"
91
+ - ".travis.yml"
91
92
  - CHANGELOG.md
92
93
  - Gemfile
93
94
  - LICENSE.txt
94
95
  - README.md
95
96
  - Rakefile
97
+ - doc/README.md
98
+ - doc/sql/maker.md
99
+ - doc/sql/maker/condition.md
100
+ - doc/sql/maker/error.md
101
+ - doc/sql/maker/helper.md
102
+ - doc/sql/maker/quoting.md
103
+ - doc/sql/maker/select.md
104
+ - doc/sql/maker/select_set.md
105
+ - doc/sql/maker/util.md
106
+ - doc/sql/query_maker.md
96
107
  - lib/sql-maker.rb
97
108
  - lib/sql/maker.rb
98
109
  - lib/sql/maker/condition.rb
@@ -105,11 +116,12 @@ files:
105
116
  - lib/sql/maker/util.rb
106
117
  - lib/sql/query_maker.rb
107
118
  - scripts/perl2ruby.rb
119
+ - scripts/pod2md.rb
108
120
  - spec/maker/bind_param_spec.rb
109
121
  - spec/maker/condition/add_raw_spec.rb
122
+ - spec/maker/condition/cheatsheat_spec.rb
110
123
  - spec/maker/condition/compose_empty_spec.rb
111
124
  - spec/maker/condition/empty_values_spec.rb
112
- - spec/maker/condition/make_term_spec.rb
113
125
  - spec/maker/condition/where_spec.rb
114
126
  - spec/maker/delete_spec.rb
115
127
  - spec/maker/insert_empty_spec.rb
@@ -159,9 +171,9 @@ summary: SQL Builder for Ruby
159
171
  test_files:
160
172
  - spec/maker/bind_param_spec.rb
161
173
  - spec/maker/condition/add_raw_spec.rb
174
+ - spec/maker/condition/cheatsheat_spec.rb
162
175
  - spec/maker/condition/compose_empty_spec.rb
163
176
  - spec/maker/condition/empty_values_spec.rb
164
- - spec/maker/condition/make_term_spec.rb
165
177
  - spec/maker/condition/where_spec.rb
166
178
  - spec/maker/delete_spec.rb
167
179
  - spec/maker/insert_empty_spec.rb