sydney 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +1 -2
  2. data/NEWS.md +6 -0
  3. data/README.md +21 -10
  4. data/doc/Gemfile.html +107 -0
  5. data/doc/LICENSE.html +125 -0
  6. data/doc/Rakefile.html +105 -0
  7. data/doc/Sydney.html +276 -0
  8. data/doc/SydneyAliasFile.html +141 -0
  9. data/doc/SydneyAliasFile/AliasComment.html +193 -0
  10. data/doc/SydneyAliasFile/AliasDefinition.html +259 -0
  11. data/doc/SydneyAliasFile/AliasEntry.html +257 -0
  12. data/doc/SydneyAliasFile/Document.html +193 -0
  13. data/doc/SydneyAliasFile/Section.html +225 -0
  14. data/doc/SydneyAliasFile/SectionComment.html +193 -0
  15. data/doc/SydneyAliasFile/SyntaxNode.html +193 -0
  16. data/doc/created.rid +15 -0
  17. data/doc/images/add.png +0 -0
  18. data/doc/images/brick.png +0 -0
  19. data/doc/images/brick_link.png +0 -0
  20. data/doc/images/bug.png +0 -0
  21. data/doc/images/bullet_black.png +0 -0
  22. data/doc/images/bullet_toggle_minus.png +0 -0
  23. data/doc/images/bullet_toggle_plus.png +0 -0
  24. data/doc/images/date.png +0 -0
  25. data/doc/images/delete.png +0 -0
  26. data/doc/images/find.png +0 -0
  27. data/doc/images/loadingAnimation.gif +0 -0
  28. data/doc/images/macFFBgHack.png +0 -0
  29. data/doc/images/package.png +0 -0
  30. data/doc/images/page_green.png +0 -0
  31. data/doc/images/page_white_text.png +0 -0
  32. data/doc/images/page_white_width.png +0 -0
  33. data/doc/images/plugin.png +0 -0
  34. data/doc/images/ruby.png +0 -0
  35. data/doc/images/tag_blue.png +0 -0
  36. data/doc/images/tag_green.png +0 -0
  37. data/doc/images/transparent.png +0 -0
  38. data/doc/images/wrench.png +0 -0
  39. data/doc/images/wrench_orange.png +0 -0
  40. data/doc/images/zoom.png +0 -0
  41. data/doc/index.html +100 -0
  42. data/doc/js/darkfish.js +153 -0
  43. data/doc/js/jquery.js +18 -0
  44. data/doc/js/navigation.js +142 -0
  45. data/doc/js/search.js +94 -0
  46. data/doc/js/search_index.js +1 -0
  47. data/doc/js/searcher.js +228 -0
  48. data/doc/rdoc.css +543 -0
  49. data/doc/spec/fixtures/aliases.html +123 -0
  50. data/doc/table_of_contents.html +116 -0
  51. data/lib/sydney.rb +23 -1
  52. data/lib/sydney/sydney_alias_file/node_extensions.rb +18 -0
  53. data/lib/sydney/version.rb +1 -1
  54. data/spec/sydney_alias_file/alias_definition_spec.rb +6 -0
  55. data/spec/sydney_alias_file/alias_entry_spec.rb +1 -0
  56. data/spec/sydney_spec.rb +23 -8
  57. metadata +49 -1
@@ -0,0 +1,123 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>aliases - RDoc Documentation</title>
8
+
9
+ <link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet">
10
+
11
+ <script type="text/javascript">
12
+ var rdoc_rel_prefix = "../../";
13
+ </script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
16
+ <script type="text/javascript" charset="utf-8" src="../../js/navigation.js"></script>
17
+ <script type="text/javascript" charset="utf-8" src="../../js/search_index.js"></script>
18
+ <script type="text/javascript" charset="utf-8" src="../../js/search.js"></script>
19
+ <script type="text/javascript" charset="utf-8" src="../../js/searcher.js"></script>
20
+ <script type="text/javascript" charset="utf-8" src="../../js/darkfish.js"></script>
21
+
22
+
23
+ <body class="file">
24
+ <nav id="metadata">
25
+ <nav id="home-section" class="section">
26
+ <h3 class="section-header">
27
+ <a href="../../index.html">Home</a>
28
+ <a href="../../table_of_contents.html#classes">Classes</a>
29
+ <a href="../../table_of_contents.html#methods">Methods</a>
30
+ </h3>
31
+ </nav>
32
+
33
+
34
+ <nav id="search-section" class="section project-section" class="initially-hidden">
35
+ <form action="#" method="get" accept-charset="utf-8">
36
+ <h3 class="section-header">
37
+ <input type="text" name="search" placeholder="Search" id="search-field"
38
+ title="Type to search, Up and Down to navigate, Enter to load">
39
+ </h3>
40
+ </form>
41
+
42
+ <ul id="search-results" class="initially-hidden"></ul>
43
+ </nav>
44
+
45
+
46
+ <div id="project-metadata">
47
+ <nav id="fileindex-section" class="section project-section">
48
+ <h3 class="section-header">Pages</h3>
49
+
50
+ <ul>
51
+
52
+ <li class="file"><a href="../../Gemfile.html">Gemfile</a>
53
+
54
+ <li class="file"><a href="../../LICENSE.html">LICENSE</a>
55
+
56
+ <li class="file"><a href="../../Rakefile.html">Rakefile</a>
57
+
58
+ <li class="file"><a href="../../spec/fixtures/aliases.html">aliases</a>
59
+
60
+ </ul>
61
+ </nav>
62
+
63
+ <nav id="classindex-section" class="section project-section">
64
+ <h3 class="section-header">Class and Module Index</h3>
65
+
66
+ <ul class="link-list">
67
+
68
+ <li><a href="../../SydneyAliasFile.html">SydneyAliasFile</a>
69
+
70
+ <li><a href="../../SydneyAliasFile/AliasComment.html">SydneyAliasFile::AliasComment</a>
71
+
72
+ <li><a href="../../SydneyAliasFile/AliasDefinition.html">SydneyAliasFile::AliasDefinition</a>
73
+
74
+ <li><a href="../../SydneyAliasFile/AliasEntry.html">SydneyAliasFile::AliasEntry</a>
75
+
76
+ <li><a href="../../SydneyAliasFile/Document.html">SydneyAliasFile::Document</a>
77
+
78
+ <li><a href="../../SydneyAliasFile/Section.html">SydneyAliasFile::Section</a>
79
+
80
+ <li><a href="../../SydneyAliasFile/SectionComment.html">SydneyAliasFile::SectionComment</a>
81
+
82
+ <li><a href="../../SydneyAliasFile/SyntaxNode.html">SydneyAliasFile::SyntaxNode</a>
83
+
84
+ <li><a href="../../Sydney.html">Sydney</a>
85
+
86
+ </ul>
87
+ </nav>
88
+
89
+ </div>
90
+ </nav>
91
+
92
+ <div id="documentation" class="description">
93
+
94
+ <p>alias noop=‘noop -all’ ## Unix ## Command Line Aliases # Continuously tail
95
+ file live. # This can be useful when tracking activity. alias tlf=“tail -f”
96
+ alias ln=‘ln -v’ alias mkdir=‘mkdir -p’ alias …=‘../..’ alias l=‘ls’ alias
97
+ ll=‘ls -al’ alias lh=‘ls -Alh’</p>
98
+
99
+ <p># Pipe to grep alias -g G=‘| grep’ # Pipe to less alias -g M=‘| less’ #
100
+ Line count alias -g L=‘| wc -l’ alias -g ONE=“| awk ‘{ print $1}’”</p>
101
+
102
+ <p>## Git alias g=“git” alias gci=“git pull –rebase &amp;&amp; rake &amp;&amp;
103
+ git push”</p>
104
+
105
+ <p>## Bundler alias b=“bundle”</p>
106
+
107
+ <p>## Tests and Specs alias t=“ruby -I test” alias cuc=“bundle exec cucumber”</p>
108
+
109
+ <p>## Rubygems alias gi=“gem install” alias giv=“gem install -v”</p>
110
+
111
+ <p>## Rails alias migrate=“rake db:migrate &amp;&amp; rake db:rollback
112
+ &amp;&amp; rake db:migrate &amp;&amp; rake db:test:prepare”</p>
113
+
114
+ </div>
115
+
116
+
117
+
118
+ <footer id="validator-badges">
119
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
120
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
121
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
122
+ </footer>
123
+
@@ -0,0 +1,116 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
+
7
+ <title>Table of Contents - RDoc Documentation</title>
8
+
9
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
10
+
11
+ <script type="text/javascript">
12
+ var rdoc_rel_prefix = "./";
13
+ </script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
16
+ <script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
17
+ <script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
18
+ <script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
19
+ <script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
20
+ <script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
21
+
22
+
23
+ <body class="indexpage">
24
+ <h1>Table of Contents - RDoc Documentation</h1>
25
+
26
+ <h2>Pages</h2>
27
+ <ul>
28
+ <li class="file">
29
+ <a href="Gemfile.html">Gemfile</a>
30
+ </li>
31
+ <li class="file">
32
+ <a href="LICENSE.html">LICENSE</a>
33
+ </li>
34
+ <li class="file">
35
+ <a href="Rakefile.html">Rakefile</a>
36
+ </li>
37
+ <li class="file">
38
+ <a href="spec/fixtures/aliases.html">aliases</a>
39
+ </li>
40
+
41
+ </ul>
42
+
43
+ <h2 id="classes">Classes/Modules</h2>
44
+ <ul>
45
+ <li class="module">
46
+ <a href="SydneyAliasFile.html">SydneyAliasFile</a>
47
+ </li>
48
+ <li class="class">
49
+ <a href="SydneyAliasFile/AliasComment.html">SydneyAliasFile::AliasComment</a>
50
+ </li>
51
+ <li class="class">
52
+ <a href="SydneyAliasFile/AliasDefinition.html">SydneyAliasFile::AliasDefinition</a>
53
+ </li>
54
+ <li class="class">
55
+ <a href="SydneyAliasFile/AliasEntry.html">SydneyAliasFile::AliasEntry</a>
56
+ </li>
57
+ <li class="class">
58
+ <a href="SydneyAliasFile/Document.html">SydneyAliasFile::Document</a>
59
+ </li>
60
+ <li class="class">
61
+ <a href="SydneyAliasFile/Section.html">SydneyAliasFile::Section</a>
62
+ </li>
63
+ <li class="class">
64
+ <a href="SydneyAliasFile/SectionComment.html">SydneyAliasFile::SectionComment</a>
65
+ </li>
66
+ <li class="class">
67
+ <a href="SydneyAliasFile/SyntaxNode.html">SydneyAliasFile::SyntaxNode</a>
68
+ </li>
69
+ <li class="module">
70
+ <a href="Sydney.html">Sydney</a>
71
+ </li>
72
+
73
+ </ul>
74
+
75
+ <h2 id="methods">Methods</h2>
76
+ <ul>
77
+
78
+ <li class="method"><a href="Sydney.html#method-c-aliases">::aliases &mdash; Sydney</a>
79
+
80
+ <li class="method"><a href="Sydney.html#method-c-parse">::parse &mdash; Sydney</a>
81
+
82
+ <li class="method"><a href="Sydney.html#method-c-sections">::sections &mdash; Sydney</a>
83
+
84
+ <li class="method"><a href="SydneyAliasFile/AliasEntry.html#method-i-alias">#alias &mdash; SydneyAliasFile::AliasEntry</a>
85
+
86
+ <li class="method"><a href="SydneyAliasFile/AliasDefinition.html#method-i-command">#command &mdash; SydneyAliasFile::AliasDefinition</a>
87
+
88
+ <li class="method"><a href="SydneyAliasFile/AliasEntry.html#method-i-comment">#comment &mdash; SydneyAliasFile::AliasEntry</a>
89
+
90
+ <li class="method"><a href="SydneyAliasFile/AliasEntry.html#method-i-comments">#comments &mdash; SydneyAliasFile::AliasEntry</a>
91
+
92
+ <li class="method"><a href="SydneyAliasFile/Section.html#method-i-entries">#entries &mdash; SydneyAliasFile::Section</a>
93
+
94
+ <li class="method"><a href="SydneyAliasFile/Document.html#method-i-sections">#sections &mdash; SydneyAliasFile::Document</a>
95
+
96
+ <li class="method"><a href="SydneyAliasFile/AliasDefinition.html#method-i-shortcut">#shortcut &mdash; SydneyAliasFile::AliasDefinition</a>
97
+
98
+ <li class="method"><a href="SydneyAliasFile/Section.html#method-i-title">#title &mdash; SydneyAliasFile::Section</a>
99
+
100
+ <li class="method"><a href="SydneyAliasFile/AliasDefinition.html#method-i-to_s">#to_s &mdash; SydneyAliasFile::AliasDefinition</a>
101
+
102
+ <li class="method"><a href="SydneyAliasFile/AliasComment.html#method-i-to_s">#to_s &mdash; SydneyAliasFile::AliasComment</a>
103
+
104
+ <li class="method"><a href="SydneyAliasFile/SectionComment.html#method-i-to_s">#to_s &mdash; SydneyAliasFile::SectionComment</a>
105
+
106
+ <li class="method"><a href="SydneyAliasFile/SyntaxNode.html#method-i-to_s">#to_s &mdash; SydneyAliasFile::SyntaxNode</a>
107
+
108
+ </ul>
109
+
110
+
111
+ <footer id="validator-badges">
112
+ <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
113
+ <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
114
+ <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
115
+ </footer>
116
+
@@ -14,6 +14,8 @@ module Sydney
14
14
  )
15
15
  @@parser = SydneyAliasFileParser.new
16
16
 
17
+ # Parse the supplied string and return a
18
+ # Treetop::Runtime::SyntaxNode tree
17
19
  def self.parse(data)
18
20
  # Pass the data over to the parser instance
19
21
  tree = @@parser.parse(data)
@@ -24,7 +26,27 @@ module Sydney
24
26
  raise Exception, "Parse error at offset: #{@@parser.index}"
25
27
  end
26
28
 
27
- return tree
29
+ self.clean_tree(tree)
30
+
31
+ tree
32
+ end
33
+
34
+ # Parse the string and return an array of AliasEntry nodes
35
+ def self.aliases(data)
36
+ sections(data).map(&:entries).flatten.map(&:alias).flatten
37
+ end
38
+
39
+ # Parse the string and return an array of Section nodes
40
+ def self.sections(data)
41
+ parse(data).sections
42
+ end
43
+
44
+ private
45
+
46
+ def self.clean_tree(root_node)
47
+ return if(root_node.elements.nil?)
48
+ root_node.elements.delete_if{|node| node.class.name == "Treetop::Runtime::SyntaxNode" }
49
+ root_node.elements.each {|node| self.clean_tree(node) }
28
50
  end
29
51
 
30
52
  end
@@ -6,56 +6,74 @@
6
6
  end
7
7
 
8
8
  class Document < SyntaxNode
9
+ # Return an array of Section nodes
9
10
  def sections
10
11
  to_a
11
12
  end
12
13
 
14
+ private
15
+
13
16
  def to_a
14
17
  elements.map{ |element| element }
15
18
  end
16
19
  end
17
20
 
18
21
  class Section < SyntaxNode
22
+ # Return all the '##'-led lines in the section as a single string
19
23
  def title
20
24
  section_title.elements.map(&:to_s).join(' ')
21
25
  end
22
26
 
27
+ # Return the AliasEntry nodes as an array
23
28
  def entries
24
29
  content.elements
25
30
  end
26
31
  end
27
32
 
28
33
  class SectionComment < SyntaxNode
34
+ # Return the comment without surrounding whitespace
29
35
  def to_s
30
36
  content.text_value.strip
31
37
  end
32
38
  end
33
39
 
34
40
  class AliasEntry < SyntaxNode
41
+ # Return the AliasComment nodes as an array
35
42
  def comments
36
43
  entry_comments.elements
37
44
  end
38
45
 
46
+ # Return the comments as a string
39
47
  def comment
40
48
  comments.map(&:to_s).join(' ')
41
49
  end
42
50
 
51
+ # Return the child AliasDefinition node
43
52
  def alias
44
53
  definition
45
54
  end
46
55
  end
47
56
 
48
57
  class AliasComment < SyntaxNode
58
+ # Return the comment without the preceding # and surrounding whitespace
49
59
  def to_s
50
60
  comment_text.text_value.strip
51
61
  end
52
62
  end
53
63
 
54
64
  class AliasDefinition < SyntaxNode
65
+ # Return the alias definition without the preceding 'alias' and
66
+ # surrounding whitespace
67
+ def to_s
68
+ "#{shortcut} = #{command}"
69
+ end
70
+
71
+ # Return the command line shortcut (alias)
55
72
  def shortcut
56
73
  prefix.text_value.strip
57
74
  end
58
75
 
76
+ # Return the command to be executed in place of the alias
59
77
  def command
60
78
  stripped_command = aliased_command.to_s.strip
61
79
  stripped_command[1,stripped_command.length - 2]
@@ -1,3 +1,3 @@
1
1
  module Sydney
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -16,4 +16,10 @@ describe SydneyAliasFile::AliasDefinition do
16
16
  @alias_definition.command.should eq('tail -f')
17
17
  end
18
18
  end
19
+
20
+ describe "#to_s" do
21
+ it "returns the shortcut and command separated by an equal sign surrounded by single spaces" do
22
+ @alias_definition.to_s.should eq('tlf = tail -f')
23
+ end
24
+ end
19
25
  end
@@ -7,6 +7,7 @@ describe SydneyAliasFile::AliasEntry do
7
7
 
8
8
  describe '#comments' do
9
9
  it "returns an array of all the AliasComment nodes" do
10
+ @alias_entry.comments.class.should eq(Array)
10
11
  @alias_entry.comments.count.should eq(2)
11
12
  @alias_entry.comments.first.class.should eq(SydneyAliasFile::AliasComment)
12
13
  end
@@ -2,18 +2,33 @@ require 'spec_helper'
2
2
 
3
3
  describe Sydney do
4
4
 
5
- context "with a valid alias file" do
6
- it "parses the alias file" do
7
- @parser_result.should be_true
5
+ describe ".parse" do
6
+ context "with a valid alias file" do
7
+ it "parses the alias file" do
8
+ @parser_result.should be_true
9
+ end
10
+ end
11
+
12
+ context "with an invalid alias file" do
13
+ it "raises an exception and reports the offset where the problem occurred" do
14
+ expect {
15
+ Sydney.parse("blah blah")
16
+ }.to raise_error
17
+ end
8
18
  end
9
19
  end
10
20
 
11
- context "with an invalid alias file" do
12
- it "raises an exception and reports the offset where the problem occurred" do
13
- expect {
14
- Sydney.parse("blah blah")
15
- }.to raise_error
21
+ describe ".sections" do
22
+ it "returns an array of sections from the file" do
23
+ Sydney.sections(@alias_file).class.should eq(Array)
24
+ Sydney.sections(@alias_file).count.should eq(7)
16
25
  end
17
26
  end
18
27
 
28
+ describe ".aliases" do
29
+ it "returns an array of the aliases in the file" do
30
+ Sydney.aliases(@alias_file).class.should eq(Array)
31
+ Sydney.aliases(@alias_file).count.should eq(20)
32
+ end
33
+ end
19
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sydney
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -53,8 +53,56 @@ files:
53
53
  - .gitignore
54
54
  - Gemfile
55
55
  - LICENSE
56
+ - NEWS.md
56
57
  - README.md
57
58
  - Rakefile
59
+ - doc/Gemfile.html
60
+ - doc/LICENSE.html
61
+ - doc/Rakefile.html
62
+ - doc/Sydney.html
63
+ - doc/SydneyAliasFile.html
64
+ - doc/SydneyAliasFile/AliasComment.html
65
+ - doc/SydneyAliasFile/AliasDefinition.html
66
+ - doc/SydneyAliasFile/AliasEntry.html
67
+ - doc/SydneyAliasFile/Document.html
68
+ - doc/SydneyAliasFile/Section.html
69
+ - doc/SydneyAliasFile/SectionComment.html
70
+ - doc/SydneyAliasFile/SyntaxNode.html
71
+ - doc/created.rid
72
+ - doc/images/add.png
73
+ - doc/images/brick.png
74
+ - doc/images/brick_link.png
75
+ - doc/images/bug.png
76
+ - doc/images/bullet_black.png
77
+ - doc/images/bullet_toggle_minus.png
78
+ - doc/images/bullet_toggle_plus.png
79
+ - doc/images/date.png
80
+ - doc/images/delete.png
81
+ - doc/images/find.png
82
+ - doc/images/loadingAnimation.gif
83
+ - doc/images/macFFBgHack.png
84
+ - doc/images/package.png
85
+ - doc/images/page_green.png
86
+ - doc/images/page_white_text.png
87
+ - doc/images/page_white_width.png
88
+ - doc/images/plugin.png
89
+ - doc/images/ruby.png
90
+ - doc/images/tag_blue.png
91
+ - doc/images/tag_green.png
92
+ - doc/images/transparent.png
93
+ - doc/images/wrench.png
94
+ - doc/images/wrench_orange.png
95
+ - doc/images/zoom.png
96
+ - doc/index.html
97
+ - doc/js/darkfish.js
98
+ - doc/js/jquery.js
99
+ - doc/js/navigation.js
100
+ - doc/js/search.js
101
+ - doc/js/search_index.js
102
+ - doc/js/searcher.js
103
+ - doc/rdoc.css
104
+ - doc/spec/fixtures/aliases.html
105
+ - doc/table_of_contents.html
58
106
  - lib/sydney.rb
59
107
  - lib/sydney/sydney_alias_file/grammar_rules.treetop
60
108
  - lib/sydney/sydney_alias_file/node_extensions.rb