ember-excerpt 0.0.2

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGUxMWIwYmY5NDg2ZjI4ODI5Mzc2MjgzMWVhMzc4ZWY1ZTc3MTM3Mw==
5
+ data.tar.gz: !binary |-
6
+ ZTdkNDA3YWY1YjgxMjMwZmExYjgxMjg4OGEzN2VmNjNiMzJlNzE0ZA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NTIwYWIwMGFhODczNTIyYmQ3ZTI1N2RiMGFlNzhmMTMzNzY5YWNhMTcyMjhm
10
+ Yzk4ZGRhMjUzYTY2MGRlMjllMjczOWNhYjM4YzA5OWI1OGRiYmZjMGVhNjVh
11
+ MTBkYzI2YWQ1NGYyZjgxZDlkMzAyMjBlM2M3NDczYjA0MmI4MGI=
12
+ data.tar.gz: !binary |-
13
+ MDk1ODIzOWRiNjhlNzE1NjQ0ZjY2MTIzNDc4OTU0MTU5NTM0OWI4NGVmNzc5
14
+ N2Y2NTE0ZGI5YzlhOGRlZDllYTAwMjE1MDFlYTczMzM3NDliYmQ0M2Y1ODg4
15
+ NDE5OTI0NjIwOGE5YjVmN2QyMjE0YTAyZjg1ZDcyY2U4YzMwM2U=
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ notes.txt
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Darshan Sawardekar (darshan@sawardekar.org)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # EmberExcerpt
2
+
3
+ Extracts keywords like methods, classes, etc from ember documentation. This is
4
+ useful for creating syntax files for vim and other editors.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ $ gem 'ember-excerpt'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install ember-excerpt
19
+
20
+ ## Usage
21
+
22
+ Default uses api.yml from ember's github repository.
23
+
24
+ $ ember-excerpt -t <extract_type> -o <output_file>
25
+
26
+ Or specify a path to the yml file manually with -i
27
+
28
+ $ ember-excerpt -i <doc.yml> -t <extract_type> -o <output_file>
29
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/ember-excerpt ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path('../../lib/ember_excerpt/loader', __FILE__)
4
+
5
+ module EmberExcerpt
6
+
7
+ require 'ember_excerpt/cli/app'
8
+ app = EmberExcerpt::CLI::App.new
9
+ app.start(ARGV)
10
+
11
+ 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
+
5
+ require 'ember_excerpt/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "ember-excerpt"
9
+ spec.version = EmberExcerpt::VERSION
10
+ spec.authors = ["Darshan Sawardekar"]
11
+ spec.email = ["darshan@sawardekar.org"]
12
+ spec.description = %q{Extracts keywords from ember documentation.}
13
+ spec.summary = %q{Extracts keywords like methods, classnames from ember documentation yml.}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,17 @@
1
+ module EmberExcerpt
2
+ module CLI
3
+
4
+ require_relative 'options'
5
+ require_relative 'router'
6
+
7
+ class App
8
+ def start(args)
9
+ options = Options.new
10
+ opts = options.load(args)
11
+
12
+ router = Router.new
13
+ router.route(opts.action, opts)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,131 @@
1
+ module EmberExcerpt
2
+ module CLI
3
+
4
+ require 'ember_excerpt/version'
5
+ require 'uri'
6
+ require 'yaml'
7
+ require 'open-uri'
8
+
9
+ class Controller
10
+
11
+ def initialize(options)
12
+ @options = options
13
+ end
14
+
15
+ def show_version
16
+ puts VERSION
17
+ end
18
+
19
+ def show_help
20
+ puts @options.options
21
+ end
22
+
23
+ def show_error(msg = @options.error)
24
+ puts "Error: #{msg}"
25
+ puts
26
+
27
+ show_help
28
+ end
29
+
30
+ def show_invalid_option
31
+ show_error @options.error
32
+ end
33
+
34
+ def show_missing_args
35
+ show_error @options.error
36
+ end
37
+
38
+ def show_parser_error
39
+ show_error @options.error
40
+ end
41
+
42
+ def extract
43
+ begin
44
+ data = load(@options.input)
45
+
46
+ extractor = get_extractor(@options.type)
47
+ items = extractor.extract(data)
48
+
49
+ write_output(items)
50
+ rescue => err
51
+ puts 'Extract Failed'
52
+ if @options.verbose
53
+ puts err.backtrace
54
+ end
55
+ end
56
+ end
57
+
58
+ def write_output(items)
59
+ if items.length == 0
60
+ puts "Nothing to output for #{options.type}"
61
+ else
62
+ file = File.open(@options.output, 'w')
63
+ items.each do |item|
64
+ file.puts item
65
+ end
66
+
67
+ file.close
68
+ puts "Wrote #{items.length} items to #{@options.output}"
69
+ end
70
+ end
71
+
72
+ def get_extractor(type)
73
+ if type == 'class'
74
+ return ClassExtractor.new
75
+ elsif type == 'method'
76
+ return MethodExtractor.new
77
+ else
78
+ raise "Extractor not found for type: #{type}"
79
+ end
80
+ end
81
+
82
+ def uri?(string)
83
+ uri = URI.parse(string)
84
+ %w( http https ).include?(uri.scheme)
85
+ rescue URI::BadURIError
86
+ false
87
+ rescue URI::InvalidURIError
88
+ false
89
+ end
90
+
91
+ def load(input)
92
+ puts "Loading #{input}"
93
+ data = open(input)
94
+ yml = YAML.load(data)
95
+
96
+ return yml
97
+ end
98
+ end
99
+
100
+ class MethodExtractor
101
+ def extract(yml)
102
+ methods = []
103
+ unless yml['classitems'].nil?
104
+ yml['classitems'].each do |key, value|
105
+ access = key['access']
106
+ if (!key['name'].nil?) && (access == 'public' || access.nil?)
107
+ methods << key['name']
108
+ end
109
+ end
110
+ end
111
+
112
+ methods
113
+ end
114
+ end
115
+
116
+ class ClassExtractor
117
+ def extract(yml)
118
+ classes = []
119
+ unless yml['classes'].nil?
120
+ yml['classes'].each do |key, value|
121
+ unless value['name'].nil?
122
+ classes << value['name']
123
+ end
124
+ end
125
+ end
126
+
127
+ classes
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,78 @@
1
+ module EmberExcerpt
2
+ module CLI
3
+
4
+ require 'optparse'
5
+ require 'ostruct'
6
+
7
+ class Options
8
+ include Loader
9
+
10
+ def load(args)
11
+ opts = OpenStruct.new
12
+ opts.action = :extract
13
+ opts.input = nil
14
+
15
+ parser = OptionParser.new do |o|
16
+ opts.options = o
17
+
18
+ o.banner = "Usage: ember-excerpt -t <type> -o <output>"
19
+ o.separator ''
20
+ o.separator 'Options:'
21
+ o.separator ''
22
+
23
+ o.on_head('-t', '--type <type>', 'Specify the type to extract') do |type|
24
+ opts.type = type
25
+ end
26
+
27
+ o.on_head('-o', '--output <output>', 'Specify the output file to extract into') do |output|
28
+ opts.output = output
29
+ end
30
+
31
+ o.on_tail('-i', '--input <input>', 'Optional specify the input yaml file to extract from, default(github)') do |input|
32
+ opts.input = input
33
+ end
34
+
35
+ o.on('-v', '--verbose', 'Display verbose output') do
36
+ opts.verbose = true
37
+ end
38
+
39
+ o.on('-D', '--debug', 'Display debug output') do
40
+ opts.verbose = true
41
+ opts.debug = true
42
+ end
43
+
44
+ o.on_tail('-V', '--version', 'Print version') do
45
+ opts.action = :show_version
46
+ end
47
+
48
+ o.on_tail('-h', '--help', 'Print help') do
49
+ opts.action = :show_help
50
+ end
51
+ end
52
+
53
+ begin
54
+ parser.parse!(args)
55
+
56
+ raise OptionParser::MissingArgument.new('type') if opts.type.nil?
57
+ raise OptionParser::MissingArgument.new('output') if opts.output.nil?
58
+
59
+ if opts.input.nil?
60
+ opts.input = 'https://raw.github.com/emberjs/website/master/data/api.yml'
61
+ end
62
+
63
+ rescue OptionParser::InvalidOption => e
64
+ opts.error = e
65
+ opts.action = :show_invalid_option
66
+ rescue OptionParser::MissingArgument => e
67
+ opts.error = e
68
+ opts.action = :show_missing_args
69
+ rescue OptionParser::ParseError => e
70
+ opts.error = e
71
+ opts.action = :show_parser_error
72
+ end
73
+
74
+ opts
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,14 @@
1
+ module EmberExcerpt
2
+ module CLI
3
+
4
+ require_relative 'controller'
5
+
6
+ class Router
7
+ def route(action, options)
8
+ controller = Controller.new(options)
9
+ controller.send(action)
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ require "ember/excerpt/version"
2
+
3
+ module Ember
4
+ module Excerpt
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ module EmberExcerpt
2
+
3
+ module Loader
4
+ ROOT_DIR = File.expand_path('../../../', __FILE__)
5
+ LIB_DIR = File.join(ROOT_DIR, 'lib')
6
+
7
+ $:.unshift(LIB_DIR) unless $:.include? LIB_DIR
8
+ end
9
+
10
+ end
@@ -0,0 +1,3 @@
1
+ module EmberExcerpt
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ember-excerpt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Darshan Sawardekar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-15 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Extracts keywords from ember documentation.
42
+ email:
43
+ - darshan@sawardekar.org
44
+ executables:
45
+ - ember-excerpt
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/ember-excerpt
55
+ - ember-excerpt.gemspec
56
+ - lib/ember_excerpt/cli/app.rb
57
+ - lib/ember_excerpt/cli/controller.rb
58
+ - lib/ember_excerpt/cli/options.rb
59
+ - lib/ember_excerpt/cli/router.rb
60
+ - lib/ember_excerpt/ember_excerpt.rb
61
+ - lib/ember_excerpt/loader.rb
62
+ - lib/ember_excerpt/version.rb
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.0.5
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Extracts keywords like methods, classnames from ember documentation yml.
87
+ test_files: []