Birst_Command 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58f9b1e8e6efa926c798dce89e9135c72faa9899
4
- data.tar.gz: bdac960c6a738e563bec501a64adf03bd7eae28b
3
+ metadata.gz: 662351a7efa2b85710e7eb37986a00bc452c0c92
4
+ data.tar.gz: fec8a4a7cf294a572a937e26a7ab50192e6d18b6
5
5
  SHA512:
6
- metadata.gz: f7d27fb486170d53a80d6bf946672d2f71cb8e29ed2c292827452f35fb1c21789c6a894816d72dd959b5f06301d7c4da606440dbc6f1bd5c31a89ea8d3c51bf2
7
- data.tar.gz: 144d996dd5e0bd9fbd8d73bdd0cfa70a5345371a85084b2fef7ea321f5964e710e0a870c366aacc83c02181135768b1548fb688987806e3a77f91505818763fb
6
+ metadata.gz: b71cce7ef718ca3d3d2409002208dc83826d37c7b5ba8970c403aabc48cd9fdd1792992f7b9fdcacb8dca8cc529b659917b80589e79f5a0da4e76fea3ca14345
7
+ data.tar.gz: 1d8b12dc02b8b293540fedb866c95b3013b8ae270ff1a3de2356d4c44a3d8835d369e0d76e6d536a384d5e6fcfb4f3386f9323087373a2736f9bfe72ac416bd0
@@ -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 - Command-line tool
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
- require 'rubygems'
69
- require 'bundler/setup'
70
- require 'Birst_Command'
68
+ ````ruby
69
+ require 'rubygems'
70
+ require 'bundler/setup'
71
+ require 'Birst_Command'
71
72
 
72
- Birst_Command::Config.read_config(File.join(File.dirname(__FILE__),"config.json"))
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
- Birst_Command::Session.start do |bc|
80
- spaces = bc.list_spaces
81
- puts "#{JSON.pretty_generate spaces}"
82
- end
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
- "user_space": [
88
- {
89
- "name": "MyGreatSpace",
90
- "owner": "name@myplace.com",
91
- "id": "b413207d-3fe2-4309-1b4a-ac8e961daad2"
92
- },
93
- {
94
- "name": "MyOtherGreatSpace",
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 Methods
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
- class Birst_Command::Session
116
- def list_spaces(*args)
117
- result = command __method__, *args
118
- [result[:user_space]].flatten
119
- end
120
- end
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
- Birst_Command::Session.start do |bc|
136
- new_space_id = bc.create_new_space :spaceName => "myNewSpace",
137
- :comments => "Just testing",
138
- :automatic => "false"
139
- end
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
 
@@ -1,3 +1,3 @@
1
1
  module Birst_Command
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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: '0'
90
+ version: '2'
91
91
  required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - '>='