my-lib 0.0.1.1 → 0.0.1.3

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/my-lib.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{my-lib}
8
- s.version = "0.0.1.1"
8
+ s.version = "0.0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{modeverv}]
12
- s.date = %q{2011-09-01}
12
+ s.date = %q{2011-09-02}
13
13
  s.description = %q{longer description of your gem}
14
14
  s.email = %q{modeverv@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -24,13 +24,23 @@ Gem::Specification.new do |s|
24
24
  "LICENSE.txt",
25
25
  "README.rdoc",
26
26
  "Rakefile",
27
+ "TAGS",
27
28
  "VERSION",
28
- "lib/dev.rb",
29
+ "lib/1.rb",
30
+ "lib/lib/anisoku.rb",
31
+ "lib/lib/job.rb",
32
+ "lib/lib/machine.rb",
33
+ "lib/lib/myat.rb",
34
+ "lib/lib/myconfig.rb",
35
+ "lib/lib/mydb.rb",
36
+ "lib/lib/mygcal.rb",
37
+ "lib/lib/mylogger.rb",
38
+ "lib/lib/myobject.rb",
39
+ "lib/lib/mypusher.rb",
40
+ "lib/lib/runpersec.rb",
29
41
  "lib/my-lib.rb",
30
- "lib/opt-parse.rb",
31
42
  "my-lib.gemspec",
32
43
  "spec/my-lib_spec.rb",
33
- "spec/opt-parse_spec.rb",
34
44
  "spec/spec_helper.rb"
35
45
  ]
36
46
  s.homepage = %q{http://github.com/modeverv/my-lib}
@@ -51,6 +61,8 @@ Gem::Specification.new do |s|
51
61
  s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
52
62
  s.add_development_dependency(%q<jeweler>, [">= 0"])
53
63
  s.add_development_dependency(%q<rcov>, [">= 0"])
64
+ s.add_development_dependency(%q<guard>, [">= 0"])
65
+ s.add_development_dependency(%q<guard-spork>, [">= 0"])
54
66
  else
55
67
  s.add_dependency(%q<term-ansicolor>, [">= 0"])
56
68
  s.add_dependency(%q<eventmachine>, [">= 0"])
@@ -60,6 +72,8 @@ Gem::Specification.new do |s|
60
72
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
61
73
  s.add_dependency(%q<jeweler>, [">= 0"])
62
74
  s.add_dependency(%q<rcov>, [">= 0"])
75
+ s.add_dependency(%q<guard>, [">= 0"])
76
+ s.add_dependency(%q<guard-spork>, [">= 0"])
63
77
  end
64
78
  else
65
79
  s.add_dependency(%q<term-ansicolor>, [">= 0"])
@@ -70,6 +84,8 @@ Gem::Specification.new do |s|
70
84
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
71
85
  s.add_dependency(%q<jeweler>, [">= 0"])
72
86
  s.add_dependency(%q<rcov>, [">= 0"])
87
+ s.add_dependency(%q<guard>, [">= 0"])
88
+ s.add_dependency(%q<guard-spork>, [">= 0"])
73
89
  end
74
90
  end
75
91
 
data/spec/my-lib_spec.rb CHANGED
@@ -17,3 +17,27 @@ describe "MyLib" do
17
17
  MyLogger.lw "warn"
18
18
  end
19
19
  end
20
+
21
+
22
+ describe "MyLogger" do
23
+
24
+ it "log should success" do
25
+ MyLogger.ln("nihogno")
26
+ MyLogger.lw("nihogno")
27
+ end
28
+
29
+ end
30
+
31
+ describe "MyConfig" do
32
+ it "get should be success" do
33
+ MyConfig.get
34
+ end
35
+
36
+ it "set config file failue" do
37
+ proc {
38
+ MyConfig.dispose
39
+ MyConfig.set "aaaaaaaaaaa.yml"
40
+ p MyConfig.get
41
+ }.should raise_error
42
+ end
43
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,32 @@
1
+ require 'rubygems'
2
+ require 'spork'
3
+
4
+ Spork.prefork do
5
+ # Loading more in this block will cause your tests to run faster. However,
6
+ # if you change any configuration or code from libraries loaded here, you'll
7
+ # need to restart spork for it take effect.
8
+
9
+ end
10
+
11
+ Spork.each_run do
12
+ # This code will be run each time you run your specs.
13
+
14
+ end
15
+
16
+ # --- Instructions ---
17
+ # - Sort through your spec_helper file. Place as much environment loading
18
+ # code that you don't normally modify during development in the
19
+ # Spork.prefork block.
20
+ # - Place the rest under Spork.each_run block
21
+ # - Any code that is left outside of the blocks will be ran during preforking
22
+ # and during each_run!
23
+ # - These instructions should self-destruct in 10 seconds. If they don't,
24
+ # feel free to delete them.
25
+ #
26
+
27
+
28
+
29
+
1
30
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
31
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
32
  require 'rspec'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.1
4
+ version: 0.0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-01 00:00:00.000000000Z
12
+ date: 2011-09-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &2152500740 !ruby/object:Gem::Requirement
16
+ requirement: &2157852080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152500740
24
+ version_requirements: *2157852080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: eventmachine
27
- requirement: &2152500140 !ruby/object:Gem::Requirement
27
+ requirement: &2157850440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152500140
35
+ version_requirements: *2157850440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mechanize
38
- requirement: &2152499580 !ruby/object:Gem::Requirement
38
+ requirement: &2157849800 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2152499580
46
+ version_requirements: *2157849800
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &2152498940 !ruby/object:Gem::Requirement
49
+ requirement: &2157849080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>'
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.3.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152498940
57
+ version_requirements: *2157849080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &2152498200 !ruby/object:Gem::Requirement
60
+ requirement: &2157848400 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>'
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.6.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2152498200
68
+ version_requirements: *2157848400
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &2152497460 !ruby/object:Gem::Requirement
71
+ requirement: &2157847720 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>'
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152497460
79
+ version_requirements: *2157847720
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &2152496840 !ruby/object:Gem::Requirement
82
+ requirement: &2157846980 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2152496840
90
+ version_requirements: *2157846980
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &2152496180 !ruby/object:Gem::Requirement
93
+ requirement: &2157846260 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,29 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2152496180
101
+ version_requirements: *2157846260
102
+ - !ruby/object:Gem::Dependency
103
+ name: guard
104
+ requirement: &2157845560 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *2157845560
113
+ - !ruby/object:Gem::Dependency
114
+ name: guard-spork
115
+ requirement: &2157844900 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *2157844900
102
124
  description: longer description of your gem
103
125
  email: modeverv@gmail.com
104
126
  executables: []
@@ -114,13 +136,23 @@ files:
114
136
  - LICENSE.txt
115
137
  - README.rdoc
116
138
  - Rakefile
139
+ - TAGS
117
140
  - VERSION
118
- - lib/dev.rb
141
+ - lib/1.rb
142
+ - lib/lib/anisoku.rb
143
+ - lib/lib/job.rb
144
+ - lib/lib/machine.rb
145
+ - lib/lib/myat.rb
146
+ - lib/lib/myconfig.rb
147
+ - lib/lib/mydb.rb
148
+ - lib/lib/mygcal.rb
149
+ - lib/lib/mylogger.rb
150
+ - lib/lib/myobject.rb
151
+ - lib/lib/mypusher.rb
152
+ - lib/lib/runpersec.rb
119
153
  - lib/my-lib.rb
120
- - lib/opt-parse.rb
121
154
  - my-lib.gemspec
122
155
  - spec/my-lib_spec.rb
123
- - spec/opt-parse_spec.rb
124
156
  - spec/spec_helper.rb
125
157
  homepage: http://github.com/modeverv/my-lib
126
158
  licenses:
@@ -137,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
169
  version: '0'
138
170
  segments:
139
171
  - 0
140
- hash: 969569085450216819
172
+ hash: 3234728574918465057
141
173
  required_rubygems_version: !ruby/object:Gem::Requirement
142
174
  none: false
143
175
  requirements:
data/lib/dev.rb DELETED
@@ -1,363 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
-
3
- #! ruby
4
- # -*- coding: utf-8 -*-
5
- #
6
- # 俺俺な典型的な動作を提供する
7
- #
8
- # こんな感じで使うと良い
9
- #
10
- # require "/Users/seijiro/code/ruby/my-lib.rb"
11
- # class This < MyObject
12
- # include RunPerSecModule
13
- # include MyDBModule
14
- # include MyPusherModule
15
- # .....
16
- #
17
- # end
18
- #
19
-
20
- # 俺俺インスタンスをつくるためにクラスを用意した
21
- # 典型的なrequireを書きこんでいく
22
- # 読み込み済みモジュール
23
- # kconv time
24
- class MyObject
25
- def self.myrequire
26
- require "kconv"
27
- require "time"
28
- require "optparse"
29
- end
30
- end
31
-
32
- #~/config.ymlに配置された設定ファイルを読んで返す
33
- class MyConfig
34
- # 設定オブジェクトを返す
35
- def self.get
36
- self.read unless @data
37
- return @data
38
- end
39
-
40
- private
41
-
42
- def self.read
43
- require 'yaml'
44
- @data = YAML.load_file("#{ENV['HOME']}/config.yml")
45
- end
46
- end
47
-
48
- # 指定秒数ごとにrun関数をループする
49
- # 各メソッドを必要に応じて再定義して使う。
50
- #
51
- # 使い方:
52
- # someinstance.extend RunPerSecModule
53
- # someinstance.run(ループのインターバルsec){
54
- # __block__for__yield__
55
- # }
56
- #
57
- # OR
58
- #
59
- # class ThisDo < MyObject
60
- # include RunPerSecModule
61
- # .....
62
- #
63
- module RunPerSecModule
64
- # ループフラグ
65
- @loop_flg
66
-
67
- # main_loopをループする
68
- # sec : ループ間隔 秒
69
- # before_run_loop,ループ,after_run_loopの順番で実行する。
70
- # ループの中身はloop_hook_pre,与えられたブロック,main_loop,loop_hook_postの順番で実行する
71
- def run(sec)
72
- init_run_per_sec_module
73
- before_run_loop
74
- while @loop_flg
75
- loop_hook_pre
76
- yield
77
- main_loop
78
- loop_hook_post
79
- sleep sec
80
- end
81
- after_run_loop
82
- end
83
-
84
- # 外からは使わない
85
- # 無限ループフラグを立てる
86
- def init_run_per_sec_module
87
- @loop_flg = true
88
- end
89
-
90
- # runのループを止める
91
- def stop_run
92
- @loop_flg = false
93
- end
94
-
95
- # runメソッドが呼ばれるとループの前に一回だけ実行される
96
- def before_run_loop
97
- end
98
-
99
- # runメソッドのloopの中で最初に実行される
100
- def loop_hook_pre
101
- end
102
-
103
- # runメソッドのloopの中で実行される
104
- def main_loop
105
- end
106
-
107
- # runのループの中でmain_loopのあとで実行される
108
- def loop_hook_post
109
- end
110
-
111
- # runメソッドが呼ばれるとループのあとで実行される
112
- def after_run_loop
113
- end
114
- end
115
-
116
- # DBに接続してなんでもいれておくtableへのインサートを提供する
117
- #
118
- # @dbcon:DBコネクション
119
- # @insert:インサート文
120
- # @config:
121
- # ~/config.ymlに
122
- # mydbmodule:
123
- # server:localhost
124
- # port: 3389
125
- # socket:/tmp/mysql.sock
126
- # user:xxxx
127
- # pass:xxxxxx
128
- # database:xxxxx
129
- # を設定
130
- #
131
- # 使い方
132
- # class ThisDo
133
- # include MyDBModule
134
- # して
135
- # o = ThisDo.new
136
- # o.insert_DB("my_app_tail",'data')
137
- # でOK
138
- #
139
- module MyDBModule
140
- #DBコネクション
141
- @dbcon
142
-
143
- #インサート文
144
- @insert
145
-
146
- # DBに接続する
147
- def set_my_db
148
- require "mysql"
149
- @c = MyConfig.get
150
- @dbcon = Mysql::new(
151
- @c['mydbmodule']['server'],
152
- @c['mydbmodule']['user'],
153
- @c['mydbmodule']['pass'],
154
- @c['mydbmodule']['database'],
155
- @c['mydbmodule']['port'],
156
- @c['mydbmodule']['socket'],
157
- )
158
- @dbcon.query("set character set utf8") #おまじない
159
- @dbcon.query("use " + @c['mydbmodule']['database'])
160
- @insertsql = @dbcon.prepare("insert into keyvalue(`usage`,`value`) values (?,?);")
161
- end
162
-
163
- # テーブルにインサートする
164
- #
165
- # args
166
- # usage : string key
167
- # value : string value
168
- def insert_DB(key='test_app',value='')
169
- set_my_db if @dbcon == nil
170
- @insertsql.execute(key,value)
171
- end
172
- end
173
-
174
- # Pusherサービスへのアクセスを提供する
175
- # https://app.pusherapp.com/apps/7449/api_access?welcome=true
176
- # @pusher_app_id = 'your pusher app id'
177
- # @pusher_key = 'pusher key'
178
- # @pusher_secret = 'pusher secret'
179
- # @config
180
- # ~/config.ymlに
181
- # mypushermodule:
182
- # app_id:xxx
183
- # key:xxxxxxxxxxxxx
184
- # secret:xxxxxxxxxx
185
- # event:my_event
186
- # channel:test_channel
187
- #
188
- # 使い方など
189
- # class ThisDo
190
- # include MyPusherModule
191
- # して
192
- # o = ThisDo.new
193
- # o.push_pusher('test_app','test')
194
- # とかでok
195
- module MyPusherModule
196
-
197
- #pussherが設定されているか?
198
- @pusherconnected
199
-
200
- # Pusherへの接続を設定する
201
- def set_my_pusher
202
- @c = MyConfig.get['mypushermodule']
203
-
204
- require "pusher"
205
- Pusher.app_id = @c['app_id']
206
- Pusher.key = @c['key']
207
- Pusher.secret = @c['secret']
208
- @pusher_event = @c['event']
209
- @pusher_channel = @c['test_channel']
210
- end
211
-
212
- # Pusherにデータをpushする
213
- # args
214
- # app_name : string アプリの名前
215
- # data : string データ
216
- def push_pusher(app_name='test_app',data='test')
217
- if @pusherconnected == nil
218
- set_my_pusher
219
- @pusherconnected = true
220
- end
221
- begin
222
- Pusher[@pusher_channel].trigger!(
223
- @pusher_event, { app_name => data})
224
- rescue Pusher::Error => e
225
- p e
226
- end
227
- end
228
- end
229
-
230
-
231
- # Googleカレンダーへのアクセスを提供する
232
- #
233
- # ~/config.ymlに
234
- # gmail:
235
- # address:YourMailAdress@gmail.com
236
- # pass:xxxxxxxxxx
237
- # feedurl:http://www.google.com/calendar/feeds/xxxxxxxx%40gmail.com/private/full
238
- #
239
- # 使い方など
240
- # class ThisDo
241
- # include MyGCalModule
242
- # して
243
- # o = ThisDo.new
244
- # o.gcal_read
245
- # とかでok
246
- module MyGCalModule
247
- attr_accessor :gmail,:gmailpass,:gcalfeedurl,:gcal_query
248
-
249
- def gcal_read
250
- service
251
- @gcal_events = @gcal.events
252
- return self
253
- end
254
-
255
- #GCalへ書きこむ
256
- def gcal_write(eventdata)
257
- service
258
- event = @gcal.create_event
259
- event.title = eventdata[:title]
260
- event.st = eventdata[:start]
261
- event.en = eventdata[:end]
262
- event.save!
263
- @gcal_event = event
264
- return self
265
- end
266
-
267
- # gcalのイベントをAtMduleが食べれる形に変換する
268
- # 共通のJOBクラスで包もうかしら?
269
- def gcal_parse_2_jobs
270
- @gcal_jobs = []
271
- q = @gcal_query ||= '[Gcal2PusherTail'
272
- @gcal_events.each do |event|
273
- begin
274
- kind,filename = event.title.split(']')
275
- if(kind == @gcal_query && filename != nil)
276
- @gcal_jobs << {:filename => filename,
277
- :start => event.st,
278
- :end => event.en,
279
- :object => event}
280
- end
281
- rescue =>ex
282
- p ex
283
- #握りつぶす
284
- end
285
- end
286
- return self
287
- end
288
-
289
- #fetchしたデータの取り込み済みマークを立てる
290
- def gcal_checkout(event)
291
- event.title = '[FETCHED]' + event.title
292
- event.save!
293
- return self
294
- end
295
-
296
- # GCalへのアクセス
297
- def service
298
- if @gcal_srv.nil?
299
- require 'gcalapi'
300
- @c = MyConfig.get['gmail']
301
- @gcal_srv = GoogleCalendar::Service.new(@c['address'],@c['pass'])
302
- end
303
- @gcal = GoogleCalendar::Calendar::new(@gcal_srv, @c['feedurl'])
304
- end
305
- end
306
-
307
- # Atコマンドを突っ込む
308
- # MyGCalModuleとの連携で使う
309
- #
310
- # @config
311
- # ~/config.ymlに
312
- # atmodule:
313
- # scriptdir:/Users/seijiro/scripts
314
- # rbdir:/Users/seijiro/code/ruby
315
- #
316
- # 使い方など
317
- # class ThisDo
318
- # include MyAtModule
319
- # include MyGCalModule
320
- # して
321
- # o = ThisDo.new
322
- # とかでok
323
- module MyAtModule
324
- def initialize
325
- @c = MyConfig.get['atmodule']
326
- end
327
-
328
- def gcaljobs_2_at
329
- @gcal_jobs.each { |job| jobs2at(job) }
330
- return self
331
- end
332
-
333
- def jobs2at(job)
334
- command = _at_command(job)
335
- File.open("#{_at_scriptpath(job)}","w") do |io|
336
- io.write(command)
337
- end
338
-
339
- atcommand = "/usr/bin/at -f #{_at_scriptpath(job)} #{job[:start].localtime.strftime("%H:%M %m/%d/%y")}"
340
- p atcommand
341
- p command
342
- system atcommand
343
- gcal_checkout(job[:object])
344
- end
345
-
346
- def _at_scriptpath(job)
347
- "#{@c['scriptdir']}/job2at_#{job[:start].localtime.strftime("%Y%m%d%H%M")}.sh"
348
- end
349
-
350
- def _at_command(job)
351
- "#! /bin/bash
352
- #ユーザーの環境変数パスを使いたい
353
- source ~/.bashrc
354
- growlnotify -t 'Gcal2At' -m 'pusher tail #{job[:filename]} start . end is #{job[:start].localtime.strftime("%Y/%m/%d/%H/%M")}'
355
- ruby #{@c['rbdir']}/pushertail.rb #{job[:filename]} '#{job[:end].to_s}'
356
- "
357
- end
358
- end
359
-
360
-
361
-
362
- __END__
363
- test