flaun 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +1 -0
- data/README.md +4 -0
- data/Rakefile +13 -0
- data/features/flaun.feature +1 -0
- data/features/step_definit/flaun_steps.rb +1 -1
- data/features/support/env.rb +3 -1
- data/flaun.gemspec +0 -1
- data/lib/flaun.rb +31 -12
- data/lib/flaun/config.rb +4 -2
- data/lib/flaun/dsl.rb +4 -0
- data/lib/flaun/version.rb +1 -1
- data/spec/flaun/dsl_spec.rb +36 -0
- data/spec/spec_helper.rb +2 -0
- metadata +8 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 917b113c60d5045df2218e8382186b13558968c4
|
4
|
+
data.tar.gz: 9ee89dc8e537b1c0a4b3416a4a358650c7ded3b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dd4c0c492639c90d0243342a9ba03b6e6789fc6f73114f807d935f8a3a50cc9db151ef380662b048ac96af5ac4c8ca94e991e73a00f56dd64c45a0be354bfe2
|
7
|
+
data.tar.gz: e87b8c306b3b7deef43ce572f96bdd1f91774dd827f6408e7f470b9bdfc053624839b0168b09765567ba3b93cbcb579ab676f2ef86b97631d925197b396ab631
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Flaun
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/eiel/flaun.png?branch=master)](https://travis-ci.org/eiel/flaun)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/eiel/flaun/badge.png?branch=master)](https://coveralls.io/r/eiel/flaun)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/eiel/flaun.png)](https://codeclimate.com/github/eiel/flaun)
|
6
|
+
|
3
7
|
TODO 英語で書きなおす。
|
4
8
|
|
5
9
|
リモートのサーバからブラウザでアクセスすることを再現できます。
|
data/Rakefile
CHANGED
@@ -1 +1,14 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require 'cucumber'
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require 'cucumber/rake/task'
|
9
|
+
|
10
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
11
|
+
t.cucumber_opts = "features --format pretty"
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => [:spec, :features]
|
data/features/flaun.feature
CHANGED
@@ -7,7 +7,7 @@ Given(/^should open "(.*?)"$/) do |uri|
|
|
7
7
|
end
|
8
8
|
|
9
9
|
Given(/^should ssh "(.*?)"$/) do |host|
|
10
|
-
Net::SSH.should_receive(:start).with(host,
|
10
|
+
Net::SSH.should_receive(:start).with(host, 'bar') do |a,b, &block|
|
11
11
|
ssh = double
|
12
12
|
|
13
13
|
h = 'localhost'
|
data/features/support/env.rb
CHANGED
data/flaun.gemspec
CHANGED
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "cucumber"
|
24
24
|
spec.add_development_dependency "rspec"
|
25
|
-
spec.add_development_dependency "pry-byebug"
|
26
25
|
spec.add_dependency "launchy"
|
27
26
|
spec.add_dependency "net-ssh"
|
28
27
|
end
|
data/lib/flaun.rb
CHANGED
@@ -26,30 +26,49 @@ module Flaun
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def start(target_name = nil, config_file = nil)
|
29
|
-
config_file ||=
|
29
|
+
config_file ||= default_config_file
|
30
30
|
unless File.exist? config_file
|
31
|
-
|
31
|
+
not_found_config_file
|
32
32
|
exit 1
|
33
33
|
end
|
34
34
|
config = config_load(open(config_file).read, config_file)
|
35
35
|
|
36
36
|
if target_name.nil?
|
37
|
-
|
38
|
-
puts config.targets.keys
|
37
|
+
not_target_name config
|
39
38
|
exit 1
|
40
39
|
end
|
41
40
|
|
42
41
|
target = config[target_name.to_sym]
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
target.forward_host_port)
|
43
|
+
ssh_forward_and_launch target
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
49
47
|
|
50
|
-
|
48
|
+
def default_config_file
|
49
|
+
Pathname.new("~/.flaun").expand_path.to_s
|
50
|
+
end
|
51
51
|
|
52
|
-
|
52
|
+
def not_found_config_file
|
53
|
+
$stderr.puts 'Plaese, create file ~/.flaun'
|
53
54
|
end
|
54
|
-
|
55
|
+
|
56
|
+
def not_target_name(config)
|
57
|
+
$stderr.puts 'select target:'
|
58
|
+
puts config.targets.keys
|
59
|
+
end
|
60
|
+
|
61
|
+
def ssh_forward_and_launch(target)
|
62
|
+
Net::SSH.start(target.host, target.user ) do |ssh|
|
63
|
+
ssh.forward.local(
|
64
|
+
target.forward_port,
|
65
|
+
target.forward_host,
|
66
|
+
target.forward_host_port)
|
67
|
+
|
68
|
+
Launchy.open( target.access_url )
|
69
|
+
|
70
|
+
ssh.loop { true }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
# end private
|
55
74
|
end
|
data/lib/flaun/config.rb
CHANGED
@@ -14,14 +14,16 @@ module Flaun
|
|
14
14
|
|
15
15
|
class TargetConfig
|
16
16
|
attr_accessor :forward_host_port, :host, :path
|
17
|
+
attr_reader :user
|
17
18
|
|
18
19
|
def initialize(config)
|
19
20
|
@config = config
|
20
21
|
@forward_host_port = 80
|
22
|
+
@user = ENV['USER']
|
21
23
|
end
|
22
24
|
|
23
|
-
def user
|
24
|
-
|
25
|
+
def user=(user)
|
26
|
+
@user = user
|
25
27
|
end
|
26
28
|
|
27
29
|
def forward_port
|
data/lib/flaun/dsl.rb
CHANGED
data/lib/flaun/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'flaun/dsl'
|
3
|
+
|
4
|
+
describe Flaun::DSL do
|
5
|
+
let(:dsl) { Flaun::DSL.new }
|
6
|
+
|
7
|
+
describe '#port' do
|
8
|
+
subject { dsl.port number }
|
9
|
+
|
10
|
+
context 'when port number 4000' do
|
11
|
+
let(:number) { 4000 }
|
12
|
+
|
13
|
+
it 'config.port eq 4000' do
|
14
|
+
subject
|
15
|
+
expect( dsl.config.port ).to eq(4000)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe Flaun::DSLTarget do
|
22
|
+
let(:dsl) { Flaun::DSLTarget.new(config) }
|
23
|
+
let(:config) { Flaun::Config.new }
|
24
|
+
|
25
|
+
describe '#user' do
|
26
|
+
subject { dsl.user user }
|
27
|
+
context "when user is 'bar'" do
|
28
|
+
let(:user) { 'bar' }
|
29
|
+
|
30
|
+
it 'config.user eq "user"' do
|
31
|
+
subject
|
32
|
+
expect( dsl.config.user ).to eq(user)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flaun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomohiko Himura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry-byebug
|
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
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: launchy
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,7 +102,9 @@ executables:
|
|
116
102
|
extensions: []
|
117
103
|
extra_rdoc_files: []
|
118
104
|
files:
|
105
|
+
- .coveralls.yml
|
119
106
|
- .gitignore
|
107
|
+
- .travis.yml
|
120
108
|
- Gemfile
|
121
109
|
- LICENSE.txt
|
122
110
|
- README.md
|
@@ -131,6 +119,8 @@ files:
|
|
131
119
|
- lib/flaun/config.rb
|
132
120
|
- lib/flaun/dsl.rb
|
133
121
|
- lib/flaun/version.rb
|
122
|
+
- spec/flaun/dsl_spec.rb
|
123
|
+
- spec/spec_helper.rb
|
134
124
|
homepage: https://github.com/eiel/flaun
|
135
125
|
licenses:
|
136
126
|
- MIT
|
@@ -160,4 +150,6 @@ test_files:
|
|
160
150
|
- features/flaun.feature
|
161
151
|
- features/step_definit/flaun_steps.rb
|
162
152
|
- features/support/env.rb
|
153
|
+
- spec/flaun/dsl_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
163
155
|
has_rdoc:
|