Birst_Command 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/Birst_Command.gemspec +2 -1
- data/README.md +43 -33
- data/bin/birstcl +10 -6
- data/lib/birst_command/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 662351a7efa2b85710e7eb37986a00bc452c0c92
|
4
|
+
data.tar.gz: fec8a4a7cf294a572a937e26a7ab50192e6d18b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b71cce7ef718ca3d3d2409002208dc83826d37c7b5ba8970c403aabc48cd9fdd1792992f7b9fdcacb8dca8cc529b659917b80589e79f5a0da4e76fea3ca14345
|
7
|
+
data.tar.gz: 1d8b12dc02b8b293540fedb866c95b3013b8ae270ff1a3de2356d4c44a3d8835d369e0d76e6d536a384d5e6fcfb4f3386f9323087373a2736f9bfe72ac416bd0
|
data/Birst_Command.gemspec
CHANGED
@@ -12,8 +12,9 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.license = "MIT"
|
13
13
|
s.summary = "Birst Command"
|
14
14
|
s.description = "Ruby interface to Birst web API"
|
15
|
-
|
16
15
|
s.rubyforge_project = "Birst_Command"
|
16
|
+
|
17
|
+
s.required_ruby_version = '~> 2'
|
17
18
|
s.add_runtime_dependency "savon", ["~> 2.0"]
|
18
19
|
s.add_runtime_dependency "httpclient", ["~> 2.3"]
|
19
20
|
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ to a secure location**. If any attacker is able to get your
|
|
36
36
|
obfuscated password and knows it was created using this program, it
|
37
37
|
would be trivial to get your Birst login credentials.
|
38
38
|
|
39
|
-
# Usage -
|
39
|
+
# Usage - Birst command line tool
|
40
40
|
|
41
41
|
Birst Command also installs a rudimentary command line tool for interacting
|
42
42
|
with the Birst web API. It's still very simple. If you want more functionality,
|
@@ -65,45 +65,51 @@ Copy space with options
|
|
65
65
|
|
66
66
|
In your Ruby program, include the Birst Command gem and load the config file via
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
````ruby
|
69
|
+
require 'rubygems'
|
70
|
+
require 'bundler/setup'
|
71
|
+
require 'Birst_Command'
|
71
72
|
|
72
|
-
|
73
|
+
Birst_Command::Config.read_config(File.join(File.dirname(__FILE__),"config.json"))
|
74
|
+
````
|
73
75
|
|
74
76
|
Birst commands are submitted in session blocks, which automatically
|
75
77
|
perform the process of logging in, tracking the login token, and
|
76
78
|
logging out. For example, to list all spaces that you have rights to,
|
77
79
|
you can submit the following code
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
````ruby
|
82
|
+
Birst_Command::Session.start do |bc|
|
83
|
+
spaces = bc.list_spaces
|
84
|
+
puts "#{JSON.pretty_generate spaces}"
|
85
|
+
end
|
86
|
+
````
|
83
87
|
|
84
88
|
Which would return something like
|
85
89
|
|
90
|
+
````ruby
|
91
|
+
{
|
92
|
+
"user_space": [
|
86
93
|
{
|
87
|
-
"
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
"owner": "name@myplace.com",
|
96
|
-
"id": "a113207d-3fe2-4310-1b4a-b58e961da123"
|
97
|
-
}
|
98
|
-
]
|
94
|
+
"name": "MyGreatSpace",
|
95
|
+
"owner": "name@myplace.com",
|
96
|
+
"id": "b413207d-3fe2-4309-1b4a-ac8e961daad2"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"name": "MyOtherGreatSpace",
|
100
|
+
"owner": "name@myplace.com",
|
101
|
+
"id": "a113207d-3fe2-4310-1b4a-b58e961da123"
|
99
102
|
}
|
103
|
+
]
|
104
|
+
}
|
105
|
+
````
|
100
106
|
|
101
107
|
The `spaces` variable is a Ruby hash parsed from the SOAP response.
|
102
108
|
The structure of the returned hash follows the structure that Birst
|
103
109
|
returns.
|
104
110
|
|
105
111
|
|
106
|
-
## Helper
|
112
|
+
## Helper methods
|
107
113
|
|
108
114
|
I find some of the Birst API responses to be rather cumbersome. For
|
109
115
|
example, why do I need hash with a single `user_space` key? I'd
|
@@ -112,12 +118,14 @@ to define helper methods that extend the Session class to simplify
|
|
112
118
|
some of this. To override the return value of the native
|
113
119
|
`list_spaces` command, you can do the following
|
114
120
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
+
````ruby
|
122
|
+
class Birst_Command::Session
|
123
|
+
def list_spaces(*args)
|
124
|
+
result = command __method__, *args
|
125
|
+
[result[:user_space]].flatten
|
126
|
+
end
|
127
|
+
end
|
128
|
+
````
|
121
129
|
|
122
130
|
You can then execute the same `list_spaces` command above, but you get
|
123
131
|
an array of hashes rather than hash with a key that points to an array
|
@@ -132,11 +140,13 @@ provides the basic interface.
|
|
132
140
|
Some Birst API commands require arguments. All arguments are supplied
|
133
141
|
as an argument hash. For example, to create a new space,
|
134
142
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
143
|
+
````ruby
|
144
|
+
Birst_Command::Session.start do |bc|
|
145
|
+
new_space_id = bc.create_new_space :spaceName => "myNewSpace",
|
146
|
+
:comments => "Just testing",
|
147
|
+
:automatic => "false"
|
148
|
+
end
|
149
|
+
````
|
140
150
|
|
141
151
|
## camelCase/snake_case issues
|
142
152
|
|
data/bin/birstcl
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# FOR TESTING ONLY
|
4
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__),"../lib")
|
5
|
-
require 'rubygems'
|
6
|
-
require 'bundler/setup'
|
7
|
-
# REMOVE THE ABOVE
|
8
|
-
|
9
3
|
require "birst_command"
|
10
4
|
require "optparse"
|
11
5
|
|
@@ -22,6 +16,11 @@ module BirstCL
|
|
22
16
|
@options[:verbose] = v
|
23
17
|
end
|
24
18
|
|
19
|
+
@options[:version] = false
|
20
|
+
opts.on("--version", "--version", "Print version") do |v|
|
21
|
+
@options[:version] = true
|
22
|
+
end
|
23
|
+
|
25
24
|
opts.on("-h","--help", "Show this message") do
|
26
25
|
puts opts
|
27
26
|
exit
|
@@ -49,6 +48,11 @@ module BirstCL
|
|
49
48
|
@options[:config_full_path] = opt
|
50
49
|
end
|
51
50
|
end.parse!
|
51
|
+
|
52
|
+
if @options[:version]
|
53
|
+
puts "Birst_Command Version: #{Birst_Command::VERSION}"
|
54
|
+
exit
|
55
|
+
end
|
52
56
|
end
|
53
57
|
|
54
58
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Birst_Command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sterling Paramore
|
@@ -85,9 +85,9 @@ require_paths:
|
|
85
85
|
- lib
|
86
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
90
|
+
version: '2'
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - '>='
|