testspace 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e911e1369f68f49716073e4fac1300ea88fa6cb
4
+ data.tar.gz: f9f7985d63694c5c0a37dec74aa342950c4d18b0
5
+ SHA512:
6
+ metadata.gz: c578bb16756b3c310aea5cec37918508f15f3626a291d37b25e0e96565e492ae9f7225b2801333e80ed3a7da81fa950fc50a3edc88f2fd5e08da73f3266b1756
7
+ data.tar.gz: 16ad1ff8d2f6a36e78d41ae66e4c8c0601558b22aa093da6f9ab8ea91ece25d6a61545dd9fad5fec2239742ef8d85ccdf82aca9c701f1e7bc0da183ded235edf
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in testspace.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Testspace
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/testspace`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'testspace'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install testspace
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/testspace.
36
+
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/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "testspace"
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,13 @@
1
+ module Testspace
2
+ module Inflection
3
+ refine ::String do
4
+ def pascalize
5
+ split(/_/).map{|i| i[0].upcase + i[1..-1]}.join('')
6
+ end
7
+
8
+ def snakify
9
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Testspace
2
+ module Modules
3
+ @@number = 1
4
+
5
+ def self.create
6
+ m = ::Module.new
7
+ const_set "M#{@@number}", m
8
+ m.name # fix module's name
9
+ @@number += 1
10
+ m
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Testspace::Rspec
2
+ module Helpers
3
+ def testspace(metadata, &block)
4
+ from = ::Testspace::Rspec::Metadata.new(metadata).dir
5
+ options = {}
6
+ options[:from] = from if ::File.exist?(from)
7
+ space = ::Testspace::Space.new(options)
8
+ space.enter do
9
+ block.call space
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module Testspace::Rspec::Metadata::Extensions::Description
2
+ module ClassMethod
3
+ def local_dir
4
+ @local_dir ||= description_arg
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ module Testspace::Rspec::Metadata::Extensions::Description
2
+ module General
3
+ def local_dir
4
+ @local_dir ||= begin
5
+ s = description_arg.gsub(/\s+/, '_')
6
+ '-' + s
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Testspace::Rspec::Metadata::Extensions::Description
2
+ module InstanceMethod
3
+ def local_dir
4
+ @local_dir ||= description_arg
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ using Testspace::Inflection
2
+
3
+ module Testspace::Rspec::Metadata::Extensions::Description
4
+ module Module
5
+ def root_dir
6
+ @root_dir ||= "#{::Dir.pwd}/spec/classes"
7
+ end
8
+
9
+ def local_dir
10
+ description_arg.name.split(/::/).map{|i| i.snakify}.join('/')
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,55 @@
1
+ using Testspace::Inflection
2
+
3
+ module Testspace::Rspec
4
+ class Metadata
5
+ Quir.autoload! {}
6
+
7
+ def initialize(rspec)
8
+ @rspec = rspec
9
+ extend_for_description
10
+ end
11
+
12
+ def parent
13
+ @parent ||= begin
14
+ @rspec[:parent_example_group] && Metadata.new(@rspec[:parent_example_group]) ||
15
+ @rspec.key?(:example_group) && @rspec[:example_group] && Metadata.new(@rspec[:example_group])
16
+ end
17
+ end
18
+
19
+ def root
20
+ @root ||= parent ? parent.root : self
21
+ end
22
+
23
+ def dir
24
+ @dir ||= parent ? "#{parent.dir}/#{local_dir}" : "#{root_dir}/#{local_dir}"
25
+ end
26
+
27
+ def description_arg
28
+ @description_arg ||= @rspec[:description_args].first
29
+ end
30
+
31
+ def description_kind
32
+ @description_kind ||= begin
33
+ case description_arg
34
+ when ::Module
35
+ :module
36
+ when ::NilClass
37
+ :anonymous
38
+ else
39
+ arg = description_arg.to_s
40
+ if /^#/ =~ arg
41
+ :instance_method
42
+ elsif /^\./ =~ arg
43
+ :class_method
44
+ else
45
+ :general
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ def extend_for_description
52
+ extend Extensions::Description.const_get(description_kind.to_s.pascalize, false)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,38 @@
1
+ module Testspace
2
+ class Space
3
+ def initialize(options = {})
4
+ @options = options
5
+ end
6
+
7
+ attr_reader :dir
8
+
9
+ def module
10
+ @module ||= ::Testspace::Modules.create
11
+ end
12
+
13
+ def enter(&block)
14
+ ::Dir.mktmpdir do |dir|
15
+ @dir = dir
16
+ expand
17
+ block.call
18
+ end
19
+ end
20
+
21
+ private def expand
22
+ return unless from
23
+ `find '#{from}' -maxdepth 1 | grep -v -F -x '#{from}' | xargs -I {} cp -a {} '#{dir}/'`
24
+ ::Dir.glob("#{dir}/**/*.rb").each do |f|
25
+ next unless ::File.file?(f)
26
+ ::File.write f, expand_text(::File.read(f))
27
+ end
28
+ end
29
+
30
+ def from
31
+ @from ||= @options[:from]
32
+ end
33
+
34
+ private def expand_text(text)
35
+ text.gsub(/TESTSPACE/, self.module.name)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Testspace
2
+ VERSION = "0.1.0"
3
+ end
data/lib/testspace.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "testspace/version"
2
+ require 'quir'
3
+
4
+ module Testspace
5
+ Quir.autoload! {}
6
+ end
data/testspace.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'testspace/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "testspace"
8
+ spec.version = Testspace::VERSION
9
+ spec.authors = ["mosop"]
10
+ spec.email = ["mosop@a.b.com"]
11
+
12
+ spec.summary = %q{A library for making temporary space.}
13
+ spec.homepage = "https://github.com/mosop/testspace"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "quir", "~> 0.2.0"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.4"
25
+ spec.add_development_dependency "pry"
26
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: testspace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mosop
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: quir
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - mosop@a.b.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - lib/testspace.rb
99
+ - lib/testspace/inflection.rb
100
+ - lib/testspace/modules.rb
101
+ - lib/testspace/rspec/helpers.rb
102
+ - lib/testspace/rspec/metadata.rb
103
+ - lib/testspace/rspec/metadata/extensions/description/class_method.rb
104
+ - lib/testspace/rspec/metadata/extensions/description/general.rb
105
+ - lib/testspace/rspec/metadata/extensions/description/instance_method.rb
106
+ - lib/testspace/rspec/metadata/extensions/description/module.rb
107
+ - lib/testspace/space.rb
108
+ - lib/testspace/version.rb
109
+ - testspace.gemspec
110
+ homepage: https://github.com/mosop/testspace
111
+ licenses: []
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.5.1
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: A library for making temporary space.
133
+ test_files: []