computering 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: f9b6c82f164452c69e747b1bbeec59dbc12a28a5
4
+ data.tar.gz: f590c24a272d05f5a71a35e4f68bfb92f7b0b831
5
+ SHA512:
6
+ metadata.gz: 288e4f9489d1a4228c9f8e87d168f1ef9ea8a650844a92e59c276706c21aeea46640627f78b09932be64a6cbf6e64720daa32cd17f9c2f664c48e406e109bc2b
7
+ data.tar.gz: 4e0f3415af3df94aa53740b2d7886a575dfdfd556c99b690261a4dd8a3a7adca2883ac7781123844cedeb0b79cf8cd5c59c9e4e97ab9db0a6392de0068f45674
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in Computering.gemspec
4
+ gemspec
5
+
6
+ gem "pry"
@@ -0,0 +1,22 @@
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.
@@ -0,0 +1,10 @@
1
+ # Computering
2
+
3
+ ![Computering](https://peepcode.com/blog/2013/charismatic-duo/img/dinosaur-hands.gif)
4
+
5
+ # License
6
+
7
+ "THE (extended) BEER-WARE LICENSE" (Revision 42.0815): [phoet](mailto:ps@nofail.de) contributed to this project.
8
+
9
+ As long as you retain this notice you can do whatever you want with this stuff.
10
+ If we meet some day, and you think this stuff is worth it, you can buy me some beers in return.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ #! /usr/bin/env ruby
2
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
3
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
4
+
5
+ require "Computering"
6
+
7
+ cmd = Computering::Cmd.new ARGV[0]
8
+ cmd.execute rescue Computering::Cmd::Exit
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'computering/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "computering"
8
+ spec.version = Computering::VERSION
9
+ spec.authors = ["Peter Schröder"]
10
+ spec.email = ["phoetmail@googlemail.com"]
11
+ spec.summary = spec.description = %q{pretends you could type really fast}
12
+ spec.homepage = "https://github.com/phoet/computering"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rspec"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,5 @@
1
+ require "computering/version"
2
+ require "computering/dsl"
3
+ require "computering/dsl/text"
4
+ require "computering/dsl/command"
5
+ require "computering/cmd"
@@ -0,0 +1,48 @@
1
+ require "io/console"
2
+
3
+ module Computering
4
+ class Cmd
5
+ class Exit < StandardError; end
6
+
7
+ include Computering::Dsl
8
+
9
+ CONTROL_C = 3
10
+ ENTER = 13
11
+
12
+ def initialize(file, stdin = STDIN, stdout = STDOUT)
13
+ @file = file
14
+ @stdin = stdin
15
+ @stdout = stdout
16
+ @code = File.readlines(file).join "\n"
17
+
18
+ instance_eval @code
19
+ end
20
+
21
+ def execute
22
+ items.each do |item|
23
+ if item.blank?
24
+ @stdout.puts ""
25
+ else
26
+ readchars item
27
+ end
28
+ end
29
+ end
30
+
31
+ def readchars(item)
32
+ i = 0
33
+ @stdin.noecho do |io|
34
+ while char = io.getch
35
+ raise Exit if char.ord == CONTROL_C
36
+ if char.ord == ENTER
37
+ @stdout.puts item[i..-1]
38
+ @stdout.puts item.buffer
39
+ break
40
+ else
41
+ @stdout.putc item[i] if item[i]
42
+ i += 1
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,21 @@
1
+ module Computering
2
+ module Dsl
3
+ def paragraph(text)
4
+ self.items += Text.from_text(text)
5
+ end
6
+
7
+ def command(text)
8
+ self.items << Command.from_text(text)
9
+ end
10
+
11
+ protected
12
+
13
+ def items
14
+ @items ||= []
15
+ end
16
+
17
+ def items=(items)
18
+ @items = items
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ module Computering::Dsl
2
+ class Command < Text
3
+ def self.from_text(text)
4
+ buffer = `#{text}`
5
+ self.new "> #{text}", "\n#{buffer}\n"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ module Computering::Dsl
2
+ class Text
3
+ def initialize(line, buffer = "")
4
+ @line = line
5
+ @buffer = buffer
6
+ end
7
+
8
+ def [](index)
9
+ @line[index]
10
+ end
11
+
12
+ def buffer
13
+ @buffer
14
+ end
15
+
16
+ def blank?
17
+ @line.nil? || @line.strip == ""
18
+ end
19
+
20
+ def self.from_text(text)
21
+ text.strip.split("\n").map { |line| self.new(line) }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module Computering
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ module Computering::Dsl
4
+ describe Text do
5
+ context "initialization" do
6
+ it "inits from a paragraph" do
7
+ items = Text.from_text(TEXT)
8
+ items.should have(3).items
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ require "computering"
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+ end
8
+
9
+ TEXT = <<-PARAGRAPH
10
+ Hallo leute,
11
+
12
+ wie geht es euch?
13
+ PARAGRAPH
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: computering
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Peter Schröder
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-09 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: rspec
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
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: pretends you could type really fast
56
+ email:
57
+ - phoetmail@googlemail.com
58
+ executables:
59
+ - computering
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .rspec
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/computering
70
+ - computering.gemspec
71
+ - example/preso_1.rb
72
+ - lib/computering.rb
73
+ - lib/computering/cmd.rb
74
+ - lib/computering/dsl.rb
75
+ - lib/computering/dsl/command.rb
76
+ - lib/computering/dsl/text.rb
77
+ - lib/computering/version.rb
78
+ - spec/computering/dsl/text_spec.rb
79
+ - spec/spec_helper.rb
80
+ homepage: https://github.com/phoet/computering
81
+ licenses: []
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.0.0
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: pretends you could type really fast
103
+ test_files:
104
+ - spec/computering/dsl/text_spec.rb
105
+ - spec/spec_helper.rb
106
+ has_rdoc: