computering 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9b6c82f164452c69e747b1bbeec59dbc12a28a5
4
- data.tar.gz: f590c24a272d05f5a71a35e4f68bfb92f7b0b831
3
+ metadata.gz: 9efa6d55cd4edf4da0ff1bf5c1ab415973b9cdc0
4
+ data.tar.gz: 3f125e492b6ca53f7e011a044488ff4a0d2d00da
5
5
  SHA512:
6
- metadata.gz: 288e4f9489d1a4228c9f8e87d168f1ef9ea8a650844a92e59c276706c21aeea46640627f78b09932be64a6cbf6e64720daa32cd17f9c2f664c48e406e109bc2b
7
- data.tar.gz: 4e0f3415af3df94aa53740b2d7886a575dfdfd556c99b690261a4dd8a3a7adca2883ac7781123844cedeb0b79cf8cd5c59c9e4e97ab9db0a6392de0068f45674
6
+ metadata.gz: 296528c1d1c84523f13a57366e38143a856db47ef4334bb2a900f3d3c7c7649ad268adc0897de24a7e36e285bd97fe2da8034e6196b0bf8bd1d5fc319d68c536
7
+ data.tar.gz: cb578a23be60309645c8dcf33e7b9438b90d4c07a978cc17af8bbcbabd00215e113b97d1dc1ba8c4140b8654a2c695519dd3d6cdbc1aa8b709e70966054556fa
data/README.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  ![Computering](https://peepcode.com/blog/2013/charismatic-duo/img/dinosaur-hands.gif)
4
4
 
5
+ # Usage
6
+
7
+ Installing the gem:
8
+
9
+ ```
10
+ gem install computering
11
+ ```
12
+
13
+ or via Bundler
14
+
15
+ ```ruby
16
+ #Gemfile
17
+ gem "computering"
18
+ ```
19
+
20
+ create a presentation file
21
+
22
+ ```
23
+ echo "
24
+ headline 'computering'
25
+ paragraph 'is super easy'
26
+ command 'echo to use'
27
+ link 'see yourself', 'https://github.com/phoet/computering'
28
+ " > preso.rb
29
+ ```
30
+
31
+ and run it with the `computering` command:
32
+
33
+ ```
34
+ computering preso.rb
35
+ ```
36
+
37
+ # TODO
38
+
39
+ * syntax-check
40
+ * dry-mode
41
+ * config speed
42
+ * add styling
43
+
5
44
  # License
6
45
 
7
46
  "THE (extended) BEER-WARE LICENSE" (Revision 42.0815): [phoet](mailto:ps@nofail.de) contributed to this project.
@@ -4,5 +4,14 @@ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
4
4
 
5
5
  require "Computering"
6
6
 
7
- cmd = Computering::Cmd.new ARGV[0]
8
- cmd.execute rescue Computering::Cmd::Exit
7
+ abort "USAGE: computering file [file ...]" if ARGV.empty?
8
+
9
+ begin
10
+ puts "", "Start typing or exit with Ctrl+C", ""
11
+ ARGV.each do |cmd|
12
+ cmd = Computering::Cmd.new ARGV[0]
13
+ cmd.execute
14
+ end
15
+ rescue Computering::Cmd::Exit
16
+ puts "", "KTHXBYE!"
17
+ end
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Computering::VERSION
9
9
  spec.authors = ["Peter Schröder"]
10
10
  spec.email = ["phoetmail@googlemail.com"]
11
+ spec.license = %q{THE (extended) BEER-WARE LICENSE}
11
12
  spec.summary = spec.description = %q{pretends you could type really fast}
12
13
  spec.homepage = "https://github.com/phoet/computering"
13
14
 
@@ -16,6 +17,8 @@ Gem::Specification.new do |spec|
16
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
18
  spec.require_paths = ["lib"]
18
19
 
20
+ spec.add_dependency "rainbow", "> 1.0"
21
+
19
22
  spec.add_development_dependency "bundler", "~> 1.3"
20
23
  spec.add_development_dependency "rspec"
21
24
  spec.add_development_dependency "rake"
@@ -0,0 +1,7 @@
1
+ headline 'computering'
2
+
3
+ paragraph 'is super easy'
4
+
5
+ command 'echo to use'
6
+
7
+ link 'see yourself', 'https://github.com/phoet/computering'
@@ -1,5 +1,9 @@
1
+ require "rainbow"
2
+
1
3
  require "computering/version"
2
4
  require "computering/dsl"
3
5
  require "computering/dsl/text"
4
6
  require "computering/dsl/command"
7
+ require "computering/dsl/headline"
8
+ require "computering/dsl/link"
5
9
  require "computering/cmd"
@@ -21,7 +21,7 @@ module Computering
21
21
  def execute
22
22
  items.each do |item|
23
23
  if item.blank?
24
- @stdout.puts ""
24
+ @stdout.puts
25
25
  else
26
26
  readchars item
27
27
  end
@@ -35,6 +35,7 @@ module Computering
35
35
  raise Exit if char.ord == CONTROL_C
36
36
  if char.ord == ENTER
37
37
  @stdout.puts item[i..-1]
38
+ item.execute
38
39
  @stdout.puts item.buffer
39
40
  break
40
41
  else
@@ -1,11 +1,19 @@
1
1
  module Computering
2
2
  module Dsl
3
+ def headline(text)
4
+ self.items += Headline.from_text(text)
5
+ end
6
+
3
7
  def paragraph(text)
4
8
  self.items += Text.from_text(text)
5
9
  end
6
10
 
7
11
  def command(text)
8
- self.items << Command.from_text(text)
12
+ self.items += Command.from_text(text)
13
+ end
14
+
15
+ def link(text, link)
16
+ self.items += Link.from_text(text, link)
9
17
  end
10
18
 
11
19
  protected
@@ -1,8 +1,25 @@
1
+ require "bundler"
2
+
1
3
  module Computering::Dsl
2
4
  class Command < Text
3
- def self.from_text(text)
4
- buffer = `#{text}`
5
- self.new "> #{text}", "\n#{buffer}\n"
5
+ def initialize(cmd)
6
+ @text = " #{'⌘'.color(:green)} #{cmd.color(:black).background(:cyan)}"
7
+ @buffer = ""
8
+ @cmd = cmd
9
+ end
10
+
11
+ def execute
12
+ output = ""
13
+ Bundler.with_clean_env do
14
+ output = `#{@cmd}`
15
+ end
16
+ @buffer = "\n#{output}\n"
17
+ rescue
18
+ puts $!
19
+ end
20
+
21
+ def self.from_text(cmd)
22
+ Array(self.new cmd)
6
23
  end
7
24
  end
8
25
  end
@@ -0,0 +1,8 @@
1
+ module Computering::Dsl
2
+ class Headline < Text
3
+ def initialize(text)
4
+ @text = text.background(:red)
5
+ @buffer = "#{'=' * text.size}\n\n".foreground(:red)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ module Computering::Dsl
2
+ class Link < Text
3
+ def initialize(text, link)
4
+ @text = " #{'☞'.color(:green)} #{text}"
5
+ @link = link
6
+ @buffer = ''
7
+ end
8
+
9
+ def execute
10
+ `open '#{@link}'`
11
+ rescue
12
+ puts $!
13
+ end
14
+
15
+ def self.from_text(text, link)
16
+ Array(self.new text, link)
17
+ end
18
+ end
19
+ end
@@ -1,12 +1,15 @@
1
1
  module Computering::Dsl
2
2
  class Text
3
- def initialize(line, buffer = "")
4
- @line = line
5
- @buffer = buffer
3
+ def initialize(text)
4
+ @text = text
5
+ @buffer = ""
6
6
  end
7
7
 
8
8
  def [](index)
9
- @line[index]
9
+ @text[index]
10
+ end
11
+
12
+ def execute
10
13
  end
11
14
 
12
15
  def buffer
@@ -14,7 +17,7 @@ module Computering::Dsl
14
17
  end
15
18
 
16
19
  def blank?
17
- @line.nil? || @line.strip == ""
20
+ @text.nil? || @text.strip == ""
18
21
  end
19
22
 
20
23
  def self.from_text(text)
@@ -1,3 +1,3 @@
1
1
  module Computering
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: computering
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Schröder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-09 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rainbow
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>'
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>'
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -63,22 +77,24 @@ files:
63
77
  - .gitignore
64
78
  - .rspec
65
79
  - Gemfile
66
- - LICENSE.txt
67
80
  - README.md
68
81
  - Rakefile
69
82
  - bin/computering
70
83
  - computering.gemspec
71
- - example/preso_1.rb
84
+ - example/preso.rb
72
85
  - lib/computering.rb
73
86
  - lib/computering/cmd.rb
74
87
  - lib/computering/dsl.rb
75
88
  - lib/computering/dsl/command.rb
89
+ - lib/computering/dsl/headline.rb
90
+ - lib/computering/dsl/link.rb
76
91
  - lib/computering/dsl/text.rb
77
92
  - lib/computering/version.rb
78
93
  - spec/computering/dsl/text_spec.rb
79
94
  - spec/spec_helper.rb
80
95
  homepage: https://github.com/phoet/computering
81
- licenses: []
96
+ licenses:
97
+ - THE (extended) BEER-WARE LICENSE
82
98
  metadata: {}
83
99
  post_install_message:
84
100
  rdoc_options: []
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 Peter Schröder
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.
@@ -1,10 +0,0 @@
1
- paragraph <<-PARAGRAPH
2
- Hallo leute,
3
- wie geht es euch?
4
- PARAGRAPH
5
-
6
- command "ls -la"
7
-
8
- paragraph <<-PARAGRAPH
9
- geht so
10
- PARAGRAPH