sinc 0.0.0 → 0.0.1

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: 5470ab670861b8b3df030eaefaa8ed60d133a911
4
- data.tar.gz: 2fad2e9ed27975a3dac02e3ad599216b443890ef
3
+ metadata.gz: 28d51acde589ad3e17ef708e4dd55d52a1d3ffff
4
+ data.tar.gz: 1683a300411bbcc849df74075c7554f3c16db7a8
5
5
  SHA512:
6
- metadata.gz: 0bdb6560b89f805376cffc41144f88cbac416a21e0342eedeaf2185a472da901b4aa62f7014f4e771fd8c8df81c700f73ac533cf2946c3cb8b4c5389cd55716e
7
- data.tar.gz: f707313ad8db2ee4cdc3f24e0b9a54c5f60081e839a69e02b81d00940e7b94227e24523048f6f56cde55c83de3a06b3aa1bed0d11754b3ccef6e000b33e4823f
6
+ metadata.gz: 73fcc527dd1f5b84703d01108c796bbdb5523638d792155688960907c46fc198a92b803681c22f093aded4ce54c4751c19a5031c1416e1c15200755566d12776
7
+ data.tar.gz: 3728ff620a8406f6a413c8ce63a4286096c854716966b71c65ae08925b778303094614bf595d1f3e21369aa678d704ded7eb8a653e0942154d2136a2b434f670
data/bin/sinc ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts "Hello"
data/lib/sinc.rb CHANGED
@@ -1,6 +1,2 @@
1
- class Sinc
2
- def self.test_gem
3
- "sinc"
4
- end
5
- end
6
-
1
+ require "sinc/sinc"
2
+ require "sinc/after_block"
@@ -0,0 +1,15 @@
1
+ after do
2
+ if Sinc.settings
3
+ puts ""
4
+ puts Sinc.headers(response.headers) if Sinc.settings.headers
5
+ puts Sinc.params(params) if Sinc.settings.params
6
+ puts Sinc.session?(session) if Sinc.settings.session
7
+ puts Sinc.body(response.body) if Sinc.settings.body
8
+ else
9
+ puts ""
10
+ puts Sinc.headers(response.headers)
11
+ puts Sinc.params(params)
12
+ puts Sinc.session?(session)
13
+ puts "Response:"
14
+ end
15
+ end
data/lib/sinc/sinc.rb ADDED
@@ -0,0 +1,33 @@
1
+ module Sinc
2
+ require "ostruct"
3
+
4
+ class << self
5
+ attr_accessor :settings
6
+ end
7
+
8
+ module_function
9
+
10
+ def test_gem
11
+ "sinc"
12
+ end
13
+
14
+ def headers(headers)
15
+ "Headers: #{headers}"
16
+ end
17
+
18
+ def params(params)
19
+ "Params: #{params}"
20
+ end
21
+
22
+ def session?(session)
23
+ "Session?: #{session.any?}"
24
+ end
25
+
26
+ def body(body)
27
+ "Body: \n#{body}\n\n"
28
+ end
29
+
30
+ def configure(args)
31
+ @settings = OpenStruct.new(args)
32
+ end
33
+ end
data/spec/sinc_spec.rb CHANGED
@@ -1,7 +1,95 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require "spec_helper"
4
+
1
5
  describe "sinc gem" do
2
- require "sinc"
6
+ include Rack::Test::Methods
7
+ require 'rspec/mocks/standalone'
3
8
 
4
- it "should say hi" do
5
- expect(Sinc.test_gem).to eq("sinc")
9
+ def app
10
+ Sinatra::Application
11
+ end
12
+
13
+ describe "#test_gem" do
14
+ it "should be defined" do
15
+ expect(Sinc).to respond_to(:test_gem)
16
+ end
17
+
18
+ it "should say hi" do
19
+ expect(Sinc.test_gem).to eq("sinc")
20
+ end
21
+ end
22
+
23
+ describe "#headers" do
24
+ it "should be defined" do
25
+ expect(Sinc).to respond_to(:headers)
26
+ end
27
+
28
+ it "should display headers" do
29
+ expect(Sinc.headers({"Content-Type" => "text/plain"})).to eq("Headers: {\"Content-Type\"=>\"text/plain\"}")
30
+ end
31
+ end
32
+
33
+ describe "#params" do
34
+ it "should be defined" do
35
+ expect(Sinc).to respond_to(:params)
36
+ end
37
+
38
+ it "should display params" do
39
+ expect(Sinc.params({:fake_key => "fake value"})).to eq("Params: {:fake_key=>\"fake value\"}")
40
+ end
41
+ end
42
+
43
+ describe "#session" do
44
+ it "should be defined" do
45
+ expect(Sinc).to respond_to(:session?)
46
+ end
47
+
48
+ it "should display session presence" do
49
+ expect(Sinc.session?({:fake_user_id => 1})).to eq("Session?: true")
50
+ end
51
+ end
52
+
53
+ describe "#body" do
54
+ it "should be defined" do
55
+ expect(Sinc).to respond_to(:body)
56
+ end
57
+
58
+ it "should display the body" do
59
+ expect(Sinc.body(["body"])).to eq("Body: \n[\"body\"]\n\n")
60
+ end
61
+ end
62
+
63
+ describe "#configure" do
64
+ it "should be defined" do
65
+ expect(Sinc).to respond_to(:configure)
66
+ end
67
+
68
+ it "should take arguments" do
69
+ expect(Sinc.configure(:params => true)).not_to be_nil
70
+ end
71
+
72
+ it "should hold attributes" do
73
+ config = Sinc.configure(:params => true, :session => true, :headers => false, :body => false)
74
+ expect(config.params).to eq(true)
75
+ expect(config.session).to eq(true)
76
+ expect(config.headers).to eq(false)
77
+ expect(config.body).to eq(false)
78
+ end
79
+ end
80
+
81
+ describe "#settings" do
82
+ it "should be defined" do
83
+ expect(Sinc).to respond_to(:settings)
84
+ end
85
+
86
+ it "should hold settings" do
87
+ Sinc.configure(:params => true, :session => true, :headers => false, :body => false)
88
+ expect(Sinc.settings.params).to eq(true)
89
+ expect(Sinc.settings.session).to eq(true)
90
+ expect(Sinc.settings.headers).to eq(false)
91
+ expect(Sinc.settings.body).to eq(false)
92
+ end
6
93
  end
7
94
  end
95
+
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,16 @@
1
1
  require "sinatra"
2
2
  require "rspec"
3
3
  require "rack/test"
4
- require "spec_helper"
5
- require "lib/sinc.rb"
4
+ Dir["./lib/*/*.rb"].each {|file| require file }
6
5
 
7
- Rspec.configure do |config|
6
+ RSpec.configure do |config|
8
7
  config.color_enabled = true
9
8
  end
9
+
10
+ get "/" do
11
+ "Hello world"
12
+ end
13
+
14
+ get "/params" do
15
+ params[:hello] = "hi"
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Weiksnar
@@ -10,16 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-09-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: gem under construction
13
+ description: Sinatra server log for classic apps
14
14
  email: aweiksnar@gmail.com
15
- executables: []
15
+ executables:
16
+ - sinc
16
17
  extensions: []
17
18
  extra_rdoc_files: []
18
19
  files:
20
+ - lib/sinc/after_block.rb
21
+ - lib/sinc/sinc.rb
19
22
  - lib/sinc.rb
20
23
  - spec/sinc_spec.rb
21
24
  - spec/spec_helper.rb
22
- homepage:
25
+ - bin/sinc
26
+ homepage: http://rubygems.org/gems/sinc
23
27
  licenses:
24
28
  - MIT
25
29
  metadata: {}
@@ -42,7 +46,7 @@ rubyforge_project:
42
46
  rubygems_version: 2.0.5
43
47
  signing_key:
44
48
  specification_version: 4
45
- summary: Sinatra Console
49
+ summary: sinc = sinatra in console
46
50
  test_files:
47
51
  - spec/sinc_spec.rb
48
52
  - spec/spec_helper.rb