pushpop-file 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/README.md +46 -0
- data/Rakefile +16 -0
- data/examples/colors.txt +8 -0
- data/examples/jobs.rb +19 -0
- data/lib/pushpop-file.rb +29 -0
- data/lib/pushpop-file/version.rb +5 -0
- data/pushpop-file.gemspec +21 -0
- data/spec/fixtures/file.txt +3 -0
- data/spec/pushpop-file_spec.rb +11 -0
- data/spec/spec_helper.rb +11 -0
- metadata +77 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Author Josh Dzielak
|
2
|
+
Copyright (c) 2014 Keen Labs
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
## pushpop-file
|
2
|
+
|
3
|
+
A Pushpop plugin for reading file contents.
|
4
|
+
|
5
|
+
### Installation
|
6
|
+
|
7
|
+
Add the `pushpop-file` gem to your Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem 'pushpop-file'
|
11
|
+
```
|
12
|
+
|
13
|
+
or install it:
|
14
|
+
|
15
|
+
``` shell
|
16
|
+
$ gem install pushpop-file
|
17
|
+
```
|
18
|
+
|
19
|
+
### Usage
|
20
|
+
|
21
|
+
Here's a simple job that reads a `usernames.txt` file and prints each line:
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
require 'pushpop-file'
|
25
|
+
|
26
|
+
job do
|
27
|
+
|
28
|
+
# emit the file contents as an array of lines
|
29
|
+
file do
|
30
|
+
path 'usernames.txt'
|
31
|
+
end
|
32
|
+
|
33
|
+
# print each line to show the output
|
34
|
+
step 'print each line' do |last_response|
|
35
|
+
last_response.each do |line|
|
36
|
+
puts line
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
### Contributing
|
44
|
+
|
45
|
+
Code and documentation issues and pull requests are welcome. Help us make this template as
|
46
|
+
useful as possible!
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$stdout.sync = true
|
2
|
+
|
3
|
+
$: << File.join(File.dirname(__FILE__), './lib')
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
desc 'Run Rspec unit tests'
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
9
|
+
t.pattern = 'spec/**/*_spec.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
task default: :spec
|
13
|
+
rescue LoadError
|
14
|
+
end
|
15
|
+
|
16
|
+
|
data/examples/colors.txt
ADDED
data/examples/jobs.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# from this repository run with:
|
2
|
+
# $ foreman run bundle exec ruby examples/jobs.rb
|
3
|
+
|
4
|
+
require 'pushpop'
|
5
|
+
require_relative '../lib/pushpop-file'
|
6
|
+
|
7
|
+
job do
|
8
|
+
file do
|
9
|
+
path File.expand_path('../colors.txt', __FILE__)
|
10
|
+
end
|
11
|
+
|
12
|
+
step do |last_response|
|
13
|
+
last_response.each do |line|
|
14
|
+
puts line
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Pushpop.run
|
data/lib/pushpop-file.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'pushpop'
|
2
|
+
|
3
|
+
module Pushpop
|
4
|
+
|
5
|
+
class File < Step
|
6
|
+
|
7
|
+
PLUGIN_NAME = 'file'
|
8
|
+
|
9
|
+
Pushpop::Job.register_plugin(PLUGIN_NAME, self)
|
10
|
+
|
11
|
+
def run(last_response=nil, step_responses=nil)
|
12
|
+
|
13
|
+
self.configure(last_response, step_responses)
|
14
|
+
|
15
|
+
::File.read(@path).split("\n")
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def path(str)
|
20
|
+
@path = str
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure(last_response=nil, step_responses=nil)
|
24
|
+
self.instance_exec(last_response, step_responses, &block)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'pushpop-file/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
|
7
|
+
s.name = "pushpop-file"
|
8
|
+
s.version = Pushpop::File::VERSION
|
9
|
+
s.authors = ["Josh Dzielak"]
|
10
|
+
s.email = "josh@keen.io"
|
11
|
+
s.homepage = "https://github.com/pushpop-project/pushpop-file"
|
12
|
+
s.summary = "A Pushpop plugin for reading file contents"
|
13
|
+
|
14
|
+
s.add_dependency "pushpop"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pushpop::File do
|
4
|
+
it 'should emit file contents as an array of strings' do
|
5
|
+
step = Pushpop::File.new do
|
6
|
+
path File.expand_path("../fixtures/file.txt", __FILE__)
|
7
|
+
end
|
8
|
+
result = step.run
|
9
|
+
expect(result).to eq(["one", "two", "three"])
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pushpop-file
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Dzielak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pushpop
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description:
|
31
|
+
email: josh@keen.io
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- .travis.yml
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- examples/colors.txt
|
43
|
+
- examples/jobs.rb
|
44
|
+
- lib/pushpop-file.rb
|
45
|
+
- lib/pushpop-file/version.rb
|
46
|
+
- pushpop-file.gemspec
|
47
|
+
- spec/fixtures/file.txt
|
48
|
+
- spec/pushpop-file_spec.rb
|
49
|
+
- spec/spec_helper.rb
|
50
|
+
homepage: https://github.com/pushpop-project/pushpop-file
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.23
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: A Pushpop plugin for reading file contents
|
74
|
+
test_files:
|
75
|
+
- spec/fixtures/file.txt
|
76
|
+
- spec/pushpop-file_spec.rb
|
77
|
+
- spec/spec_helper.rb
|