yard-bit-struct 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8931e8364d6818b0875c3fbad8f973fc8c15eeab
4
+ data.tar.gz: c18994240175d1a4793a29fb89a7feedb3a91743
5
+ SHA512:
6
+ metadata.gz: 8d3337c699eefdaec6552d1fb7aa8b68e7db63d360ed11c3e976ab93431a4938c5fc4432c0475aaf41e16f99541914bd8e1ce9d5117e4a9aa7aaf13998c88b45
7
+ data.tar.gz: 617aab77d3e2d0ee6dfa01562415dfcb80bde9ee5f2b78f5ffda2b1a4d976c28e832aacadfda56871ebb7ed7c3fa8923b5cc500d47f39d2e8cf3f6488876dc86
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yard-bit-struct.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ Copyright (c) 2015, Rapid7 Inc
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ * Neither the name of yard-bit-struct nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
@@ -0,0 +1,31 @@
1
+ # YARD::BitStruct
2
+
3
+ YARD extension for bit-struct's DSL
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'yard-bit-struct'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install yard-bit-struct
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/yard-bit-struct/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,4 @@
1
+
2
+ require 'yard/handlers/ruby/bit_struct_handler'
3
+ require 'yard/handlers/ruby/nest_handler'
4
+
@@ -0,0 +1,5 @@
1
+ module YARD
2
+ module BitStruct
3
+
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module YARD
2
+ module BitStruct
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ class YARD::Handlers::Ruby::BitStructHandler < YARD::Handlers::Ruby::AttributeHandler
2
+ handles method_call(:unsigned)
3
+ handles method_call(:signed)
4
+ handles method_call(:string)
5
+ namespace_only
6
+
7
+ def process
8
+ name = statement.parameters[0].jump(:tstring_content, :ident).source
9
+ bitlength = statement.parameters[1].jump(:tstring_content, :ident).source
10
+
11
+ type = case statement.method_name(true)
12
+ when :unsigned, :signed
13
+ "Fixnum"
14
+ when :string
15
+ "String"
16
+ else
17
+ "Object"
18
+ end
19
+
20
+ reader = YARD::CodeObjects::MethodObject.new(namespace, name)
21
+ reader.dynamic = true
22
+
23
+ # Grabs the comment and parses it out into MethodObject#docstring
24
+ register(reader)
25
+
26
+ if reader.docstring.blank?
27
+ # Use the default if there wasn't a field-specific docstring
28
+ doc = "Value of the `#{name}` field\n"
29
+ reader.docstring.replace(doc)
30
+ end
31
+
32
+ # Must have a writer method so this won't show up as read-only, but the
33
+ # reader's stuff takes precedence, so none of its properties seem to
34
+ # matter as long as there is a reader
35
+ writer = reader.dup
36
+ writer.name = "#{name}="
37
+
38
+ unless reader.docstring.has_tag?(:return)
39
+ reader.docstring.add_tag(
40
+ YARD::Tags::Tag.new(:return, "#{bitlength}-bit #{statement.method_name(true)} value", type)
41
+ )
42
+ end
43
+
44
+ namespace.attributes[scope][name] = SymbolHash[:read => reader, :write => writer]
45
+ end
46
+ end
47
+
@@ -0,0 +1,32 @@
1
+ class NestHandler < YARD::Handlers::Ruby::Base
2
+ handles method_call(:nest)
3
+ namespace_only
4
+
5
+ def process
6
+ name = statement.parameters[0].jump(:tstring_content, :ident).source
7
+ klass = statement.parameters[1].jump(:var_ref, :const).source
8
+
9
+ reader = YARD::CodeObjects::MethodObject.new(namespace, name)
10
+ reader.dynamic = true
11
+ if reader.docstring.blank?(false)
12
+ reader.docstring = "A copy of the value in the `#{name}` field"
13
+ end
14
+ unless reader.docstring.include?("@return")
15
+ reader.docstring += "\n@return [#{klass}]"
16
+ end
17
+ register(reader)
18
+
19
+ writer = YARD::CodeObjects::MethodObject.new(namespace, "#{name}=")
20
+ writer.signature = "def #{name}=(value)"
21
+ writer.source = "def #{name}=(value)\n @#{name} = value\nend"
22
+ writer.parameters = [['value', nil]]
23
+
24
+ writer.dynamic = true
25
+ if writer.docstring.blank?(false)
26
+ writer.docstring = "Sets the attribute #{name}\n@param value [#{klass},String] the value to set the attribute #{name} to."
27
+ end
28
+ register(writer)
29
+
30
+ namespace.attributes[scope][name] = SymbolHash[:read => reader, :write => writer]
31
+ end
32
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'yard/bit-struct'
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe YARD::BitStruct do
4
+ it 'has a version number' do
5
+ expect(described_class::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yard/bit-struct/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yard-bit-struct"
8
+ spec.version = YARD::BitStruct::VERSION
9
+ spec.authors = ["James Lee"]
10
+ spec.email = ["egypt@metasploit.com"]
11
+ spec.summary = %q{YARD plugin for documenting bit-struct's DSL}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "BSD 3-clause"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-bit-struct
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - James Lee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: ''
56
+ email:
57
+ - egypt@metasploit.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - lib/yard-bit-struct.rb
70
+ - lib/yard/bit-struct.rb
71
+ - lib/yard/bit-struct/version.rb
72
+ - lib/yard/handlers/ruby/bit_struct_handler.rb
73
+ - lib/yard/handlers/ruby/nest_handler.rb
74
+ - spec/spec_helper.rb
75
+ - spec/yard/bit-struct_spec.rb
76
+ - yard-bit-struct.gemspec
77
+ homepage: ''
78
+ licenses:
79
+ - BSD 3-clause
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.3
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: YARD plugin for documenting bit-struct's DSL
101
+ test_files:
102
+ - spec/spec_helper.rb
103
+ - spec/yard/bit-struct_spec.rb