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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 485d2fe9387ec4f159917ac4edcb328701f27117
4
- data.tar.gz: 4e43f0d82abf11ca5d8716cf803271a8eb39b345
3
+ metadata.gz: 917b113c60d5045df2218e8382186b13558968c4
4
+ data.tar.gz: 9ee89dc8e537b1c0a4b3416a4a358650c7ded3b0
5
5
  SHA512:
6
- metadata.gz: a98fb67e3f561bc60187ad1d0c030215e4dfdfc2f6d1762b46627009e00db7efffa1f0ab512aa1026d2eafe72d06c6c17114038d963ad846b972aea30ef7e25e
7
- data.tar.gz: efa9c5929f7d90f59a5f010682bdaa769cbc718c619f2cae30aeb8e8fc6913bb35ab1fae3d098b03d7f62d29015a26d44387a72dc46810996c2459a48ade77cb
6
+ metadata.gz: 1dd4c0c492639c90d0243342a9ba03b6e6789fc6f73114f807d935f8a3a50cc9db151ef380662b048ac96af5ac4c8ca94e991e73a00f56dd64c45a0be354bfe2
7
+ data.tar.gz: e87b8c306b3b7deef43ce572f96bdd1f91774dd827f6408e7f470b9bdfc053624839b0168b09765567ba3b93cbcb579ab676f2ef86b97631d925197b396ab631
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in flaun.gemspec
4
4
  gemspec
5
+ gem 'coveralls', require: false
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]
@@ -6,6 +6,7 @@ Scenario: Open remote host
6
6
  port 8010
7
7
 
8
8
  target :sample do
9
+ user 'bar'
9
10
  host 'eiel.info'
10
11
  path 'foo'
11
12
  end
@@ -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, ENV['USER']) do |a,b, &block|
10
+ Net::SSH.should_receive(:start).with(host, 'bar') do |a,b, &block|
11
11
  ssh = double
12
12
 
13
13
  h = 'localhost'
@@ -1,4 +1,6 @@
1
1
  require 'bundler/setup'
2
- require 'pry-byebug'
3
2
  require 'cucumber/rspec/doubles'
4
3
  require 'flaun'
4
+
5
+ require 'coveralls'
6
+ Coveralls.wear!
@@ -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
@@ -26,30 +26,49 @@ module Flaun
26
26
  end
27
27
 
28
28
  def start(target_name = nil, config_file = nil)
29
- config_file ||= Pathname.new("~/.flaun").expand_path.to_s
29
+ config_file ||= default_config_file
30
30
  unless File.exist? config_file
31
- $stderr.puts 'Plaese, create file ~/.flaun'
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
- $stderr.puts 'select target:'
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
- Net::SSH.start(target.host, target.user ) do |ssh|
45
- ssh.forward.local(
46
- target.forward_port,
47
- target.forward_host,
48
- target.forward_host_port)
43
+ ssh_forward_and_launch target
44
+ end
45
+
46
+ private
49
47
 
50
- Launchy.open( target.access_url )
48
+ def default_config_file
49
+ Pathname.new("~/.flaun").expand_path.to_s
50
+ end
51
51
 
52
- ssh.loop { true }
52
+ def not_found_config_file
53
+ $stderr.puts 'Plaese, create file ~/.flaun'
53
54
  end
54
- end
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
@@ -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
- ENV['USER']
25
+ def user=(user)
26
+ @user = user
25
27
  end
26
28
 
27
29
  def forward_port
@@ -26,6 +26,10 @@ module Flaun
26
26
  @config = ::Flaun::TargetConfig.new(config)
27
27
  end
28
28
 
29
+ def user(user)
30
+ @config.user = user
31
+ end
32
+
29
33
  def port(port)
30
34
  @config.forward_host_port = port
31
35
  end
@@ -1,3 +1,3 @@
1
1
  module Flaun
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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
@@ -0,0 +1,2 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
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.2
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-09 00:00:00.000000000 Z
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: