pure-extractor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e86c4f9ccfa73b45bbc332923846e67df4364a6d
4
+ data.tar.gz: 8e51dc6ee010b75a3e0991d3077afabc19509bd7
5
+ SHA512:
6
+ metadata.gz: 77d773162fb19a2ba38b61ac7a9297961cb19fc681f970f079c147e50f209cc7e29bd9cb5471557de73e8988824961e48754b0f1b49318c4e1610b0db187cacf
7
+ data.tar.gz: 1c69242edc0ddc3b560c0644a774eeff085498b404176864306d90fcc9cc45c282ac31c1d7bd3dfb908890d7ffec3383daeb22300f261e30b2e3b12000803a8e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pure-extractor.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Pure::Extractor
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pure/extractor`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'pure-extractor'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install pure-extractor
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pure-extractor.
36
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pure/extractor"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pure/extractor"
5
+
6
+ Pure::Extractor::Commands::PureExtractorCommand.run
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pure/extractor"
5
+
6
+ Pure::Extractor::Commands::PureOrganisationExtractorCommand.run
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require "pure/extractor/version"
2
+ require "pure/extractor/configure_puree"
3
+ require "pure/extractor/commands/pure_extractor"
4
+ require "pure/extractor/commands/pure_organisation_extractor"
5
+ require "pure/extractor/organisation"
6
+
7
+ module Pure
8
+ module Extractor
9
+ # Your code goes here...
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ require 'clamp'
2
+
3
+ module Pure
4
+ module Extractor
5
+ module Commands
6
+ class PureCommand < Clamp::Command
7
+
8
+ option ["-o", "--output-folder"], "folder", "folder to output to", required: true
9
+ option ["-s", "--server"], "server", "Full url to Pure WS rest server", required: true
10
+ option ["-u", "--username"], "username", "Username to connect to Pure WS", required: true
11
+ option ["-p", "--password"], "password", "Password to connect to Pure WS", required: true
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ require 'pure/extractor/commands/pure_command'
2
+ require 'puree'
3
+
4
+ module Pure
5
+ module Extractor
6
+ module Commands
7
+ class PureExtractorCommand < PureCommand
8
+
9
+ include Pure::Extractor::ConfigurePuree
10
+
11
+ valid_extracts = [:organisation, :people]
12
+
13
+ parameter "EXTRACT", "what to extract from pure" do |s|
14
+
15
+ s = s.to_sym
16
+
17
+ raise ArgumentError.new("Must be a valid extract area from #{valid_extracts.map{|v| v.to_s}}") unless valid_extracts.include? s
18
+
19
+ s
20
+
21
+ end
22
+
23
+ def execute
24
+
25
+ configure_puree server, username, password
26
+
27
+ case extract
28
+
29
+ when :organisation
30
+
31
+ Pure::Extractor::Organisation.extract output_folder
32
+
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,22 @@
1
+ require 'pure/extractor/commands/pure_command'
2
+ require 'puree'
3
+
4
+ module Pure
5
+ module Extractor
6
+ module Commands
7
+ class PureOrganisationExtractorCommand < PureCommand
8
+
9
+ include Pure::Extractor::ConfigurePuree
10
+
11
+ def execute
12
+
13
+ configure_puree server, username, password
14
+
15
+ Pure::Extractor::Organisation.extract output_folder
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ require 'puree'
2
+
3
+ module Pure
4
+ module Extractor
5
+ module ConfigurePuree
6
+
7
+ def configure_puree server, username, password
8
+
9
+ Puree.configure do |config|
10
+
11
+ config.base_url = server
12
+
13
+ if !username.empty? && !password.empty?
14
+
15
+ config.username = username
16
+ config.password = password
17
+ config.basic_auth = true
18
+
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,51 @@
1
+ require 'puree'
2
+ require 'json'
3
+
4
+ module Pure
5
+ module Extractor
6
+ class Organisation
7
+
8
+ def self.extract output_folder
9
+
10
+ filename = "organisation.json"
11
+
12
+ org = Puree::Collection.new resource: :organisation
13
+
14
+ org_uuids = org.find limit: 1000000000, full: false
15
+
16
+ org_uuids.count
17
+
18
+ offset = 0
19
+ limit = 20
20
+
21
+ orgs = []
22
+
23
+ while offset < org_uuids.count do
24
+
25
+ returned_orgs = org.find limit: limit, offset: offset
26
+
27
+ returned_orgs.each do |r_org|
28
+
29
+ r_org.delete("address")
30
+ r_org.delete("email")
31
+ r_org.delete("organisation")
32
+ r_org.delete("phone")
33
+ r_org.delete("url")
34
+
35
+ end
36
+
37
+ orgs.concat(returned_orgs)
38
+
39
+ offset += limit
40
+
41
+ end
42
+
43
+ File.open(output_folder + "/" + filename, "w") do |f|
44
+ f.write(orgs.to_json)
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ module Pure
2
+ module Extractor
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pure/extractor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pure-extractor"
8
+ spec.version = Pure::Extractor::VERSION
9
+ spec.authors = ["Stephen Robinson", "LULibrary"]
10
+ spec.email = ["library.dit@lancaster.ac.uk"]
11
+
12
+ spec.summary = %q{Command line application to extract data from Pure and write to JSON files for DMAO}
13
+ spec.description = %q{Command line application to extract data from Pure and write to JSON files for DMAO}
14
+ spec.homepage = "https://github.com/lulibrary"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "clamp"
30
+ spec.add_dependency "puree"
31
+
32
+ spec.add_dependency "bundler", "~> 1.12"
33
+
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "minitest"
36
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pure-extractor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Robinson
8
+ - LULibrary
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-09-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: clamp
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: puree
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.12'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.12'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: minitest
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: Command line application to extract data from Pure and write to JSON
85
+ files for DMAO
86
+ email:
87
+ - library.dit@lancaster.ac.uk
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/pure-extractor
98
+ - bin/pure-organisation-extractor
99
+ - bin/setup
100
+ - lib/pure/extractor.rb
101
+ - lib/pure/extractor/commands/pure_command.rb
102
+ - lib/pure/extractor/commands/pure_extractor.rb
103
+ - lib/pure/extractor/commands/pure_organisation_extractor.rb
104
+ - lib/pure/extractor/configure_puree.rb
105
+ - lib/pure/extractor/organisation.rb
106
+ - lib/pure/extractor/version.rb
107
+ - pure-extractor.gemspec
108
+ homepage: https://github.com/lulibrary
109
+ licenses: []
110
+ metadata:
111
+ allowed_push_host: https://rubygems.org
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.5.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Command line application to extract data from Pure and write to JSON files
132
+ for DMAO
133
+ test_files: []