hiroshimarb 0.0.1 → 0.0.2

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.
data/hiroshimarb.gemspec CHANGED
@@ -17,4 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.version = Hiroshimarb::VERSION
18
18
 
19
19
  gem.add_dependency "launchy", "~> 2.1.2"
20
+
21
+ gem.add_development_dependency "rspec", "~> 2.11"
20
22
  end
@@ -0,0 +1,36 @@
1
+ require 'hiroshimarb/member'
2
+ require 'rubygems'
3
+ require 'launchy'
4
+
5
+ module Hiroshimarb
6
+ # コマンドラインから呼びだされる場合のサブコマンドを実装する
7
+ module CLI
8
+ # Hiroshim.rbのウェブサイトをブラウザで開く
9
+ def open
10
+ Launchy.open 'http://hiroshimarb.github.com'
11
+ end
12
+
13
+ # Hiroshim.rbの情報を標準出力へ表示
14
+ def info
15
+ help
16
+ end
17
+
18
+ # Hiroshima.rbのメンバーを標準出力へ表示
19
+ def member
20
+ Member.all.reduce(nil) do |acc, member|
21
+ puts acc if acc
22
+ puts member.to_s
23
+ acc = '-'*80
24
+ end
25
+ end
26
+
27
+ def help
28
+ puts <<EOD
29
+ Usage: hiroshimarb command
30
+ Available commands:
31
+ open : open the Hiroshima.rb website in a web browser
32
+ member : display the member of Hiroshima.rb
33
+ EOD
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ require 'hiroshimarb/member'
2
+
3
+ module Hiroshimarb
4
+ class DSL < BasicObject
5
+ def initialize
6
+ @members = []
7
+ end
8
+
9
+ def member(&block)
10
+ @member = ::Hiroshimarb::Member.new
11
+ @members << @member
12
+ block.call if block
13
+ @members
14
+ end
15
+
16
+ [:name, :github, :twitter, :website, :profile].each do |method_name|
17
+ define_method method_name do |value|
18
+ proxy_name = "#{method_name}="
19
+ @member.send proxy_name, value
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Hiroshimarb
3
+ # メンバーを表現するクラス
4
+ autoload "DSL", 'hiroshimarb/dsl'
5
+ class Member
6
+ class << self
7
+ def all
8
+ @members ||= load
9
+ end
10
+
11
+ def load
12
+ relative_path = "..","..","resource","member.rb"
13
+ resource_file = File.join(File.dirname(__FILE__), relative_path)
14
+ # resource の中で Member.define が呼ばれる
15
+ require resource_file
16
+ @members
17
+ end
18
+
19
+ def define(&block)
20
+ @members = DSL.new.instance_exec &block
21
+ end
22
+ end
23
+
24
+ attr_accessor :name, :github, :website, :twitter, :profile
25
+
26
+ def to_s
27
+ <<EOD
28
+ name #{name}
29
+ github id #{github}
30
+ twitter id #{twitter}
31
+ website #{website}
32
+ profile
33
+ #{profile}
34
+ EOD
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module Hiroshimarb
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/hiroshimarb.rb CHANGED
@@ -1,18 +1,23 @@
1
1
  require "hiroshimarb/version"
2
- require 'rubygems'
3
- require 'launchy'
2
+ require 'hiroshimarb/cli'
4
3
 
5
4
  module Hiroshimarb
5
+ extend CLI
6
+
6
7
  class << self
7
8
  def execute(argv)
8
- if argv.first == 'open'
9
- Launchy.open 'http://hiroshimarb.github.com'
9
+ return help if argv.count == 0
10
+
11
+ command = argv.shift
12
+ case command
13
+ when 'open'
14
+ open
15
+ when 'info'
16
+ info
17
+ when 'member'
18
+ member
10
19
  else
11
- puts <<EOD
12
- Usage: hiroshimarb command
13
- Available commands:
14
- open : open the Hiroshima.rb website in a web browser
15
- EOD
20
+ help
16
21
  end
17
22
  end
18
23
  end
@@ -0,0 +1,83 @@
1
+ # -*- coding: utf-8 -*-
2
+ Hiroshimarb::Member.define do
3
+ member do
4
+ name 'Tomohiko Himura'
5
+ github 'eiel'
6
+ twitter 'eielh'
7
+ website 'http://eiel.info/'
8
+ profile 'Hiroshima.rb の会場確保係。会長ではない。'
9
+ end
10
+
11
+ member do
12
+ name 'KITADAI, Yukinori'
13
+ github 'Nyoho'
14
+ twitter 'NeXTSTEP2OSX'
15
+ website 'http://nyoho.jp'
16
+ profile 'Hiroshima.rb やその会長を使って勉強をする係'
17
+ end
18
+
19
+ member do
20
+ name 'John Mettraux'
21
+ github 'jmettraux'
22
+ twitter 'jmettraux'
23
+ website 'http://lambda.io/jmettraux'
24
+ profile 'スイス人、チーズがすき'
25
+ end
26
+
27
+ member do
28
+ name 'Akira345'
29
+ github 'akira345'
30
+ twitter 'akira345'
31
+ website 'http://akira-junkbox.blogspot.com'
32
+ profile 'Hiroshima.rbで会長を困らせる係。最近WindowsPhoneに浮気気味な趣味人。ハード好き。'
33
+ end
34
+
35
+ member do
36
+ name 'Tatsuya Furukido'
37
+ github 'furu'
38
+ twitter 'pecosantoyobe'
39
+ website 'example.com'
40
+ profile 'hi'
41
+ end
42
+
43
+ member do
44
+ name 'Takanobu Kamada'
45
+ github 'kama-t'
46
+ twitter 'nill'
47
+ website 'example.com'
48
+ profile 'hi'
49
+ end
50
+
51
+ member do
52
+ name 'Takashi Akagi'
53
+ github 'majosystems'
54
+ twitter 'majosystems'
55
+ website 'http://majosystems.com'
56
+ profile 'なかなか参加できてませんが・・・勉強中です'
57
+ end
58
+
59
+ member do
60
+ name 'Hidetoshi Kawaguchi'
61
+ github 'nill'
62
+ twitter 'thethe3i9t'
63
+ website 'nill'
64
+ profile '勉強中・・・'
65
+ end
66
+
67
+ member do
68
+ name 'Kazuya Matsubara'
69
+ github 'Torokun'
70
+ twitter 'Toro_kun'
71
+ website 'http://switch.dip.jp/toro/blog/'
72
+ profile 'たまにもくもくしに参加してます。Rubyは使ったことがない初心者です・・・。'
73
+ end
74
+
75
+ member do
76
+ name 'Tomohiro Morishita'
77
+ github 'moriC'
78
+ twitter 'tomohiro_0219'
79
+ website ''
80
+ profile 'よろしくお願いします'
81
+ end
82
+
83
+ end
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'hiroshimarb/cli'
3
+
4
+ describe Hiroshimarb::CLI do
5
+ let(:cli) do
6
+ Object.new.extend Hiroshimarb::CLI
7
+ end
8
+
9
+ describe '#open' do
10
+ subject { cli.open }
11
+ it "Hiroshima.rbのウェブサイトを表示" do
12
+ Launchy.should_receive(:open).with('http://hiroshimarb.github.com')
13
+ subject
14
+ end
15
+ end
16
+
17
+ describe '#info' do
18
+ it 'Hiroshim.rbの情報を出力'
19
+ end
20
+
21
+ describe '#member' do
22
+ subject { cli.member }
23
+ it 'Hiroshim.rbのメンバーを出力' do
24
+ Hiroshimarb::Member.stub(:all) { %W{hoge mogu} }
25
+ $stdout = StringIO.new
26
+ subject
27
+ $stdout.seek 0
28
+ expect($stdout.read).to eq("hoge\n" + '-'*80 + "\nmogu\n")
29
+ end
30
+ end
31
+
32
+ describe '#help' do
33
+ it '使い方を出力'
34
+ end
35
+ end
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'hiroshimarb/dsl'
3
+
4
+ module Hiroshimarb
5
+ describe DSL do
6
+ let(:dsl) { DSL.new }
7
+
8
+ describe '#member' do
9
+ subject { dsl.member }
10
+ it { should have(1).items }
11
+ end
12
+
13
+ describe '#name' do
14
+ subject { dsl.name "hoge" }
15
+
16
+ it "name が設定できる" do
17
+ dsl.member
18
+ subject
19
+ member = dsl.instance_exec { @member }
20
+ expect(member.name).to eq("hoge")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'hiroshimarb/member'
3
+
4
+ module Hiroshimarb
5
+ describe Member do
6
+ describe '.all' do
7
+ subject { Member.all }
8
+ it "1件以上のデータがある" do
9
+ expect(subject.count).to be > 1
10
+ end
11
+ end
12
+
13
+ describe '#to_s' do
14
+ subject { member.to_s }
15
+
16
+ let(:member) do
17
+ m = Member.new
18
+ m.name = 'ruby Hiroshima'
19
+ m.github = 'hiroshimarb'
20
+ m.website = 'http://hiroshimarb.github.com/'
21
+ m.profile = 'Hiroshima.rb'
22
+ m
23
+ end
24
+
25
+ it do
26
+ should eq(<<EOD)
27
+ name ruby Hiroshima
28
+ github id hiroshimarb
29
+ twitter id
30
+ website http://hiroshimarb.github.com/
31
+ profile
32
+ Hiroshima.rb
33
+ EOD
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,43 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'hiroshimarb'
3
+
4
+ describe Hiroshimarb do
5
+ describe '.execute' do
6
+ subject { Hiroshimarb.execute argv }
7
+ context "when 第1引数が 'open'" do
8
+ let(:argv) { ['open'] }
9
+
10
+ it "open メソッドが呼ばれる" do
11
+ Hiroshimarb.should_receive(:open)
12
+ subject
13
+ end
14
+ end
15
+
16
+ context "when 第1引数が 'info'" do
17
+ let(:argv) { ['info'] }
18
+
19
+ it "info メソッドが呼ばれる" do
20
+ Hiroshimarb.should_receive(:info)
21
+ subject
22
+ end
23
+ end
24
+
25
+ context "when 第1引数が 'member'" do
26
+ let(:argv) { ['member'] }
27
+
28
+ it "member メソッドが呼ばれる" do
29
+ Hiroshimarb.should_receive(:member)
30
+ subject
31
+ end
32
+ end
33
+
34
+ context "when 引数がない場合'" do
35
+ let(:argv) { [] }
36
+
37
+ it "help メソッドが呼ばれる" do
38
+ Hiroshimarb.should_receive(:help)
39
+ subject
40
+ end
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiroshimarb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-01 00:00:00.000000000 Z
12
+ date: 2012-09-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: launchy
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 2.1.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.11'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.11'
30
46
  description: provide `hiroshimarb` command. hiroshimarb is Hiroshima.rb. Hiroshima.rb
31
47
  is local community of Ruby in Hiroshima/Japan
32
48
  email:
@@ -44,7 +60,15 @@ files:
44
60
  - bin/hiroshimarb
45
61
  - hiroshimarb.gemspec
46
62
  - lib/hiroshimarb.rb
63
+ - lib/hiroshimarb/cli.rb
64
+ - lib/hiroshimarb/dsl.rb
65
+ - lib/hiroshimarb/member.rb
47
66
  - lib/hiroshimarb/version.rb
67
+ - resource/member.rb
68
+ - spec/hiroshimarb/cli_spec.rb
69
+ - spec/hiroshimarb/dsl_spec.rb
70
+ - spec/hiroshimarb/member_spec.rb
71
+ - spec/hiroshimarb_spec.rb
48
72
  homepage: http://github.com/hiroshimarb/hiroshimarb-gem
49
73
  licenses: []
50
74
  post_install_message:
@@ -69,5 +93,9 @@ rubygems_version: 1.8.23
69
93
  signing_key:
70
94
  specification_version: 3
71
95
  summary: provide `hiroshimarb` command. hiroshimarb is Hiroshima.rb
72
- test_files: []
96
+ test_files:
97
+ - spec/hiroshimarb/cli_spec.rb
98
+ - spec/hiroshimarb/dsl_spec.rb
99
+ - spec/hiroshimarb/member_spec.rb
100
+ - spec/hiroshimarb_spec.rb
73
101
  has_rdoc: