computering 0.1.1 → 0.2.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: 7c68086d104fb3bed1f55ac98d5125ae49425a39
4
- data.tar.gz: 7c5863b2754e9976309ff05a49dd3700766e0947
3
+ metadata.gz: d13edc9482c52c1b00141f73e6ace9b3110de791
4
+ data.tar.gz: cc408c711fdeafb68511ce4d81ae9d608439f5d7
5
5
  SHA512:
6
- metadata.gz: ebbdd7570a201575f677b467a6dbb0b9279721d1158e4464857dd084a7ee1db6b5f306d14135dee99ba872476bb79ffa066cb967c8b289f50bfc4fae4ab552ff
7
- data.tar.gz: 43d10ef29b3bc8f2a7ccc3d4b5f9b6bae2f3d82a550c39896440f6c74c3d8048e134306df0f87c91b28c1f973ab9d23661e392dd6a2ccd63ed50ac9dd2bd2eeb
6
+ metadata.gz: 4b56fde80f029c0ebf9947c9289076c62e8f0c90da539ab9e26c1b47ae7480ea42e547705cdb806dcb53902e2746c03cb43f8176b7bd92e6b3ee65f9bfc08ed2
7
+ data.tar.gz: 951a7b2a5d3db91b742babb63148a43f60cbb3c13c1f137a2149c919599c2628622413cb647ed17389249426f4272400f3d48ece8cd085370177a03798492011
@@ -1,3 +1,4 @@
1
1
  script: "bundle exec rake"
2
2
  rvm:
3
- - 2.0.0-p247
3
+ - 2.0.0
4
+ - 2.1.0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Computering
2
2
 
3
- ![Computering](https://peepcode.com/blog/2013/charismatic-duo/img/dinosaur-hands.gif)
3
+ ![Computering](http://blog.pluralsight.com/wp-content/uploads/peepcode/2013/charismatic-duo/img/dinosaur-hands.gif)
4
4
 
5
5
  # Usage
6
6
 
@@ -17,10 +17,11 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "rainbow", "> 1.0"
21
- spec.add_dependency "sorcerer"
22
- spec.add_dependency "minitest"
20
+ spec.add_dependency "rainbow", "~> 2.0"
21
+ spec.add_dependency "sorcerer", "~> 1.0"
22
+ spec.add_dependency "minitest", "~> 5.2"
23
+ spec.add_dependency "rouge", "~> 1.3"
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 1.3"
25
- spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rake", "~> 10.1"
26
27
  end
@@ -0,0 +1,72 @@
1
+ headline 'Rails Middlewares for Fun (and Profit?)'
2
+ link 'Señor Developer Bacon', 'http://bit.ly/1maTrIt'
3
+
4
+ paragraph 'what can we do with a middleware?'
5
+
6
+ list [
7
+ "implement cross-cutting concerns (authorization, caching)",
8
+ "enrich request information (session-cookies)",
9
+ "modify the response (inject javascript)",
10
+ ]
11
+
12
+ link 'rails is rack based', 'http://rack.github.io/'
13
+
14
+ code(%Q[
15
+ class HelloWorld
16
+ def call(env)
17
+ [200, {"Content-Type" => "text/plain"}, ["Hello world!"]]
18
+ end
19
+ end
20
+
21
+ # even simpler
22
+ proc {|env| [200, {"Content-Type" => "text/plain"}, ["Hello world!"]] }
23
+ ])
24
+
25
+ headline 'Website Example'
26
+
27
+ command 'cd ~/o/ && git co 2c9846ce'
28
+ link 'veggie.onruby', 'http://hamburg.onruby.dev:5000/'
29
+
30
+ paragraph "let's write some code"
31
+
32
+ code(%Q[
33
+ # app/middlewares/bacon_infused.rb
34
+ class BaconInfused
35
+ def initialize(app)
36
+ @app = app
37
+ end
38
+
39
+ def call(env)
40
+ s, h, r = @app.call(env)
41
+ if r.content_type == 'text/html'
42
+ r.body = r.body.
43
+ gsub(/ruby|rails/i, 'BACON').
44
+ gsub(/src=('|")([^'|"]+).(png|jpg|jpeg|gif).*('|")/,
45
+ 'src="http://bit.ly/1maTrIt"')
46
+ end
47
+ [s, h, r]
48
+ end
49
+ end
50
+
51
+ # config/application.rb
52
+ config.middleware.use "BaconInfused"
53
+ ])
54
+
55
+ command 'cd ~/o/ && git co ba41abd30'
56
+ command 'cd ~/o/ && bundle exec rake middleware'
57
+ link 'bacon.onruby', 'http://hamburg.onruby.dev:5000/'
58
+
59
+ headline "Downsides"
60
+ list [
61
+ "out of sight",
62
+ "fragile",
63
+ "no live code reloading",
64
+ ]
65
+
66
+ link "WHY U NO CMD+R?", 'http://stackoverflow.com/questions/20874222/reloading-rails-middleware-without-restarting-the-server-in-development/21323432'
67
+
68
+ link 'zazicki', 'http://bit.ly/Mqmwzz'
69
+
70
+ link 'github.com/phoet/zazicki', 'http://github.com/phoet/zazicki'
71
+
72
+ command 'cowsay KTHXBYE'
@@ -9,6 +9,7 @@ require "computering/dsl/list"
9
9
  require "computering/dsl/link"
10
10
  require "computering/dsl/command"
11
11
  require "computering/dsl/spec"
12
+ require "computering/dsl/code"
12
13
  require "computering/code_parser"
13
14
  require "computering/container"
14
15
  require "computering/cmd"
@@ -23,16 +23,23 @@ module Computering
23
23
  def readchars(item)
24
24
  i = 0
25
25
  @stdin.noecho do |io|
26
+ @stdout.write item.padding if item.padding
26
27
  while char = io.getch
27
28
  raise Exit if char.ord == CONTROL_C
28
29
  if char.ord == ENTER
29
30
  @stdout.puts item[i..-1]
30
31
  item.execute
31
- @stdout.puts item.buffer if item.buffer
32
- @stdout.puts item.padding if item.padding
32
+ @stdout.puts "#{item.padding}#{item.buffer}" if item.buffer
33
+ @stdout.puts
33
34
  break
34
35
  else
35
- @stdout.write item[i] if item[i]
36
+ if item[i]
37
+ while item[i] =~ /\s/
38
+ @stdout.write item[i]
39
+ i += 1
40
+ end
41
+ @stdout.write item[i]
42
+ end
36
43
  i += 1
37
44
  end
38
45
  end
@@ -7,27 +7,27 @@ module Computering
7
7
  },
8
8
  list: {
9
9
  text: "-",
10
- bullet: "-".color(:green),
10
+ bullet: Rainbow("-").color(:green),
11
11
  },
12
12
  headline: {
13
- text: "-".background(:red),
14
- buffer: "-".background(:red),
13
+ text: Rainbow("-").background(:red),
14
+ buffer: Rainbow("-").background(:red),
15
15
  },
16
16
  link: {
17
- text: "-".color(:black).background(:cyan),
18
- cursor: "-".color(:green),
19
- error: "-".background(:red),
17
+ text: Rainbow("-").color(:black).background(:cyan),
18
+ cursor: Rainbow("-").color(:green),
19
+ error: Rainbow("-").background(:red),
20
20
  },
21
21
  command: {
22
- text: "-".color(:black).background(:cyan),
23
- cursor: "-".color(:green),
24
- buffer: "-".bright,
25
- error: "-".color(:red),
22
+ text: Rainbow("-").color(:black).background(:cyan),
23
+ cursor: Rainbow("-").color(:green),
24
+ buffer: Rainbow("-").bright,
25
+ error: Rainbow("-").color(:red),
26
26
  },
27
27
  spec: {
28
- text: "-".foreground(:green),
29
- buffer: "-".bright,
30
- error: "-".color(:red),
28
+ text: Rainbow("-").foreground(:green),
29
+ buffer: Rainbow("-").bright,
30
+ error: Rainbow("-").color(:red),
31
31
  },
32
32
  }
33
33
  @style = @style_defaults.dup
@@ -1,13 +1,13 @@
1
1
  module Computering
2
2
  module Dsl
3
- def spec(name, &block)
4
- self.items += Spec.from_block(name, block_source(name), &block)
5
- end
6
-
7
3
  def configure(&block)
8
4
  Config.instance_eval(&block)
9
5
  end
10
6
 
7
+ def spec(name, &block)
8
+ self.items += Spec.from_block(name, block_source(name), &block)
9
+ end
10
+
11
11
  def list(*text)
12
12
  self.items += List.from_text(text)
13
13
  end
@@ -20,6 +20,10 @@ module Computering
20
20
  self.items += Text.from_text(text)
21
21
  end
22
22
 
23
+ def code(*text)
24
+ self.items += Code.from_text(text)
25
+ end
26
+
23
27
  def command(*text)
24
28
  self.items += Command.from_text(text)
25
29
  end
@@ -0,0 +1,19 @@
1
+ require 'rouge'
2
+
3
+ module Computering::Dsl
4
+ class Code < Text
5
+ def self.from_text(*text)
6
+ text.flatten.map { |line| self.new(line) }
7
+ end
8
+
9
+ def padding
10
+ nil
11
+ end
12
+
13
+ protected
14
+
15
+ def text_with_style(text, index)
16
+ Rouge.highlight(text, 'ruby', 'terminal256')
17
+ end
18
+ end
19
+ end
@@ -3,5 +3,9 @@ module Computering::Dsl
3
3
  def buffer
4
4
  add_style('=' * @text.size, :buffer)
5
5
  end
6
+
7
+ def margin
8
+ " "
9
+ end
6
10
  end
7
11
  end
@@ -20,12 +20,12 @@ module Computering::Dsl
20
20
  def execute
21
21
  end
22
22
 
23
- def buffer
24
- add_style(@buffer, :buffer) if @buffer
23
+ def padding
24
+ " "
25
25
  end
26
26
 
27
- def padding
28
- "\n"
27
+ def buffer
28
+ add_style(@buffer, :buffer) if @buffer
29
29
  end
30
30
 
31
31
  def blank?
@@ -1,3 +1,3 @@
1
1
  module Computering
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -13,12 +13,12 @@ module Computering
13
13
 
14
14
  it "applies styles to text" do
15
15
  assert_equal "-", Config.style_defaults(:text, :text)
16
- assert_equal "-".color(:green), Config.style_defaults(:command, :cursor)
16
+ assert_equal Rainbow("-").color(:green), Config.style_defaults(:command, :cursor)
17
17
  end
18
18
 
19
19
  it "can override styles" do
20
- Config.style = {command: {cursor: "-".color(:blue)}}
21
- assert_equal "-".color(:blue), Config.style_defaults(:command, :cursor)
20
+ Config.style = {command: {cursor: Rainbow("-").color(:blue)}}
21
+ assert_equal Rainbow("-").color(:blue), Config.style_defaults(:command, :cursor)
22
22
  end
23
23
  end
24
24
  end
@@ -22,7 +22,7 @@ module Computering::Dsl
22
22
 
23
23
  it "has defaults" do
24
24
  assert_equal true, @item.blank?
25
- assert_equal "\n", @item.padding
25
+ assert_equal " ", @item.padding
26
26
  assert_equal nil, @item.buffer
27
27
  assert_equal nil, @item.execute
28
28
  end
metadata CHANGED
@@ -1,85 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: computering
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.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-10-07 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>'
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>'
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sorcerer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '5.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rouge
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
53
60
  - !ruby/object:Gem::Version
54
- version: '0'
61
+ version: '1.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ~>
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
75
  version: '1.3'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ~>
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '1.3'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '>='
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '0'
89
+ version: '10.1'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '>='
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '0'
96
+ version: '10.1'
83
97
  description: pretends you could type really fast
84
98
  email:
85
99
  - phoetmail@googlemail.com
@@ -88,13 +102,14 @@ executables:
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
91
- - .gitignore
92
- - .travis.yml
105
+ - ".gitignore"
106
+ - ".travis.yml"
93
107
  - Gemfile
94
108
  - README.md
95
109
  - Rakefile
96
110
  - bin/computering
97
111
  - computering.gemspec
112
+ - example/middleware.rb
98
113
  - example/preso.rb
99
114
  - example/socoded.rb
100
115
  - lib/computering.rb
@@ -103,6 +118,7 @@ files:
103
118
  - lib/computering/config.rb
104
119
  - lib/computering/container.rb
105
120
  - lib/computering/dsl.rb
121
+ - lib/computering/dsl/code.rb
106
122
  - lib/computering/dsl/command.rb
107
123
  - lib/computering/dsl/headline.rb
108
124
  - lib/computering/dsl/link.rb
@@ -123,17 +139,17 @@ require_paths:
123
139
  - lib
124
140
  required_ruby_version: !ruby/object:Gem::Requirement
125
141
  requirements:
126
- - - '>='
142
+ - - ">="
127
143
  - !ruby/object:Gem::Version
128
144
  version: '0'
129
145
  required_rubygems_version: !ruby/object:Gem::Requirement
130
146
  requirements:
131
- - - '>='
147
+ - - ">="
132
148
  - !ruby/object:Gem::Version
133
149
  version: '0'
134
150
  requirements: []
135
151
  rubyforge_project:
136
- rubygems_version: 2.0.0
152
+ rubygems_version: 2.2.0
137
153
  signing_key:
138
154
  specification_version: 4
139
155
  summary: pretends you could type really fast