indydoc 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d15ff3b619425fd11ab09a560b077ad0a010d85
4
- data.tar.gz: 63ce1209b39224380e9ff5a7ead3109d4b0d0045
3
+ metadata.gz: 1bbe7ea2abee3763a3ae5c2e57a2946b28169a32
4
+ data.tar.gz: 601e2fa6594abd8966fcea922c61b772a05a133e
5
5
  SHA512:
6
- metadata.gz: 9cdd0bf715bbbca7cc296115ab3debff15709f1f0ec097974b2634126c5b7beacd23b16b82e2c2c940ae602ad63b705256d8a9fb9cf35d7fbe40f7fe975e639e
7
- data.tar.gz: adafa3ff43b8e02b07f776c6c64542d2ccdd0dc27e2b77fc8d587641d98f9ad9a107e149407e526a9cd6591d527dc6699d28fba2fd4857c7271492eb9f7bbdf1
6
+ metadata.gz: f2eeb55b3011290ebbea2ba5e563ec2e6fe52c27188f99af4ea01458668d5f950c844d79dd457dded70ad9e06559edef25bc8c4403dc326b5fd4465080a9672e
7
+ data.tar.gz: 8799dee93c6fb8f9ccb56053f2f1657795fa4e999ad7a8e3369d092c08f86794c74227d5087a2567d38832bf56696f3632f4e25291563b7395bb2478be257c2a
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/indydoc.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  # file: indydoc.rb
4
4
 
5
+ require 'polyrex'
5
6
  require 'nokogiri'
6
7
  require 'open-uri'
7
8
  require 'method_parser'
@@ -9,13 +10,53 @@ require 'method_parser'
9
10
 
10
11
  class IndyDoc
11
12
 
13
+ attr_reader :to_s
14
+
12
15
  def initialize(file=nil, path: File.dirname(__FILE__))
13
16
  @file = file
14
- @px = File.read(file) if file
17
+ @px = Polyrex.new file if file
15
18
  @path = path
16
- end
19
+ end
20
+
21
+ def merge(rbfile = nil)
22
+
23
+
24
+ buffer = File.read rbfile
25
+
26
+ @px.records.each do |x|
27
+
28
+ x.records.each do |method|
29
+
30
+ if method.desc.strip.length > 0 then
31
+
32
+ buffer.sub!(/( *)def\s+#{method.name}/) do |y|
17
33
 
18
- def parse(filepath)
34
+ indent = ($1)
35
+
36
+ comment = if method.desc.lines.length < 2 then
37
+ method.desc.lines\
38
+ .map {|line| "%s# %s\n" % [indent,line.chomp]}
39
+ else
40
+
41
+ lines = method.desc.lines\
42
+ .map {|line| "%s# %s" % [indent,line.chomp]}
43
+
44
+ [indent + '#'] << lines << [indent + "#\n"]
45
+
46
+ end
47
+
48
+ y.sub(/(?= *def\s+#{method.name})/, comment.join("\n"))
49
+
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ @to_s = buffer
56
+
57
+ end
58
+
59
+ def parse(filepath)
19
60
  mp = MethodParser.new File.read(filepath)
20
61
  @raw_xml = mp.to_xml
21
62
  end
@@ -23,9 +64,8 @@ class IndyDoc
23
64
  def save(filepath=@file)
24
65
 
25
66
  raise 'IndyDoc#save: please supply a file path' if filepath.nil?
26
-
27
- @px ||= self.to_px
28
- File.write filepath, @px
67
+
68
+ @px ? px.save(filepath) : File.write(filepath, @px=self.to_px)
29
69
  puts 'saved'
30
70
  end
31
71
 
data/lib/indydoc.rb~ ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: indydoc.rb
4
+
5
+ require 'nokogiri'
6
+ require 'open-uri'
7
+ require 'method_parser'
8
+
9
+
10
+ class IndyDoc
11
+
12
+ def initialize(file=nil, path: File.dirname(__FILE__))
13
+ @file = file
14
+ @px = File.read(file) if file
15
+ @path = path
16
+ end
17
+
18
+ def parse(filepath)
19
+ mp = MethodParser.new File.read(filepath)
20
+ @raw_xml = mp.to_xml
21
+ end
22
+
23
+ def save(filepath=@file)
24
+
25
+ raise 'IndyDoc#save: please supply a file path' if filepath.nil?
26
+
27
+ @px ||= self.to_px
28
+ File.write filepath, @px
29
+ puts 'saved'
30
+ end
31
+
32
+ def to_px
33
+ doc = Nokogiri::XML(@raw_xml)
34
+ xsl_source = File.read(File.join(@path,'to_polyrex.xsl'))
35
+ #xsl_source = open(File.join(@path,'template.xsl'),
36
+ # 'UserAgent' => 'IndyDoc').read
37
+ xslt = Nokogiri::XSLT(xsl_source)
38
+ xslt.transform(doc).to_s
39
+ end
40
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indydoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  O2NWI/Mtqr6/TnZVTu+xVC1mt30la4CrzcJW0P5NjbgUPEy9xfTnms03KvNvL6Gx
32
32
  5ZaE7gNbPGDp7Q==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-09-18 00:00:00.000000000 Z
34
+ date: 2014-09-20 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
@@ -73,6 +73,26 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.1.5
76
+ - !ruby/object:Gem::Dependency
77
+ name: polyrex
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.9.11
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.9'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 0.9.11
76
96
  description:
77
97
  email: james@r0bertson.co.uk
78
98
  executables: []
@@ -80,6 +100,7 @@ extensions: []
80
100
  extra_rdoc_files: []
81
101
  files:
82
102
  - lib/indydoc.rb
103
+ - lib/indydoc.rb~
83
104
  - lib/to_polyrex.xsl
84
105
  homepage: https://github.com/jrobertson/indydoc
85
106
  licenses:
metadata.gz.sig CHANGED
Binary file