anymock 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2e688b558692babd2640ab7f1eeb7c56ca06e51c
4
+ data.tar.gz: 29ac02734b8851f8e614b9d6851cc29c2e166923
5
+ SHA512:
6
+ metadata.gz: 92a15672380e54a4f844c4b308040aa65b00e1d979320ed1afa814278f1945345c5310c2fd3580a0ec75a0f14dac510e60605cceb08b2354a00ac81d540ebcdc
7
+ data.tar.gz: 9085f797ec7b7406d38d1b4bacbec5a5e9329807b8683b0b05a68a390ee57ea474b43ddefa17ed963c9d10cebaace098bdc363566c513fde402e15e0bd22ab98
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.13.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in anymock.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Anymock
2
+
3
+ Simple mock server.
4
+ Print request params to response and STDOUT.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'anymock'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install anymock
21
+
22
+ ## Options
23
+
24
+ ```
25
+ -d [DIR] specify document root (default: './public')
26
+ -h [HOST] speify host name (default: 'localhost')
27
+ -p [PORT] specify port number (default: '8080')
28
+ -m puts response to STDOUT
29
+ ```
30
+
31
+ ## Example
32
+
33
+ $ anyock -d ./files -h localhost -p 8100 -m
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nysalor/anymock.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/anymock.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'anymock/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "anymock"
8
+ spec.version = Anymock::VERSION
9
+ spec.authors = ["Jun Yokoyama"]
10
+ spec.email = ["jun@larus.org"]
11
+
12
+ spec.summary = %q{mock server for development.}
13
+ spec.description = %q{simple mock server for development.}
14
+ spec.homepage = "https://github.com/nysalor/anymock"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = ['anymock']
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.13"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ spec.add_dependency "thor"
36
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "anymock"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/anymock ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "anymock"
4
+
5
+ Anymock::CLI.start
data/lib/anymock.rb ADDED
@@ -0,0 +1,43 @@
1
+ require "anymock/version"
2
+ require "anymock/cli"
3
+ require "webrick"
4
+ require "json"
5
+
6
+ module Anymock
7
+ class Server
8
+ attr_accessor :document_root, :address, :port
9
+
10
+ def initialize(opts = {})
11
+ @document_root = opts[:document_root]
12
+ @address = opts[:address]
13
+ @port = opts[:port]
14
+ @mirror = opts[:mirror]
15
+ end
16
+
17
+ def start
18
+ server.mount_proc '/' do |req, res|
19
+ body = { req.request_method => req.query }.to_json
20
+ res.body = body
21
+ output body if @mirror
22
+ end
23
+ server.start
24
+ end
25
+
26
+ def output(body)
27
+ puts "response:"
28
+ puts "----"
29
+ puts body
30
+ puts "----"
31
+ end
32
+
33
+ private
34
+
35
+ def server
36
+ @server ||= WEBrick::HTTPServer.new({
37
+ DocumentRoot: document_root,
38
+ BindAddress: address,
39
+ Port: port
40
+ })
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,33 @@
1
+ require 'thor'
2
+
3
+ module Anymock
4
+ class CLI < Thor
5
+ default_command :start_server
6
+
7
+ option :d, type: :string, default: 'public/'
8
+ option :h, type: :string, default: 'localhost'
9
+ option :p, type: :string, default: '8080'
10
+ option :m, type: :boolean, default: false
11
+
12
+ desc "start", "start mock server"
13
+
14
+ def start_server
15
+ server.start
16
+ end
17
+
18
+ private
19
+
20
+ def server
21
+ @anymock ||= Anymock::Server.new option_strings
22
+ end
23
+
24
+ def option_strings
25
+ {
26
+ document_root: options[:d],
27
+ address: options[:h],
28
+ port: options[:p],
29
+ mirror: options[:m]
30
+ }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Anymock
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: anymock
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jun Yokoyama
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-29 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: simple mock server for development.
70
+ email:
71
+ - jun@larus.org
72
+ executables:
73
+ - anymock
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - anymock.gemspec
84
+ - bin/console
85
+ - bin/setup
86
+ - exe/anymock
87
+ - lib/anymock.rb
88
+ - lib/anymock/cli.rb
89
+ - lib/anymock/version.rb
90
+ homepage: https://github.com/nysalor/anymock
91
+ licenses: []
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.6.8
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: mock server for development.
113
+ test_files: []